File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Struts Spring Integration problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Struts Spring Integration problem" Watch "Struts Spring Integration problem" New topic
Author

Struts Spring Integration problem

waqas shahwar
Greenhorn

Joined: Sep 17, 2003
Posts: 19
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>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17256
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Spring Integration problem