Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325794 - Servers Tomcat integration can't deploy dynamic web project to Tomcat
Summary: Servers Tomcat integration can't deploy dynamic web project to Tomcat
Status: RESOLVED WORKSFORME
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: jst.server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Larry Isaacs CLA
QA Contact: Angel Vera CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-20 16:12 EDT by Dean Schulze CLA
Modified: 2010-09-22 09:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Schulze CLA 2010-09-20 16:12:16 EDT
Build Identifier: 20100617-1415

While adding my project with the Add and Remove dialog if I expand the Project tree by clicking on the + it only shows one of the .jar files I have in WEB-INF/lib.  Nothing else in the project is shown.  None of the other .jar files in WEB-INF/lib, no JSPs, no .class files, no deployment descriptors.

When I add the project and click Finish tt throws this Exception (probably caused by all the missing resources):

Sep 20, 2010 1:55:15 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/bin/Java/jdk1.6.0_21/bin/../jre/bin/client;C:/bin/Java/jdk1.6.0_21/bin/../jre/bin;C:/bin/Java/jdk1.6.0_21/bin/../jre/lib/i386;C:\bin\Java\jdk1.6.0_21\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Attachmate\E!PC;c:\PROGRA~1\DISKEE~1\DISKEE~1\;c:\Program Files\Verint\SDK\Bin\;C:\Program Files\Java\jre1.6\bin;c:\Program Files\Rational\\Common;c:\Program Files\Rational\Common;c:\Program Files\Rational\ClearCase\bin;c:\Program Files\Rational\ClearCase\etc\utils;C:\oracle\product\10.2.0\client_1\BIN;C:\dean\bin\Groovy\Groovy-1.7.4\bin;C:\bin\BitviseTunnelier
Sep 20, 2010 1:55:15 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Struts2HW' did not find a matching property.
Sep 20, 2010 1:55:15 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Sep 20, 2010 1:55:15 PM org.apache.coyote.ajp.AjpProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
Sep 20, 2010 1:55:15 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1319 ms
Sep 20, 2010 1:55:16 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 20, 2010 1:55:16 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.2
Sep 20, 2010 1:55:16 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
WARNING: Could not create JarEntryRevision for [jar:file:/C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib/struts2-core-2.2.1.jar]!
java.lang.NoClassDefFoundError: org/apache/commons/io/output/NullOutputStream
	at com.opensymphony.xwork2.util.FileManager$JarEntryRevision.build(FileManager.java:307)
	at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:145)
	at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:105)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:898)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:154)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:121)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:179)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
	at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:269)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:250)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:368)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4193)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4801)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
	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:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.output.NullOutputStream
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
	... 35 more
Sep 20, 2010 1:55:16 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-default.xml]
Sep 20, 2010 1:55:16 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48:178
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
	at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:269)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:250)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:368)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4193)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4801)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
	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:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48:178
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:232)
	at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
	... 27 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getDeclaredConstructors(Unknown Source)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
	... 30 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
	... 34 more
Sep 20, 2010 1:55:16 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48:178
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
	at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:269)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:250)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:368)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4193)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4801)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
	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:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: Unable to load configuration. - bean - jar:file:/C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48:178
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
	at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
	... 25 more
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48:178
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:232)
	at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
	at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
	... 27 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getDeclaredConstructors(Unknown Source)
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
	... 30 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
	... 34 more
Sep 20, 2010 1:55:16 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Sep 20, 2010 1:55:16 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Struts2HW] startup failed due to previous errors


Reproducible: Always

