Hi,
I'm developing an application using Struts + hibernate + Spring + Tomcat...
when i do unit tests, it's ok, but when i do it in a Web "part", an exception occur: "Servlet action is not available."
I'm trying to login in a system, the exception occur when i submit the page.
My Web.xml:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-hibernate.xml</param-value>
</context-param>
<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>1</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>
<taglib>
<taglib-uri>/WEB-INF/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
<taglib-location>/WEB-INF/fmt-1_0-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c-1_0-rt.tld</taglib-location>
</taglib>
</web-app>
My Login form:
Code:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/c-1_0-rt.tld" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Intranet</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" src="securepass.js"></script>
<link href="styles/login.css" rel="stylesheet" type="text/css">
</head>
<link rel="STYLESHEET" type="text/css" href="styles.css"><!--- bgcolor="#182031"--->
<body leftmargin="0" topmargin="0" marginwidth="0" scroll="no" marginheight="0" background="img/backloginscreen.jpg" onload=document.entrada.txtUsuario.focus()>
<script language=JavaScript>
<!--
if (window.top != window.self) {
window.top.location = window.location;
}
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
if (top.screenX>0||top.screenY>0) {
top.moveTo(0,0);
} if (top.outerWidth<screen.availWidth) {
top.outerWidth=screen.availWidth;
} if (top.outerHeight<screen.availHeight) {
top.outerHeight=screen.availHeight;
}
} else {
top.moveTo(-4,-4);
top.resizeTo(screen.availWidth+8,screen.availHeight+8);
}
}
//-->
</script>
<SCRIPT language=JavaScript>
<!--
function disableRightClick(e)
{
var message = 'Right click disabled';
if(!document.rightClickDisabled) // initialize
{
if(document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = disableRightClick;
}
else document.oncontextmenu = disableRightClick;
return document.rightClickDisabled = true;
}
if(document.layers || (document.getElementById && !document.all))
{
if (e.which==2||e.which==3)
{
//alert(message);
return false;
}
}
else
{
//alert(message);
return false;
}
}
</SCRIPT>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><table width="558" height="346" border="0" cellpadding="0" cellspacing="0" background="img/loginscreen.jpg">
<tr>
<td><img src="img/t.gif" width="1" height="219"></td>
<td><img src="img/t.gif" width="1" height="219"></td>
</tr>
<tr>
<td><img src="img/t.gif" width="306" height="1"></td>
<td>
<html:form action="/usuario/action?act=login" method="post" target="_self" onsubmit="return validateLoginForm(this);">
<TABLE cellSpacing=2 cellPadding=2 border=0>
<TBODY>
<TR align=middle>
<TD class=FontStyle_1-Red colSpan=4><?=$_GET["msg"];?></TD>
<TR>
<TD noWrap rowSpan=3> </TD>
<TD noWrap>
<DIV align=right><SPAN class=FontStyle_1-Bold>Login:</SPAN></DIV></TD>
<TD noWrap class="form_login_input"><html:text maxlength="20" size="25" property="login" /></td>
<TD noWrap rowSpan=3> </TD></TR>
<TR>
<TD noWrap>
<DIV align=right><SPAN class=FontStyle_1-Bold>Senha:</SPAN></DIV></TD>
<TD noWrap class="form_login_input"><html:password size="25" property="senha" /></TD></TR>
<TR>
<TD><DIV align=center> </DIV></TD>
<TD><DIV align=center class="StyleBotton_1"><html:submit>ENTRAR</html:submit></DIV></TD>
</TR>
</TBODY>
</TABLE>
<html:hidden property="modulo" name="modulo" value="login"/>
<html:hidden name="acao" property="acao" value="valida_usuario"/>
</html:form>
</td>
</tr>
<tr>
<td valign="bottom"><img src="img/t.gif" width="306" height="22"></td>
<td align="left" valign="top"><img src="img/t.gif" width="252" height="22"></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<html:javascript formName="loginForm"/>
My spring-hibernate.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean name="dataSource"
class="oracle.jdbc.pool.OracleDataSource"
destroy-method="close">
<property name="user">
<value>xxx</value>
</property>
<property name="password">
<value>xxx</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>/WEB-INF/hibernate.cfg.xml</value>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean name="/usuario/action" singleton="false" autowire="byName" class="br.gov.pa.tj.usuario.actions.Action">
</bean>
<bean id="baseDAO" class="br.gov.pa.tj.util.BaseDAOImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="usuarioDAO" class="br.gov.pa.tj.usuario.dao.UsuarioDAOImpl" parent="baseDAO">
</bean>
<bean id="usuarioFacadeImpl" class="br.gov.pa.tj.usuario.facade.UsuarioFacadeImpl">
<property name="usuarioDAO">
<ref bean="usuarioDAO"/>
</property>
</bean>
<bean id="usuarioFacade"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<property name="target" ref="usuarioFacadeImpl"/>
<property name="transactionAttributes">
<props>
<prop key="inserir*">PROPAGATION_REQUIRED</prop>
<prop key="alterar*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>
</props>
</property>
</bean>
</beans>
Struts-config.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<form-beans>
<form-bean name="loginForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="login" type="java.lang.String"/>
<form-property name="senha" type="java.lang.String"/>
</form-bean>
</form-beans>
<global-exceptions/>
<global-forwards>
</global-forwards>
<action-mappings>
<action path="/Welcome" forward="/index.jsp"/>
<action path="/usuario/action" type="org.springframework.web.struts.DelegatingActionProxy" parameter="act" name="loginForm" scope="request" validate="false">
<forward name="login-ok" path="/index.jsp" redirect="false"/>
</action>
</action-mappings>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="MessageResources"/>
<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>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
<plug-in className="org.springframework.web.struts.ContextloaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/spring-hibernate.xml"/>
</plug-in>
</struts-config>
Someone knows where is my error?? :(