How to invoke a servlet from AJAX call url in struts2 application? - java

I am developing a simple Struts2 application having AJAX call. I am trying to check each field of a form, while it is being filled up, using AJAX call. I want to get the response from a servlet. To call the servlet, I have used 'exclude url' in struts.xml file and included the ajax call pattern in web.xml file. But my application is unable to find out the servlet. Below are the code snippets:
empForm.jsp:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="util.js" type="text/javascript"></script>
<script src="validate.js" type="text/javascript"></script>
<title>Employee Registration Form</title>
</head>
<body>
<h1 align="center">Employee Registration Form</h1>
<h2 align="left">Please provide your details in the appropriate fields. Fields marked with * are mandatory. </h2><br><br>
<s:form action="register">
<s:textfield id="username" name="username" label="Username*" />
<s:textfield name="fullname" label="Full Name*" />
<s:textfield name="emailid" label="Email*" />
validate.js:
window.onload = initPage;
alert("validate.js page");
function initPage() {
document.getElementById("username").onblur = checkUsername;
//document.getElementById("register").disabled = true;
alert("in initPage();");
}
function checkUsername() {
request=createRequest();
if(request==null)
alert("Unable to create request!");
else{
var theName = document.getElementById("username").value;
var username = escape(theName);
var url = "http://localhost:8080/PeopleManagement/checkName.do?username=" + username;
//var url = "checkName.do?username=" + username;
request.onreadystatechange = showUsernameStatus;
request.open("GET",url,true);
request.send(null);
alert("url:" + url);
}
alert("in checkUsername();");
}
function showUsernameStatus(){
if(request.readyState == 4){
if(request.status == 200){
alert("Status:" + request.statusText);
alert("Response:" + request.responseText);
if(request.statusText == "okay"){
alert("allowed");
}
else
alert("denied");
}
}
}
struts.xml:
<package name="admin" extends="struts-default">
<action name="Welcome">
<result>/welcome.jsp</result>
</action>
<action name="Admin" class="com.admin.AdminUser" method="execute">
<result name="input">/adminLogin.jsp</result>
<result name="SUCCESS">/adminMenu.jsp</result>
</action>
</package>
<package name="registration" extends="struts-default">
<action name="register" class="com.emp.Employee" method="execute">
<result name="input">empForm.jsp</result>
<result name="error">/registrationError.jsp</result>
<result name="SUCCESS">/registrationSuccess.jsp</result>
</action>
<action name="viewemp" class="com.emp.ViewEMP" method="execute">
<result name="error">/viewError.jsp</result>
<result name="SUCCESS">/list.jsp</result>
</action>
</package>
web.xml:
<?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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>PeopleManagement</display-name>
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>UserValidator</servlet-name>
<servlet-class>com.validation.ValidateUser</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UserValidator</servlet-name>
<url-pattern>/checkName.do*</url-pattern>
</servlet-mapping>
</web-app>
please help me out.