Steps to Reproduce:
1.  Create a dynamic web project.
2.  Add a Tomcat server (I've tried with Tomcat 6 and 7). 
3.  Open Add and Remove dialog and add the project and click finish.
Comment 1 Larry Isaacs CLA 2010-09-21 10:34:40 EDT
It's not at all obvious, but the only jars that will appear as "children" of the Web application in the Servers view and the "Add and Remove" dialog are jars that have a "Main-Class" entry in their MANIFEST.MF file.  The Java EE handling considers these Java EE Application jars and treats them as "modules" instead of as just a jar.  "Normal" jars won't appear as children.  Not seeing the other jars isn't causing the problem you are encountering.  Most likely, your project isn't quite configured properly to publish everything it needs.

If you open the Problems view, do you see any warnings similar to the following:

Classpath entry <some jar>  will not be exported or published. Runtime ClassNotFoundExceptions may result.

If so, right-click on the warning and select Quick Fix.  That may clear up the problem.

To see what jars are actually being included in WEB-INF/lib, examine the "C:/dean/eclipse.workspaces/helios.jee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2HW/WEB-INF/lib" folder.

In case it helps, details about the WTP Tomcat support can be found at http://wiki.eclipse.org/WTP_Tomcat_FAQ.
Comment 2 Dean Schulze CLA 2010-09-21 12:09:57 EDT
Looking in the deployment directory that you mentioned I saw that my Java .class files weren't being deployed.  My output directory was set to the project bin/ directory.  I set it to WebContent/WEB-INF/classes and the .class files and other resources like struts.xml got deployed correctly.

Apparently the Tomcat integration only deploys what is in WebContent/.  Is that correct, or should it also deploy the Eclipse output directory (i.e. bin/)?  

If the Eclipse project output directory has to be set to WebContent/WEB-INF/classes directory in order for Tomcat integration to work that's got to be shown when you add a Tomcat server or maybe in the Add or Remove dialog.

In order to solve the rest of the problems I added additional commons-*.jar files to WEB-INF/lib.  This project was developed on Netbeans/glassfish and Glassfish doesn't need those other commons-*.jar files.  Maybe that's a difference in the default configurations of Tomcat and Glassfish.

To close this out, the issue of Eclipse not deploying the output directory to WEB-INF/classes is still a problem.  Is that a bug in the software or just something that needs to be shown when a project is added to a Tomcat deployment?
Comment 3 Larry Isaacs CLA 2010-09-21 12:59:32 EDT
>> Apparently the Tomcat integration only deploys what is in WebContent/.  Is that
correct, or should it also deploy the Eclipse output directory (i.e. bin/)?  

No, normally Dynamic Web Projects include a mapping that publishes the output artifacts of your Java source folders to the "WEB-INF/classes" of the published webapp.  This means that on the Project properties Deployment Assembly page for your project you would normally see an entry(s) with a Deploy Path of "/WEB-INF/classes" and the Source as "/<path of a java source folder>".  The handling is smart enough to find the build output of the specified source folder and publish that to "WEB-INF/classes".  I don't know why your project was missing an entry like this.

I would recommend putting the output folder back to "bin" or some appropriate folder (WTP uses "build/classes" as its default).  I believe removing and re-adding the source folder should restore the entry, which appears in the ".settings/org.eclipse.wst.common.component" file in your project.  If not, you can add it manually, i.e. duplicate one of the other <wb-resource> elements and set the "deploy-path" and "source-path" attributes.  Setting the output folder to "WebContent/WEB-INF/classes" has been known in the past to cause other problems, though I don't recall exactly what at the moment.

>> In order to solve the rest of the problems I added additional commons-*.jar
files to WEB-INF/lib.

You can also add a reference to an external jar in the Java Build Path of the project and use the Quick Fix on the warning that will appear in the Problems view to mark it for inclusion in the WEB-INF/lib of the published webapp.  You can also add jar references on the Deployment Assembly page.

>> To close this out, the issue of Eclipse not deploying the output directory to
WEB-INF/classes is still a problem.  Is that a bug in the software or just
something that needs to be shown when a project is added to a Tomcat
deployment?

I believe if you were to create a new Dynamic Web Project, you would encounter none of these problems.  It seems this project was in an "odd" state from the beginning that required these extra steps.  I don't know why the build output wasn't configured correctly.  For jars, standard practice is to include in your project jars for all libraries your project depends on, with minimal exceptions.  This way, your webapp runs with the version you choose rather that what the server might happen to be using.  The exceptions are jars containing classes the server is required to provide, like the servlet api classes.
Comment 4 Dean Schulze CLA 2010-09-21 22:28:30 EDT
Good news and bad news

I created a new project (on a different computer with the same setup).  Accepting the defaults worked to get the WEB-INF/classes published under the .metadata/plugins directory you mentioned above.

The bad news is that Tomcat 7 won't display any pages when I start it from Eclipse.  If I start it using startup.bat it works, but doesn't think that my application is deployed.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=325917

Getting Tomcat integration with Eclipse to work is enough to make me want to write Ant scripts again.
Comment 5 Larry Isaacs CLA 2010-09-22 09:04:14 EDT
At this point, it appears that this issue was caused by problems with the project and not the WTP Tomcat support, so I'm resolving it as WORKSFORME.  We can re-open if the does turn out to be an issue with the WTP Tomcat support.

Dean,

While your expectations about the behavior of the WTP Tomcat support are understandable, there are reasons why the implementation may provide different behavior.  Two of the big choices were creating separate Tomcat server instances by default and avoiding "auto-deployment", which complicates managing projects added to the server.  These may account for why it is not working the way you expect.  See the Tomcat FAQ (http://wiki.eclipse.org/WTP_Tomcat_FAQ) for explanations and other info.

Larry