1

What exactly needs to be inside an eclipse dynamic web project in order for eclipse's run-as...run-on-server command to work?

I have a fully tested application in an eclipse dynamic web project, and I have been running it using the tomcat 7 manager application, which allows you to point to an application's xml configuration file in order to publish the application during development before creating a war file. That application xml configuration file just points to the location of web.xml, as follows:

<Context path="/myapp" docBase="C:\mypath\myapp\web"></Context>

(I also have a war file, but that is outside the scope of this question.)

For various reasons, it would be desirable for me to be able to test this application using eclipse's run-as...run-on-server command, but doing so results in 404 errors every time I try any url in the site.

The following primary error from the stack trace is dismissed by other postings:

WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:myapp' did not find a matching property.

For kicks, here is the entire stack trace in the eclipse console:

Aug 29, 2013 12:28:54 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:\glassfish\jdk\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/eclipse_kepler/jre/bin/../jre/bin/server;C:/eclipse_kepler/jre/bin/../jre/bin;C:/eclipse_kepler/jre/bin/../jre/lib/amd64;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\MATLAB\R2010a Student\bin;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0_17\bin;C:\eclipse_kepler;;.  
Aug 29, 2013 12:28:54 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:myapp' did not find a matching property.
Aug 29, 2013 12:28:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Aug 29, 2013 12:28:55 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Aug 29, 2013 12:28:55 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 801 ms
Aug 29, 2013 12:28:55 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 29, 2013 12:28:55 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Aug 29, 2013 12:28:55 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 29, 2013 12:28:55 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 29, 2013 12:28:55 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 462 ms

There is no catalina.out file because it is trying to run tomcat through eclipse. Also, the code works when run through the tomcat 7 manager, so I am not sure that adding code here is relevant. I wonder if there is just some key asset missing, or some setting that needs to be configured.

PERHAPS ECLIPSE IS NOT FINDING WEB.XML? The web.xml file is located at the context path shown above. Eclipse might want it located in WebContent/WEB-INF/web.xml instead, but I think I changed that setting in preferences to match the context path above, and using the WebContent folder would mess up my build file, so I want to avoid that.

Community
  • 1
  • 1
CodeMed
  • 9,527
  • 70
  • 212
  • 364

1 Answers1

2

Under project properties, under "Deployment Assembly", ensure that the folder with your web.xml is in the list. I had a maven project which had the web.xml in the webapps folder, but the default web deployment configuration was publishing "/WebContent", and leaving out my "/src/main/webapp" folder, so Tomcat wasn't seeing it after doing the run on server.

If you don't see Deployment Assembly, go under project properties, project facets, ensure "Dynamic Web Module" is selected, then apply. Then go back into the project properties and you should see the new options for "Deployment Assembly".

Also, if you do have a maven managed project, you will need to add your maven dependencies to your list as well in the deployment assembly (add -> java build path entries -> maven dependencies).

David
  • 91
  • 3
  • Thank you very much for giving an answer to this. I know it has been a while since this question was asked, but there is not a lot of information about this on the web, and I think people will be coming to this page from google searches for a long time. +1 for trying to help. I will test this when I am back in an eclipse web project. – CodeMed Sep 20 '13 at 16:11