• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTTP Status 404 - Servlet action is not available

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am a new comer to struts and am building a sample struts application using netbeans and sun java application server.

I am getting HTTP Status 404 - Servlet action is not available error at run time.

The url at the browser is http://localhost:8080/LoginPage_Part2/login.do


Here are my web.xml and struts config.xml.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<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>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</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>
<session-config><session-timeout>
30
</session-timeout></session-config><welcome-file-list><welcome-file>
index.jsp
</welcome-file></welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>





<?xml version="1.0" encoding="ISO-8859-1" ?>

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


<struts-config>

<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource" key="empTable">
<set-property property="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
<set-property property="url" value="jdbc erby://localhost:1527/sample" />
<set-property property="username" value="app" />
<set-property property="password" value="app" />
<set-property property="validationQuery" value="SELECT * FROM CUSTOMER" />
</data-source>
</data-sources>

<form-beans>
<form-bean name="LoginActionForm" type="com.myapp.struts.LoginActionForm"/>

</form-beans>

<global-exceptions>

</global-exceptions>

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

<action-mappings>
<action input="/loginForm.jsp" name="LoginActionForm" path="/login" scope="request" attribute="validlogin" type="com.myapp.struts.DataSourceConnectionAction">
<forward name="success" path="/mydatasourceSuccessful.jsp" redirect="true"/>
<forward name="cancel" path="/loginCancel.html"/>
</action>
<action forward="/loginOut.jsp" path="/logout"/>

<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>

<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

<message-resources parameter="com/myapp/struts/ApplicationResource"/>

<!-- ========================= Tiles plugin ==== -->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>

<!-- ========================= Validator plugin ================================= -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

</struts-config>


Thanks in advance.
Amit
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to post Struts questions in the Struts forum. I have moved this one for you.
 
Amit Kasat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear for posting my problem from servlets forum to struts forum.

But what is the solution for the above problem? I am stuck like anything.

Amit
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd advise you to remove the <data-source> stanza from your struts-config.xml file. The Struts data-source utility does not work consistently, and I'd advise you not to use it.

The best practice is to define the DataSource as a JNDI resource in your Application Server, and then access it through a JNDI lookup in your application code. Look in the Sun Application Server documentation for information on how to set up a DataSource.
 
Amit Kasat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Merrill,

I am not gettiing how to define the DataSource as a JNDI resource from sun java Application Server 9.0, and then access it through a JNDI lookup from the application code. Also I am still confused as why data source type in struts config.xml should not work.

Amit
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amit,

This link should give you a basic understanding of how to set up and use a DataSource in the Sun Application Server.

Since the Application Server is responsible for maintaining DataSources, it only makes sense to use the specific application server's interface for setting them up. Struts tried to create a kind of generic datasource, but the reality is, there are significant differnece between applicaiton servers on how datasources are set up and maintained, and it isn't realistic for one generic interface to be able to cover them all. If you do a search on this forum, you will find that there are many unhappy tales of how someone couldn't get the Struts DataSource to work.

If you are determined to use the Struts datasource and have a high tolerance for pain, go ahead and try to make it work. If you just want to get your project done, do as I suggested and use the application server interface for creating your DataSource.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit,

If you are trying for a simple application, then you may remove the validation part as well from the struts-config.xml. Also as the other member told, you may remove the data source link also. Since you are a beginer you may go to the following links for better understanding. You can download the materials. Its always better to have a step by step approach.

http://courses.coreservlets.com

regards
Prasanth
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic