This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Struts Spring Integration problem

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have copied web.xml file and in that file I have also attached code that is copied from from struts-config.xml and applicationcontext.xml and Action Class.

But I still get that error message HTTP 404 Servlet Action is not available
Could any one can help


<?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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>login.jsp</welcome-file>
</welcome-file-list>
</web-app>








/*************************(Spring Struts Configuration)ApplicationContext.xml**************************************

- <bean name="/login" class="sunny.pages.LoginAction" lazy-init="default" autowire="default" dependency-check="default">
- <property name="sunnyService">
<ref bean="sunnyService" />
</property>
</bean>
<!-- <bean name="/login" scope="prototype" autowire="auto"
class="sunny.pages.LoginAction"/>

-->
/**************************************Struts-config.xml*************************//////////////////
<action-mappings>
- <!-- <action name="LoginForm" path="/login" scope="request" type="sunny.pages.LoginAction" validate="false">
<forward name="success" path="/WEB-INF/success.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
-->
- <action path="/login" type="org.springframework.web.struts.DelegatingActionProxy" name="LoginForm" scope="request" validate="false" parameter="method">
<forward name="success" path="/WEB-INF/success.jsp" />
<forward name="failure" path="/login.jsp" />
</action>
</action-mappings

/**************************Action Class***************************************/

public class LoginAction extends ActionSupport
{

/* forward name="success" path="" */
private final static String SUCCESS = "success";
private final static String FAILURE = "failure";
final Logger LOG = Logger.getLogger(SunnyServiceImpl.class);
/**
* This is the action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws java.lang.Exception
* @return
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
LoginForm formBean = (LoginForm)form;
String name = formBean.getName();
String email = formBean.getEmail();

// perform validation
if ((name == null) || // name parameter does not exist
email == null || // email parameter does not exist
name.equals("") || // name parameter is empty
email.indexOf("@") == -1)
{ // email lacks '@'

formBean.setError();
return mapping.findForward(FAILURE);

}
ApplicationContext ctxt=getWebApplicationContext();
SunnyService service=(SunnyService) ctxt.getBean("sunnyService");
ProductType obj=new ProductType("try1");
service.getProductTypeDAO().save(obj);
LOG.debug("Product Type Added: " +obj );
return mapping.findForward(SUCCESS);

}
}


Many thanks>
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well first the applicationContext.xml files should not have a URL mapping in it, just your service beans. I don't see the sunnyService configured in your applicationContext.xml

Mark
 
Goodbye moon men. Hello tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!