I am using struts2 application but its asking the spring configuration - struts2

I am getting the following error when i am trying to run the manning examples separately out of the sand box.
Error as follows:
You might need to add the following to web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Jun 17, 2013 7:17:39 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:188)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:479)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:450)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:407)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:239)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>manning</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>anotherServlet</servlet-name>
<servlet-class>manning.servlet.AnotherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>anotherServlet</servlet-name>
<url-pattern>/anotherServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!--
For the purposes of the book, we will leave devMode set to true. This
allows several things to occur including provision of debugging level information
on error pages as well as reloading of various resources with each request.
-->
<constant name="struts.devMode" value="true" />
<!--
You can define packages directly in this file, but its probably best
to modularize the configuration files with separate xml files for each
package. Ulitmately its all the same because the include element, seen
below, pulls the included configuration document directly in to the
primary document. The only thing to consider is that a referenced
element must have been declared above the referring element.
-->
<!--
This is the menu action that will allow the reader to see the different
samples actions from the different chapters in a menu format. We declare
it here, in the root namespace, because its not really related to any of the
specific examples or chapters, its just a kind of utility for the whole
application.
-->
<package name="default" namespace="/" extends="struts-default">
<action name="Menu">
<result>/menu/Menu.jsp</result>
</action>
</package>
<include file="manning/chapterTwo/chapterTwo.xml"/>
<include file="manning/chapterThree/chapterThree.xml"/>
<include file="manning/chapterThree/objectBacked/chapterThree.xml"/>
<include file="manning/chapterThree/modelDriven/chapterThree.xml"/>
<include file="manning/chapterFour/chapterFour.xml"/>
<include file="manning/chapterFive/chapterFive.xml"/>
<include file="manning/chapterSix/chapterSix.xml"/>
<include file="manning/chapterSeven/chapterSeven.xml"/>
<include file="manning/chapterEight/chapterEight.xml"/>
<include file="manning/chapterNine/chapterNine.xml"/>
<include file="manning/chapterTen/chapterTen.xml"/>
<include file="manning/chapterEleven/chapterEleven.xml"/>
</struts>
Why i am getting the error. I have removed some configuration regarding spring in web.xml

Change your filter to below
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
And remove struts2-spring-plugin-*.jar from classpath if you have this jar in your classpath and dont want to use Spring integration with Struts2
Please let me know if you still face issue

Related

How to use JNDI with the tc server and postgresql in STS? (Unable to create initial connections of pool.)

