3

I'm trying to get a Struts tutorial working but I am coming up against the following error when I try to run the file in Tomcat.

The requested resource () is not available.

Tomcat Log Output:

Aug 29, 2012 9:55:37 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\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\GTK2-Runtime\bin;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;.
Aug 29, 2012 9:55:37 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsExample1' did not find a matching property.
Aug 29, 2012 9:55:37 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Aug 29, 2012 9:55:37 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1367 ms
Aug 29, 2012 9:55:37 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 29, 2012 9:55:37 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Aug 29, 2012 9:55:38 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Aug 29, 2012 9:55:39 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 29, 2012 9:55:39 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/56  config=null
Aug 29, 2012 9:55:39 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1468 ms

My web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>StrutsExample1</display-name>

  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
 </servlet>

  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

struts-config.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>

    <form-beans>
        <form-bean name="helloWorldForm" type="com.vaannila.form.HelloWorldForm"/>
    </form-beans>

    <global-forwards>
        <forward name="helloWorld" path="/helloWorld.do"/>
    </global-forwards>

    <action-mappings>
        <action path="/helloWorld" type="com.vaannila.action.HelloWorldAction" name="helloWorldForm">
            <forward name="success" path="/helloWorld.jsp" />
        </action>
    </action-mappings>

</struts-config>

I'm running Tomcat as a plug-in for Eclipse.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Colin747
  • 4,955
  • 18
  • 70
  • 118
  • Where did you get the message "The requested resource is not available?" When you are trying to access the application using browser? – AlexR Aug 29 '12 at 21:20
  • Have you turn logging up to DEBUG and check the logs on startup? It's almost certainly something in a config file, or triggered by a config file, like a missing class/jar, etc. – Dave Newton Aug 29 '12 at 21:20
  • @AlexR Yea I get it when trying to view the file in a browser. – Colin747 Aug 29 '12 at 21:20
  • ``You don't "view a file in the browser", you request a resource. Minor point.`` – Dave Newton Aug 29 '12 at 21:21
  • Make sure you look in all the log files found in `$TOMCAT_HOME/logs`, including catalina.out and localhost*.log. In almost all cases you will find some stack trace or clue in the logs when dealing with issues like this. – herrtim Aug 29 '12 at 21:29
  • generally, tomcat logs shows the message about deploying the application, for example `INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager`. I do not see same for your `StrutsExample1`. Please check if application is deployed successfully. – Swaraj Sep 14 '16 at 05:43

2 Answers2

1

The servlet mapping is *.do only mapped resources by extension. The message

The requested resource () is not available

shows that resource path is empty. The requested resource is web application root.

Even if you have welcome file index.jsp it might not be loaded by the Tomacat. It might also doesn't exist.

If you are using Struts framework you should not access JSP directly, and to access Struts action you should specify valid URL that is mapped to the action. I.e. http://localhost:8080/StrutsExample1/helloworld.do.

Roman C
  • 49,761
  • 33
  • 66
  • 176
0

Are you running the .java file on the server?If you do so,you will get this error.You only need to run the .jsp(or .html) file on the server,and even if your .jsp(or .html) file include some .java file's methods.The browser can only run .html(or .jsp) files.

慭慭流觞
  • 436
  • 5
  • 3