Deploy Grails 2.3.0 to Glassfish Server - grails

I have an application build with Grails 2.3.0 and type command 'grails war' to generate a war file.
I type following command to deploy the application :
asadmin deploy APP_PATH/target/myapp.war
But I get the following error:
remote failure: Error occurred during deployment: Exception while deploying the app [myapp] : org.xml.sax.SAXParseException; lineNumber: 137; columnNumber: 15;
Deployment descriptor file WEB-INF/web.xml in archive [myapp]. cvc-complex-type.2.4.a: 從元素 'init-param' found invalid content。expect '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref, "http://java.sun.com/xml/ns/javaee":multipart-config}'。. Please see server.log for more details.
I use Grails 2.3.0 and get the same error on both Glassfish 3.1.2.2 and Glassfish 4.
How can I fix this error ?
Any help would be appreciate.
-- Update
I use grails command "grails install-templates" to generate web.xml, and move web.xml to web-app/WEB-INF, but still got the same error message. Following is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
metadata-complete="true"
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">
<display-name>/#grails.project.key#</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>#grails.project.key#</param-value>
</context-param>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class>
</filter>
<filter>
<filter-name>charEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>characterEncodingFilter</param-value>
</init-param>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<listener>
<listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class>
</listener>
<!-- Grails dispatcher servlet -->
<servlet>
<servlet-name>grails</servlet-name>
<servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
<init-param>
<param-name>dispatchOptionsRequest</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<!-- The Groovy Server Pages servlet -->
<servlet>
<servlet-name>gsp</servlet-name>
<servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>gsp</servlet-name>
<url-pattern>*.gsp</url-pattern>
</servlet-mapping>
<session-config>
<!-- 30 minutes -->
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<!--
The order of the welcome pages is important. JBoss deployment will
break if index.gsp is first in the list.
-->
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.gsp</welcome-file>
</welcome-file-list>
</web-app>

Related

application Migrating to weblogic 12.1.3.0 from 10.3.3.0 -unable to render JSF expressions