I want to use JPA/JNDI, as my experience with Netbeans and Glassfish has been that I could configure database settings at the server and so I'd be able to publish to different servers without changing anything in the code or configuration.
I don't really get what's wrong and paste my configuration here in the hope that you can help me with some advice.
I successfully tried to get a database connection with this persistence unit:
<persistence-unit name="primefaces-showcase"
transaction-type="RESOURCE_LOCAL">
<class>org.primefaces.showcase.domain.Car</class>
<properties>
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/database" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="pass" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
</properties>
</persistence-unit>
I used it like this
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("primefaces-showcase");
EntityManager em = emf.createEntityManager();
But when I want to use JNDI like this
#PersistenceContext(unitName = "primefaces-jta")
private EntityManager em;
I get this console output that tells me it can't create initial connections of pool:
Sep 29, 2014 2:09:39 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNUNG: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:primefaces-showcase' did not find a matching property.
Sep 29, 2014 2:09:42 PM org.apache.tomcat.jdbc.pool.ConnectionPool init
SCHWERWIEGEND: Unable to create initial connections of pool.
java.sql.SQLException
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:486)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:144)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:554)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:242)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:141)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.NamingContext.lookup(NamingContext.java:830)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1093)
at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:672)
at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:270)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:670)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
... 32 more
/primefaces-showcase/src/main/java/org/primefaces/showcase/service/CarService.java
#ManagedBean(name = "carService")
#ApplicationScoped
public class CarService {
#PersistenceContext(unitName = "primefaces-jta")
private EntityManager em;
public List<Car> createCars(int size) {
List<Car> list = new ArrayList<Car>();
for (int i = 0; i < size; i++) {
em.getTransaction().begin();
Car car = new Car(getRandomId(), getRandomBrand(), getRandomYear(),
getRandomColor(), getRandomPrice(), getRandomSoldState());
list.add(car);
em.persist(car);
em.getTransaction().commit();
}
return list;
}
/primefaces-showcase/src/main/java/META-INF/persistence.xml
<persistence-unit name="primefaces-jta"
transaction-type="JTA">
<jta-data-source>jdbc/postgres</jta-data-source>
<properties>
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
</properties>
</persistence-unit>
/primefaces-showcase/src/main/java/META-INF/context.xml
<Context>
<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432/database"
username="postgres" password="pass" maxActive="20" maxIdle="10"
maxWait="-1" />
<!-- <ResourceLink global="jdbc/postgres" name="jdbc/postgres" -->
<!-- type="javax.sql.DataSource" /> -->
</Context>
/primefaces-showcase/src/main/webapp/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- SPRING ROOT WEB APPLICATION CONTEXT -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- SPRING SECURITY -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<servlet-name>Spring MVC Servlet</servlet-name>
</filter-mapping>
<!-- JSF 2 IMPLEMENTATION -->
<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Enables special Facelets debug output during development -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Causes Facelets to refresh templates during development -->
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Just here so the JSF implementation can initialize -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<!-- SPRING MVC -->
<servlet>
<servlet-name>Spring MVC Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Servlet</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Spring MVC Servlet</servlet-name>
</filter-mapping>
<!-- Spring Security Facelets tag library declaration -->
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param>
<!-- DEFAULT PAGE -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
UPDATE 2014-10-09:
Problem solved by adding the driver to pom.xml
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1100-jdbc41</version>
</dependency>
Make sure you have the postgres driver library in the classpath.

Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter [duplicate]

This question already has answers here:
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuterFilter
(4 answers)
Closed 6 years ago.
I just started learning struts2 when I am trying to deploy to tomcat I am encountering the following error
Exception starting filter struts2
java.lang.ClassNotFoundException:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
I went through couple of other posts but I am unable to resolve the issue please help me..
Thanks much !
/here is the web.xml file I am using/
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Struts2Start</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
/Struts.xml/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="getTutorial" class="com.javabrains.struts.action.TutorialAction">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
/console/
SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I figured out my problem was that I forgot to export my user defined libraries, in this case, struts libraries. You can export the libraries via Eclipse by
Go to the Markers tab (If you can't see, do Windows > Show View > Markers)
Expand "Classpath Dependency Validator Message"
Right click "Classpath entry org.eclipse.jdt.USER_LIBRARY/struts2 will not be exported or published. Runtime ClassNotFoundExceptions may result."
Click "Quick Fix"
Select "Mark the associated raw classpath entry as a publish/export dependency."
click "Finish"
There could be some reasons to get this error. One of the reason can be the version of jar you use does not have the required class. Check struts2-core-X.X.X.X.jar, and make sure that it contains StrutsPrepareAndExecuteFilter class under org.apache.struts2.dispatcher.ng.filter package.
Use the following jars and remove all others.
commons-fileupload-1.3.jar
commons-io-2.0.1.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.15.1.jar
xwork-core-2.3.15.1.jar
I had the same problem. I was able to solve it by adding a few more jar files. You must have at least the following jar files:
commons-fileupload-X.X.X.jar
commons-io-X.X.jar
commons-lang-X.X.jar
commons-logging-X.X.X.jar
commons-logging-api-X.X.jar
commons-lang3-X.X.jar
freemaker-X.X.X.jar
javassist-X.X.X.GA.jar
ognl-X.X.X.jar
struts2-core-X.X.X.X.jar
xwork-core-X.X.X.X.jar

Exception with Struts 2.3.15.2 org.apache.struts2.tiles.StrutsTilesListener

I upgraded from Struts 2.0.8 to 2.3.15.2
Am getting below error when starting my apache tomcat server.
Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener
**INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
Oct 16, 2013 1:03:07 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class
org.apache.struts2.tiles.StrutsTilesListener
java.lang.NullPointerException
at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)
at org.apache.commons.digester.Digester.parse(Digester.java:1887)
at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:267)**
I am using the following jar files in my WEB-INF/lib folder
commons-beanutils-1.8.0.jar
commons-codec-1.6.jar
commons-collections-3.1.jar
commons-dbcp.jar
commons-digester-2.0.jar
commons-fileupload-1.3.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
commons-pool-1.6.jar
crimson.jar
displaytag-1.1.jar
displaytag-export-poi-1.1.jar
fluent-hc-4.2.3.jar
freemarker-2.3.19.jar
httpclient-4.2.3.jar
httpclient-cache-4.2.3.jar
httpcore-4.2.2.jar
httpmime-4.2.3.jar
itext-2.0.4.jar
javax.mail_1.4.0.v201005080615.jar
jstl.jar
log4j-12.jar
mail.jar
ognl-3.0.6.jar
ojdbc6.jar
poi-3.0.1-FINAL-20070705.jar
standard.jar
struts2-core-2.3.15.2.jar
struts2-tiles3-plugin-2.3.15.2.jar
struts2-tiles-plugin-2.3.15.2.jar
struts-core-1.3.10.jar
tiles-api-2.0.6.jar
tiles-core-2.0.6.jar
tiles-jsp-2.0.6.jar
xwork-core-2.3.15.2.jar
WEB.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>My Web Application</display-name>
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>ResponseOverrideFilter</filter-name>
<filter-class>
org.displaytag.filter.ResponseOverrideFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>ResponseOverrideFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<listener>
<listener-class>com.comp.ccra.listener.CCRAContextListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
STRUTS.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="ccra" extends="struts-default" >
<interceptors>
<interceptor name="login" class="com.comp.ccra.action.interceptor.LoginInterceptor"/>
<interceptor-stack name="defaultLoginStack">
<interceptor-ref name="login"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<!-- Make the defaultLoginStack the default one used
for all actions unless otherwise configured. -->
<default-interceptor-ref name="defaultLoginStack" />
<global-results>
<result name="exception">/WEB-INF/jsp/exception.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="org.apache.tomcat.dbcp.dbcp.SQLNestedException" result="exception"/>
<exception-mapping exception="javax.servlet.ServletException" result="exception"/>
<exception-mapping exception="java.sql.SQLException" result="exception"/>
<exception-mapping exception="java.lang.Exception" result="exception"/>
</global-exception-mappings>
</package>
<include file="struts-filedownload.xml" />
<include file="struts-fileupload.xml" />
<include file="struts-common.xml" />
<include file="struts-report.xml" />
<include file="struts-admin.xml" />
</struts>
TILES.xml
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<!-- Definitions for Tiles documentation -->
<tiles-definitions>
<!-- ======================================================= -->
<!-- Master definition -->
<!-- ======================================================= -->
<definition name="basicLayout" template="/WEB-INF/tiles/layout/basicLayout.jsp">
<put-attribute name="title" value="Call Center Connection (C3)"/>
<put-attribute name="header" type="template" value="/WEB-INF/tiles/layout/header.jsp"/>
<put-attribute name="navigation" type="template" value="/WEB-INF/tiles/layout/navigation.jsp"/>
<put-attribute name="body" type="template" value="/WEB-INF/tiles/layout/empty.jsp"/>
<put-attribute name="info" type="template" value="/WEB-INF/tiles/layout/info.jsp"/>
<put-attribute name="footer" type="template" value="/WEB-INF/tiles/layout/footer.jsp"/>
</definition>
<definition name="homePage" extends="basicLayout" >
</definition>
</tiles-definitions>
Please suggest if i am doing anything wrong here. Any help is greatly appreciated.
You cannot mix two different Tiles versions, use either struts2-tiles3-plugin-2.3.15.2.jar or struts2-tiles-plugin-2.3.15.2.jar.
And follow the docs depending on Tiles version:
http://struts.apache.org/release/2.3.x/docs/tiles-plugin.html
http://struts.apache.org/release/2.3.x/docs/tiles-3-plugin.html

