Saladin
Saladin

Reputation: 27

HTTP Status 404 - The requested resource is not available

I'm running into a recurring problem while using the Tomcat server within the MyEclipse IDE, with the Struts 2 framework. I'm running my program as a server application and when it runs the default index.jsp file will open successfully but none of the other pasts of the application will work. When trying to load any of my my .do pages, I get the following error: HTTP Status 404: The requested resource .... is not available. When I ran into this error previously, I just restarted the server and all was fine, but I'm not having the same luck now.

Here's the log from the console when I hit run.

Apr 12, 2012 10:49:35 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;C:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin
Apr 12, 2012 10:49:35 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Apr 12, 2012 10:49:35 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 285 ms
Apr 12, 2012 10:49:35 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 12, 2012 10:49:35 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
Apr 12, 2012 10:49:35 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\username\My Documents\Workspaces\.metadata\.me_tcat\webapps\project-name\WEB-INF\lib\javax.servlet-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.
Apr 12, 2012 10:49:37 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Apr 12, 2012 10:49:37 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Apr 12, 2012 10:49:37 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
Apr 12, 2012 10:49:37 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1720 ms

Any suggestions?

Upvotes: 2

Views: 7115

Answers (1)

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

I don't see any reason to add javax.servlet-3.0.1.jar in your class-path.Since you are using Eclipse to build/run your application, so when you will add tomcat or any server as run time env to your project these lib dependencies will automatically be added to the class-path.Simple remove this jar from the lib folder of your project. There can be other reasons also for this.

  1. javax.servlet-3.0.1.jar has been added as runtime library (in the .WAR) – and that it was only needed during build time.
  2. Remove the jar from WEB-INF/lib, and update your build script to point to the new location.

the Servlet Spec 2.3, section 9.7.2 being referred to says that the Servlet Container (E.g. Tomcat) will supply the implementation class of the J2EE spec. The j2ee.jar (servlet-api.jar in our case?) in your WEB-INF/lib directory is trying to supply the same info. Having application specific implementations is a stability and security problem that is disallowed by the spec 2.3 and by Tomcat.

In short remove the javax.servlet-3.0.1.jar from your lib folder and let the container take care of supplying these dependencies for you.

To declare a dependency which is provided by the container with maven set the scope to "provided" here is an example of how an entry in your pom.xml should look:

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

Upvotes: 2

Related Questions