I am in the process of migrating Struts 2+Jsf 2.x web application from WEB -LOGIC 10.3.3.0 to 12.1.3.0.
I am encountering an error while accessing the pages ,as per my understanding if a JSF tag encounters with a value which is reading from the properties file it is encountering the Issue.And in the same pages I am able to read the struts messages.
I have created a POC with the same jars which my application is using to check the JSF is rendering properly or not.the POC is working fine.
and I placed the POC created page in to my application and tried to access again the same error encounterd.
when I comment the Struts filter in My application ,newly created pages worked fine.
I have tried to upgrade the Struts2jsf plugin.jar to newer versions .
I have removed the jsf-api,jsf -impl,JSTL from the APPINF\LIB.
changed the faces-config xsd to 2.0
but no luck..
Below is the error stack :
java.lang.stackOverflowError.
at java.util.HasMap$treeNode.GetTreeNode(HashMap.java:1873)
at java.util.HasMap.getNode(HashMap.java:573)
at java.util.HashMap.get(HashMap.java:556)
at ognl.ognlRuntime.getParameterTypes(ognlRuntime.java)
at ognl.ognlRuntime.findParameterTypes(ognlRuntime.java)
at ognl.OgnlRuntime.getGetMethod(ognlRuntime.java)
at ognl.ognlRuntime.hasGetMethod(ognlRuntime.java)
....
at org.apache.struts2.jsf.strutsVariableResolver.resolvervariable(StrutsVaraibaleResolver :78)
at com.sun.faces.el.variabelResolverImpl.resolvervariabel(VariableResolverImpl.java:80))
at org.apache.struts2.jsf.strutsVariableResolver.resolvervariable(StrutsVaraibaleResolver :78)
at com.sun.faces.el.variabelResolverImpl.resolvervariabel(VariableResolverImpl.java:80))
at org.apache.struts2.jsf.strutsVariableResolver.resolvervariable(StrutsVaraibaleResolver :78)
at com.sun.faces.el.variabelResolverImpl.resolvervariabel(VariableResolverImpl.java:80))
at org.apache.struts2.jsf.strutsVariableResolver.resolvervariable(StrutsVaraibaleResolver :78)
at com.sun.faces.el.variabelResolverImpl.resolvervariabel(VariableResolverImpl.java:80))
java.lang.ClassCastException:java.lang.StackOverflowerror cannot be cast to java.lang.Excetption
java.lang.ClassCastException:java.lang.StackOverflowerror cannot be cast to java.lang.Excetption
at jsp_servlet._error._jspService(_error.java)
at weblogic.servlet.jsp.Jspbase.service(JsPBase.java)
**
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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-Value>classpath:/applicationContext-resources.xml
classpath:/applicationContext-dao.xml
classpath:/applicationContext-service.xml
/WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-Struts.xml
/WEB-INF/Secuirty.xml
</param-Value>
</context-param>
<context-param>
<param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLE</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>faces</servlet-name/>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class/>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JSPSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
</servlet>
<filter>
<filter-name>struts-prepare</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphone.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter>
<display-name>richfaces</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh </filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD </dispatcher>
<dispatcher>INCLUDE </dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>struts </filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>richfaces</filter-name>
<url-pattern>*.html</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh </filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_1_2.xsd"
version="1.2"
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<resource-bundle>
<base-name>message</base-name>
<var>msg</var>
</resource-bundle>
</application>
I have added additionally to the faces config below handler which worked me to display the login page
<view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
while navigating to any page above error encountering.
Below are the list of jars presented :
activation-1.1.jar
antlr-2.7.6.jar
aopaliance-1.0.jar
asm3.3.jar
aspectjrt-1.6.6.jar
aspectjweaver-1.6.6.jar
axiom-api-1.2.5.jar
cglib-2.2.jar
commons-beanutils-1.7.0.jar
commons-Codec-1.5.jar
Commons-collections-3.2.jar
commons-digester-1.8.jar
commons-el.jar
commons-fileupload-1.2.1.jar
commons-io-1.4.jar
commons-lang-2.4.jar
commong-logging-1.1.1.jar
commons-pool-1.2.jar
commons-vfs-1.0.jar
compass-2.1.3.jar
jsf-facelets 1.1.15B1.jar
richfaces-impl 3.3.jar
richfaces-ui 3.3Final.jar
standard.jar
jstl.jar
jsf-api2.0.2.jar
jsf-impl 2.0.2.jar
log4j-1.2.13 jar
ognl2.7.3.jar
sitemesh-2.4.2.jar
richfaces-api-3.3.3.Final.jar
richfaces-imple-jsf2-3.3.3.Final.jar
richfaces-ui-3.3.3.Final.jar
slf4j-api.jar
slf4j-log4j12.jar
hibernate-core.jar
hibernate-search.jar
hibernate-commons-annotations.jar
hibernate-annotations.jar
standard1.1.2.jar
struts2-corre-2.1.8.jar
struts2-jsf-plugin-2.1.8.1
wsdl4j-1.6.2.jar
xml-apis-1.0.b2.jar
xml-resolver-1.2.jar
xmlbeans-2.4.0.jar
xmlSchema-core 2.0.jar
xwork-core2.1.6.jar
etc...
eg code causing the errors :
hello.jsp
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<head>
<title>JSF Example</title>
<head>
<body>
<h2>JSF Example - </h2>
<h:form>
<h:inputText value="#{msg.testmessage}"></h:inputText>
</h:form>
<body>
</html>
I am struggling a lot what went wrong.and the application is running fine in wls 10.3.3.0.
appreciated your help.
Regards,
Ganesh Karanam

Why am I getting WebXml is not initialized yet?