Tile 3 does not work on struts2

I am trying to use Tile plugin in my struts2 application, but I am receiving the following error,
"Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.apache.struts2.tiles.StrutsTilesListener. Please see server.log for more details."
I have the following jar files:
tiles-api-3.0.1.jar
tiles-autotag-core-runtime-1.1.0.jar
tiles-compat-3.0.1.jar
tiles-core-3.0.1.jar
tiles-el-3.0.1.jar
tiles-extras-3.0.1.jar
tiles-freemarker-3.0.1.jar
tiles-jsp-3.0.1.jar
tiles-mvel-3.0.1.jar
tiles-ognl-3.0.1.jar
tiles-request-api-1.0.1.jar
tiles-request-freemarker-1.0.1.jar
tiles-request-jsp-1.0.1.jar
tiles-request-mustache-1.0.1.jar
tiles-request-servlet-1.0.1.jar
tiles-request-servlet-wildcard-1.0.1.jar
tiles-request-velocity-1.0.1.jar
tiles-servlet-3.0.1.jar
tiles-template-3.0.1.jar
tiles-velocity-3.0.1.jar
commons-beanutils-1.8.0.jar
commons-digester-2.0.jar
jcl-over-slf4j-1.5.8.jar
slf4j-api-1.5.8.jar
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="register">
<result type="tiles">register</result>
</action>
</package>
</struts>
My struts library files
Struts 2.3.4 Core Libraries - xwork-core-2.3.4.jar
Struts 2.3.4 Core Libraries - struts2-core-2.3.4.jar
Struts 2.3.4 Core Libraries - struts2-convention-plugin-2.3.4.jar
Struts 2.3.4 Core Libraries - ognl-3.0.5.jar
Struts 2.3.4 Core Libraries - javassist-3.11.0.GA.jar
Struts 2.3.4 Core Libraries - freemarker-2.3.19.jar
Struts 2.3.4 Core Libraries - commons-lang3-3.1.jar
Struts 2.3.4 Core Libraries - commons-io-2.0.1.jar
Struts 2.3.4 Core Libraries - commons-fileupload-1.2.2.jar
Struts 2.3.4 Core Libraries - asm-tree-3.3.jar
Struts 2.3.4 Core Libraries - asm-commons-3.3.jar
Struts 2.3.4 Core Libraries - asm-3.3.jar

struts2 ignore particular pattern

I am using strust2 for my web application development. My struts.xml file will be like:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default" namespace ="/">
<action name="signup">
<result>/check.jsp</result>
</action>
</package>
</struts>
and my web.xml file will be something like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>sample</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>My WS</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.dr1.dr2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>My WS</servlet-name>
<url-pattern>/checking</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
and now,
if i access like: http://localhost:8080/appName/ its going to my signup action perfectly.
But when i tried to access like http://localhost:8080/appName/checking (for webservices), Its even looking in struts.xml and getting an error message like:
HTTP Status 404 - There is no Action mapped for namespace / and action name checking...
even after defining this in web.xml..
Is there any way to exclude a pattern in struts2, so that when I hit http://localhost:8080/appName/checking, it must not look struts action, it must call my default page path defined in web.xml file.
Thanks..
you can probably add exclude pattern in your struts.xml, something like
<struts>
<constant name="struts.action.excludePattern" value="appName/checking"/>
</struts>
read here and find excludePattern for more information.
this could works:
<!-- exclude pattern -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/struts/*</url-pattern>
</filter-mapping>
an action exampe:
<constant name="struts.action.excludePattern" value="appName/checking"/>
the constant excludePattern explicit exclusions (since 2.1.7)

Resources