Reputation: 475
I have an existing web application that uses just servlets and JSP.
Now I'm building my web apps with Tapestry 5, but I was wondering if there was a way to integrate Tapestry for just a few URL's in my application.
Is it possible to do this? I can't find it in the Tapestry docs.
Partly solved
Ok that's what I did so far. I added the JARS from the Tapestry 5 website to the /WEB-INF/lib folder and also the JARS of the Hibernate validator and Hibernate ORM since Tomcat was throwing ClassNotFoundErrors.
I modified my web.xml file and added this:
That's the solution I think to my problem. However I got one problem: my existing web app is not using Maven for dependency management. So I have included all the JARS from the Tapestry5 download to the lib folder inside the WEB-INF folder. Modified my web.xml file with this information:
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>be.blauweregen.ledenplatform</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/tapestry5/*</url-pattern>
</filter-mapping>
As I understand it, only the URL's with rootpath /tapestry5 will be handler by Tapestry.
I then added a package be.blauweregen.ledenplatform.services
to my src folder inside Eclipse and added a classfile AppModule.java
to that package with the following content:
package be.blauweregen.ledenplatform.services;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.services.ApplicationDefaults;
import org.apache.tapestry5.ioc.services.SymbolProvider;
public class AppModule {
@Contribute(SymbolProvider.class)
@ApplicationDefaults
public static void applicationDefaults(MappedConfiguration<String, String> configuration) {
configuration.add(SymbolConstants.APPLICATION_FOLDER, "tapestry5");
}
}
Now when I start my application inside Eclipse on my local Tomcat 7.0.42 server I get this exception when Tomcat is starting up:
SEVERE: Exception starting filter app
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.privateGetPublicMethods(Class.java:2641)
at java.lang.Class.getMethods(Class.java:1457)
at com.zeroturnaround.javarebel.Ce.b(JRebel:461)
at com.zeroturnaround.javarebel.Ce.a(JRebel:183)
at com.zeroturnaround.javarebel.Ce.getMethods(JRebel:611)
at java.lang.Class.getMethods(Class.java)
at org.apache.tapestry5.ioc.internal.DefaultModuleDefImpl.<init>(DefaultModuleDefImpl.java:115)
at org.apache.tapestry5.ioc.RegistryBuilder.add(RegistryBuilder.java:131)
at org.apache.tapestry5.ioc.RegistryBuilder.add(RegistryBuilder.java:159)
at org.apache.tapestry5.ioc.IOCUtilities.addModulesInList(IOCUtilities.java:137)
at org.apache.tapestry5.ioc.IOCUtilities.addModulesInManifest(IOCUtilities.java:107)
at org.apache.tapestry5.ioc.IOCUtilities.addDefaultModules(IOCUtilities.java:77)
at org.apache.tapestry5.internal.TapestryAppInitializer.<init>(TapestryAppInitializer.java:124)
at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:103)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
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$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 29 more
Don't find a way to fix this.
Upvotes: 0
Views: 943
Reputation: 27994
It sounds like you are manually adding jars to your classpath rather than using a dependency management tool (such as gradle, maven or ivy).
It's quite difficult to work in this way because you must manually determine the transitive dependencies and add them too. It's quite easy to miss some.
I'm guessing that you've added the tapestry-spring jar(s) but forgotton to add the spring jar(s) which is causing your NoClassDefFoundError.
I suggest you use a proper dependency management tool to build your webapp.
Upvotes: 0
Reputation: 3893
Tapestry can easily run within the same application as your current JSP's and servlets. All you need to do is map the TapestryFilter
to only those url's that require it in your web.xml and/or tell tapestry to ignore certain paths.
Since Tapestry uses the servlet specs and thus the HttpSession you can easily obtain the Session and share information between Tapestry and Your JSP application. Could you be more specific what you mean by "Integrate" though? Otherwise this is as detailed of an answer you'll get ;-)
Upvotes: 2
Reputation: 27994
One option is to leave tapestry processing the root context (/
) and then tell it which paths to ignore.
Another option is to configure tapestry to run inside a subfolder
Upvotes: 2