You need to map your Servlet correctly in web.xml
<servlet-mapping>
<servlet-name>UserValidator</servlet-name>
<url-pattern>/PeopleManagement/checkName.do</url-pattern>
</servlet-mapping>
.........
[EDIT]
You will also have to edit /* to / for the struts interceptor servlet. The difference is explained here - Difference between / and /* in servlet mapping url pattern

Related

Action Mapping in Struts2 [duplicate]

This question already has answers here:
There is no Action mapped for namespace [/] and action name [login] associated with context path [/Struts2Test]
(4 answers)
Closed 2 years ago.
Currently migrating an app from Struts1 to Struts2.
When I click my "submit" button, it gives me an error saying "There is no Action mapped for action name requestInput". What is wrong with my code that is the cause of this error?
web.xml
<web-app>
<display-name>My Project</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<struts>
<include file="struts-default.xml" />
<constant name="struts.custom.i18n.resources" value="global" />
<package name="default" namespace="/" extends="struts-default">
<interceptors>
<interceptor-stack name="uploadFile">
<interceptor-ref name="fileUpload" />
<interceptor-ref name="uploadForm" />
<interceptor-ref name="modelDriven" />
<interceptor-ref name="basicStack" />
</interceptor-stack>
</interceptors>
<action name="requestInput" class="com.class.action.FileAddAction" method="execute">
<result>/result.jsp</result>
</action>
</package>
</struts>
FileAdd.jsp
<s:form method="POST" action="requestInput" enctype="multipart/form-data">
...
<s:submit property="submit" style="background:#dccaa0" value="Submit" theme="simple"/>
...
</s:form>
FileAddAction.jsp
public final class FileAddAction extends ActionSupport implements SessionAware, ServletRequestAware {
...
public String execute() throws Exception{
...
}
}
And, my struts.xml is in the Java src folder and in the WEB-INF folder.
What else can I do to fix this? Thanks..
Two issues, otherwise looks good.
First issue:
action name="requestInput" class="com.class.action.FileAddAction"
method="execute"
You can't name your package with the identifier class, it is not a valid Java identifier
Second issue:
interceptor-ref name="uploadForm"
What is "uploadForm"? It's definitely not provided by Struts 2, see the list.
By naming the package differently, and removing interceptor-ref uploadForm, i am able to click the FileAdd.jsp Submit button without any issue and it is redirecting me successfully to result.jsp. I used v2.3.37.
Note:
struts.xml should be in the src/main/resources folder (struts.xml must be on the web application’s root class path). Check this out.
web.xml is to be under src/main/webapp/WEB-INF folder. Check this out.

Controller not match with url

i have a problem loading a page. I defined in the struts.xml (located in Java Resources/src/com.infopool.action) the next configuration:
<struts>
<package name="demo" namespace="/demo" extends="struts-default">
<action name="Inicio" class="com.infopool.action.Demo">
<result name="success">/View/demo/start.jsp</result>
</action>
<action name="Hola" class="com.infopool.action.Demo" method="hello">
<result name="success">/View/demo/hello.jsp</result>
</action>
<action name="Chau" class="com.infopool.action.Demo" method="goodbye">
<result name="success">/View/demo/goodbye.jsp</result>
</action>
</package>
</struts>
So, in the package com.infopool.action i have the next class defined:
package com.infopool.action;
public class Demo {
public String execute(){
return "success";
}
public String hello(){
return "success";
}
public String goodbye(){
return "success";
}
}
The views are located into WebContent/View/demo. When i try to browse the page, an 404 Tomcat error appear. The URL is:
http://localhost:8080/Infopool/demo/Inicio.action
My web.xml have the next configuration:
<filter>
<filter-name>Main</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.infopool.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Main</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
What is wrong with my configuration ?.
the use of this one is to pass an action package where all the action classes has been declared
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.infopool.action</param-value>
</init-param>
but your Demo action class doesnt have any annotation configuration like (if im not mistaken.)
#Namespace("/demo")
#Action("/Inicio")
#ResultPath(value="/")
#Result(name="success",location="/View/demo/start.jsp")
public class Demo {
....
You used the other way on configuring your action class which is your struts.xml
<struts>
<package name="demo" namespace="/demo" extends="struts-default">
<action name="Inicio" class="com.infopool.action.Demo">
<result name="success">/View/demo/start.jsp</result>
</action>
<action name="Hola" class="com.infopool.action.Demo" method="hello">
<result name="success">/View/demo/hello.jsp</result>
</action>
<action name="Chau" class="com.infopool.action.Demo" method="goodbye">
<result name="success">/View/demo/goodbye.jsp</result>
</action>
</package>
</struts>
so no need to declare/create this,
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.infopool.action</param-value>
</init-param>
inside of your struts filter.
#1 look at this : Providing an init-parameter in struts filter
#2 see this sample : struts2 annotation

java struts2 hibernate and spring application and soap web services

I have a web application using struts2, spring and hibernate frameworks. Now I want to expose some of its methods via soap web service. I have a class and I simply annotated it with #WebService annotation and an Service endpoint interface. Now when I deploy my application on glassfish it deploys fine but when I try to access wsdl via glasssfish admin console. It gives me the following error.
There is no Action mapped for namespace [/] and action name [UsersControllerImplService] associated with context path [/ossoc].
I understand its something related to configuration but I am unable to figure out what configuration.
web.xml
<?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_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>ossoc</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts2.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="spring" />
<package name="user" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="authentication" class="com.riteshsangwan.ossoc.core.interceptors.AuthenticationInterceptor"></interceptor>
<interceptor-stack name="authStack">
<interceptor-ref name="authentication"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="authStack"></default-interceptor-ref>
<global-results>
<result name="login" type="redirect">/index.action</result>
</global-results>
<action name="register" class="com.riteshsangwan.ossoc.core.actions.RegisterAction">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/index.jsp</result>
<result name="error">/register.jsp</result>
<result name="input">/register.jsp</result>
</action>
<action name="login" class="com.riteshsangwan.ossoc.core.actions.LoginAction">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/user/home.jsp</result>
<result name="error">/index.jsp</result>
<result name="input">/index.jsp</result>
</action>
<action name="activate" class="com.riteshsangwan.ossoc.core.actions.ActivateAction">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/user/home.jsp</result>
<result name="error">/index.jsp</result>
<result name="input">/index.jsp</result>
</action>
<action name="index">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result>/index.jsp</result>
</action>
<action name="home">
<result>/user/home.jsp</result>
</action>
<action name="showfiles" class="com.riteshsangwan.ossoc.core.actions.ShowFiles">
<result name="success">/user/files.jsp</result>
</action>
<action name="edit">
<result>/user/edit.jsp</result>
</action>
<action name="logout" class="com.riteshsangwan.ossoc.core.actions.LogoutAction">
<result name="success">/index.jsp</result>
</action>
<action name="changepassword" class="com.riteshsangwan.ossoc.core.actions.ChangePassword">
<result name="success">/user/edit.jsp</result>
</action>
<action name="upload" class="com.riteshsangwan.ossoc.core.actions.UploadFile">
<result>/user/home.jsp</result>
</action>
<action name="showgrid" class="com.riteshsangwan.ossoc.core.actions.ShowFiles">
<result name="success">/user/files.jsp</result>
</action>
<action name="deletefile" class="com.riteshsangwan.ossoc.core.actions.DeleteFile">
<result name="success">/user/files.jsp</result>
</action>
<action name="downloadfile" class="com.riteshsangwan.ossoc.core.actions.DownloadFile">
<result name="success" type="stream">
<param name="contentType"></param>
<param name="inputName"></param>
<param name="contentDisposition"></param>
<param name="bufferSize"></param>
<param name="allowCaching"></param>
<param name="contentLength"></param>
</result>
</action>
</package>
</struts>
applicationCOntext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- Database Configuration -->
<import resource="DataSource.xml"/>
<import resource="HibernateSessionFactory.xml"/>
<!-- Beans Declaration -->
<import resource="UsersBean.xml"/>
</beans>
Why everyone here is so eager to vote down.
This was the problem.
In web.xml the struts2 filter has /* url pattern mapped so struts2 will filter every request that comes to it including the request to the webservice servlet. Since filters execute before servlets so I was getting the action not mapped error.
From the struts2 documentation.
The action mapping extension has been changed to .action plus "" it means if I simply enter name of servlet in the address bar the struts2 will take it as action and check struts2.xml for relevant action mapping since there are no action mapping so it will throw error.
Solution
I just add the .extension after url in URL pattern mapping so struts2 will treat as a servlet request other option will to use
<constant name="struts.action.excludePattern" value="URLTOEXCLUDE"/>
and configure the webservice to use the excluded URL
Hope this helps others.

Error 404 issues using Struts application

I am having some issues running a Struts web app since few days. I tried several solutions from StackOverflow relating to my problem but none of them works.
web.xml:
<display-name>Struts2 Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
struts.xml:
<struts>
<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<action name="login"
class="net.viralpatel.struts2.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
</package>
</struts>
Login.jsp:
<%# page contentType="text/html; charset=UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Struts 2 - Login Application | ViralPatel.net</title>
</head>
<body>
<h2>Struts 2 - Login Application</h2>
<s:actionerror />
<s:form action="login.action" method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit method="execute" key="label.login" align="center" />
</s:form>
</body>
</html>
LoginAction.java:
package net.viralpatel.struts2;
public class LoginAction {
private String username;
private String password;
public String execute() {
if (this.username.equals("admin")
&& this.password.equals("admin123")) {
return "success";
} else {
return "error";
}
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
Libs I have added:
commons-logging-1.1.3.jar
freemarker-2.3.19.jar
ognl-3.0.6.jar
struts2-core-2.3.15.1.jar
xwork-core-2.3.15.1.jar
Error accessing URL:
http://localhost:8080/StrutsHelloWorld/
HTTP Status 404 - /StrutsHelloWorld/
type Status report
message /StrutsHelloWorld/
description The requested resource is not available.
Apache Tomcat/7.0.42
I tried this tutorial.
There are no errors on my console, problem view.
The error 404 means that resource you have requested is not available, the same referred to the action that is didn't map to the request URL.
FilterDispatcher is deprecated and may not work with the current Struts version, use StrutsPrepareAndExcecuteFilter instead.
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
in the struts.xml add the following
<package name="default" extends="struts-default" namespace="/">
<action name=""><result>/Login.jsp</result></acton>
this will forward you to the login page. Also consider to use absolute paths to the JSP resources.
In the JSP use the form that needs to rewrite to
<s:form namespace="/" action="login" method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit key="label.login" align="center" />
</s:form>
In the action attribute use the action name and provide namespace as you did in the package configuration.
Using method="execute" is useless in the s:submit tag, the method execute used by default, and it will not work because you have turned off DMI in the Struts configuration.
Adding libraries over the old libraries in the WEB-INF/lib doesn't help so much and your application probably would not work, until you remove and replace all lower version libraries with higher version and add new libraries needed by the current version of Struts framework.
for me it's I didn't add "lang3" to library, after adding it everything goes well

Struts 2 add an action to struts.xml

I want to add an action to my struts.xml but when I do it my webapp stop to work and I don't know why. I post here some details of my webapp.
web.xml :
<?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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>ILIMobileLeborgne</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
struts.xml (in the src folder in Eclipse):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="ilimobile" />
<package name="ilimobile" namespace="/" extends="struts-default">
<action name="index">
<result>/index.jsp</result>
</action>
<action name="registerIllimite">
<result>/registerIllimite.jsp</result>
</action>
<!-- When i try to do add the following action my app doesn't working, the browser said me that the ressource asked is unavailable and when i delete it my (little) app works correctly -->
<action name="registerClientInfo" class="action.SubscribeAction">
<result name="success">/paiement.jsp</result>
</action>
</package>
</struts>
my SubscribeAction (in the action package in the source folder) :
package action;
import model.*;
import com.opensymphony.xwork2.ActionSupport;
public class SubscribeAction extends ActionSupport {
private Client client;
private String abonnement;
public String getAbonnement() {
return abonnement;
}
public void setAbonnement(String abonnement) {
this.abonnement = abonnement;
}
#Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return SUCCESS;
}
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
}
And my JSP page which use the action defined :
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:form action="registerClientInfo">
<s:textfield key="client.nom"/>
<s:textfield key="client.prenom"/>
<s:textfield key="client.email"/>
<s:textfield key="client.adresse"/>
<s:textfield key="client.ville"/>
<s:textfield key="client.cp"/>
<s:submit/>
</s:form>
</body>
</html>
If you need some extra info ask me but i think you could see why my app doesn't want to work :/ I'm pretty sure that it's just a little error but i can't find it...
Thanks for all and have a happy new year party :)
(Sorry for my English I'm a french student ^^)
Edit : I post here the Eclipse stack trace which show me that he can't find my action class but i don't know why :/ I've a struts example made by my teacher and i don't think that he made some extra steps to deploy the app with a tomcat server on Eclipse
The stack trace :
Unable to load configuration. - action - file:/home/blackmario/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ILIMobileLeborgne/WEB-INF/classes/struts.xml:20:68
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: Action class [action.SubscribeAction] not found - action - file:/home/blackmario/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ILIMobileLeborgne/WEB-INF/classes/struts.xml:20:68
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:480)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:424)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:541)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:290)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:239)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 18 more
So, it sounds like your application fails to start when you add that action, correct? Nothing works, even the ones that worked before. So, you should look in the logs of the servlet container you are using. Nothing is more fundamental that finding where the logs are and becoming familiar with them.
When you do look in the logs, I'm guessing you'll see either
1) an error complaining that the syntax of the struts.xml is bad and the application fails when trying to parse it.
or
2) A ClassNotFoundException because the class file for that action is not on the classpath of the application. If this is the case make sure that the class files for that action are actually being put into the WAR file's WEB-INF/lib or WEB-INF/classes direcgtory; that's where a webapp's classloader looks for class files. If you don't know much about this, you should read more about Java Servlets.
Both of these are things that might cause the application to not successfully start. You must look at the logs; they will amost always tell you that the application had a specific issue. If you ask about that specific issue on this forum, you'll get very useful answers. Otherwise, I'm kind of guessing.
By default .action extension is used by the struts-default package that you extend. When you place the url in the browser make sure you have use correct url.
Try changing
<action name="registerClientInfo" class="action.SubscribeAction">
<result name="success">/paiement.jsp</result>
</action>
to
<action name="registerClientInfo" class="SubscribeAction">
<result name="success">/paiement.jsp</result>
</action>

Categories

Resources