I´ve a Maven Web Application with JSF2, Primefaces, Spring, and Hibernate.
So I recently migrated my web application from Glassfish 3 to Weblogic 12c.
When it run on Glassfish it worked fine but after migrating my application after some problems with the aspect libraries I managed to deploy it. But after running my application I found a bug. When my xhtml runs and loads data from my managed bean constructor it gets the data and renders it as expected, but if I fire an ajax event it gets the expected data but it doesn´t render the data and I get the next exception:
<11/01/2014 07:56:27 PM CST> <Error> <javax.enterprise.resource.webcontainer.jsf.application> <BEA-000000> <Error Rendering View[/pages/dashboard.xhtml]
java.lang.IllegalStateException: WebXml is not initialized yet. Please use #init(ServletContext) method to manually initialize it.
at org.omnifaces.config.WebXml.checkInitialized(WebXml.java:313)
at org.omnifaces.config.WebXml.getFormLoginPage(WebXml.java:294)
at org.omnifaces.context.OmniPartialViewContext$OmniPartialResponseWriter.startDocument(OmniPartialViewContext.java:253)
at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:134)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:287)
Truncated. see log file for complete stacktrace
>
<11/01/2014 07:56:27 PM CST> <Error> <HTTP> <BEA-101020> <[ServletContext#11936366[app:geotrack1-1.0-SNAPSHOT module:geotrack1-1.0-SNAPSHOT.war path:null spec-version:3.0]] Servlet failed with an Exception
java.lang.IllegalStateException: WebXml is not initialized yet. Please use #init(ServletContext) method to manually initialize it.
at org.omnifaces.config.WebXml.checkInitialized(WebXml.java:313)
at org.omnifaces.config.WebXml.getFormLoginPage(WebXml.java:294)
at org.omnifaces.context.OmniPartialViewContext$OmniPartialResponseWriter.startDocument(OmniPartialViewContext.java:253)
at org.primefaces.context.PrimePartialResponseWriter.startDocument(PrimePartialResponseWriter.java:134)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:201)
Truncated. see log file for complete stacktrace
>
<11/01/2014 07:56:27 PM CST> <Notice> <Diagnostics> <BEA-320068> <Watch "UncheckedException" in module "Module-FMWDFW" with severity "Notice" on server "AdminServer" has triggered at 11/01/2014 07:56:27 PM CST. Notification details:
WatchRuleType: Log
WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'WL-101020') OR (MSGID = 'WL-101017') OR (MSGID = 'WL-000802') OR (MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802'))
WatchData: DATE = 11/01/2014 07:56:27 PM CST SERVER = AdminServer MESSAGE = [ServletContext#11936366[app:geotrack1-1.0-SNAPSHOT module:geotrack1-1.0-SNAPSHOT.war path:null spec-version:3.0]] Servlet failed with an Exception
Does anyone knows what´s happening??
Here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="3.0">
<!-- Spring Context Configuration' s Path definition -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<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>Faces Servlet</servlet-name>
</filter-mapping>
<!-- The Bootstrap listener to start up and shut down Spring's root WebApplicationContext. It is registered to Servlet Container -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- JSF Servlet is defined to container -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Mapping with servlet and url for the http requests. -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- Configuracion de Quartz -->
<listener>
<listener-class>org.quartz.ee.servlet.QuartzInitializerListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>
15
</session-timeout>
</session-config>
</web-app>
In my weblogic.xml I´ve:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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 http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
<jsp-descriptor>
<keepgenerated>true</keepgenerated>
<debug>true</debug>
</jsp-descriptor>
<context-root>/geotrack1</context-root>
</weblogic-web-app>
I hope someone knows what´s happening.
Thanks in advace.
It's already reported as issue 273 at 29 october 2013 and fixed for 1.7, which has just been released:
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.7</version>
</dependency>
To fix it I change in my pom from omnifaces 1.6.3 to ominifaces 1.5

adding spring security on netbeans

I created my project on netbeans and checked spring mvc framework and hibernate.
This created a web.xml file:
<?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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
However, whenever I add
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I'm able to deploy it on tomcat but not able to run it :(
I get this error:
FAIL - Deployed application at context path /project but context failed to start
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
Anyone has suggestions to fix it?

Jruby rails application on Tomcat. War generated through warbler

I am using warbler to create war of my Jruby application. It creates a war without any problem, but when I deploy it in tomcat (webapps) it gives me following exception:
SEVERE: Parse error in application web.xml file at jndi:/localhost/POC_Rails_1_3_1_/WEB-INF/web.xml
org.xml.sax.SAXParseException: Comment must start with "<!--".
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
Generated (WEB-INF/web.xml) is below. Let me know if I have forgotten to configure something.
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>public.root</param-name>
<param-value>/</param-value>
</context-param>
<context-param>
<param-name>rails.env</param-name>
<param-value>developement</param-value>
</context-param>
<filter>
<filter-name>RackFilter</filter-name>
<filter-class>org.jruby.rack.RackFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RackFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
</listener>
</web-app>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>public.root</param-name>
<param-value>/</param-value>
</context-param>
<context-param>
<param-name>rails.env</param-name>
<param-value>developement</param-value>
</context-param>
<filter>
<filter-name>RackFilter</filter-name>
<filter-class>org.jruby.rack.RackFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RackFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
</listener>
</web-app>
As the first commentor mentioned the xml is invalid because of duplicate <web-app> and <!DOCTYPE. The parser error is related to <!. <! is meant for declaring documenttype and it can appear only before the start of the root element. Any subsequent appearances will be treated as start of a comment. And the comment needs -- after <!

Velocity + Struts2 + Sitemesh + Spring +Hibernate Integration How to configur web.xml?

I needed to create an application using Struts2 as MVC,Hibernate for data access and spring in the business logic.
And also I needed to use Velocity for presentaion and sitemesh for templating.
Integrating Hibernate and Spring is done easily but integrating spring, sitemesh and velocity together with Struts2
is not clear for me but I can use velocity,spring and sitemsh individually with Struts2.
Of course as illustrated in this example http://www.rkcole.com/articles/struts/crudTutorial/step4.html
sitemesh and spring can be integrated with struts2 configuring web.xml as
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Now my task is to integrate velocity with this combination...............
Normally to integrate Velocity and struts2 I use the following
<servlet-class>
org.apache.velocity.tools.view.servlet.VelocityViewServlet
</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
.............................................................................................
Now my question is how to set `
<servlet-mapping>
`, its only for velocity, or simemesh or has to be set differently
Please let me know how to proceed,if can please reply with complete web.xml and others steps to be followed.
Regards
T.Thamilvaanan
Ya, finally I got this web.xml after lots of reading and searching............
<?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">
<!-- A part in Spring Integration-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
</context-param>
<!-- All the filters starts here-->
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.StrutsPrepareFilter</filter-class>
</filter>
<!-- This is used to integrate sitemesh with Struts2-->
<!--
I am using Velocity to create sitemesh decorators so I have to use
VelocityPageFilter to integrate
Sitemesh (i.e. Sitemesh in velocity) + Struts2
In the web.xml, the VelocityPageFilter should be placed between the
ActionContextCleanUp (StrutsPrepareFilter since 2.1.3 ) and
and the FilterDispatcher (StrutsExecuteFilter since 2.1.3)
-->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>org.apache.struts2.sitemesh.VelocityPageFilter</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring Integration-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--Finally since I am velocity pages in struts2 MVC I am using
VelocityViewServlet to Integrate struts2 with Velocity -->
<servlet>
<servlet-name>velocity</servlet-name>
<servlet-class>org.apache.velocity.tools.view.VelocityViewServlet
</servlet-class>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/tools.xml</param-value>
</init-param>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
</servlet>
<!-- Map *.vm files to Velocity -->
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.vm</welcome-file>
</welcome-file-list>
</web-app>
Hope this is fine,will test and let you know.
Cheers............
Regards
Thamilvaanan

Resources