dimanche 1 mars 2015

How do configure struts convention plugin with struts-spring plugin with Action class mapped with annotations

I am trying to configure spring plugin with strut 2 application, which is already running with convention plugin, so am using annotations. Am using ExtJs for my form submission which was initially working well until i introduced the spring plugin, now the the ajax request cannot locate the actions and its even not showing any response in firebug. I have tried searching the net, but i cant find solution of how to successfully configure strut2 convention plugin using annotation with struts-spring plugin. Currently this is what i have


pom.xml



<!-- struts 2 dependencies -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>

<!-- Import the CDI API -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-cdi-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0-SP1</version><!--$NO-MVN-MAN-VER$-->
<scope>provided</scope>
</dependency>

<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>


struts.xml



<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://ift.tt/1iwXH3l">

<struts>
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<constant name="struts.devMode" value="true" />
<constant name="struts.convention.result.path" value="/content" />
<constant name="struts.multipart.saveDir" value="/tmp" />
<constant name="struts.multipart.maxSize" value="4194304" />
<constant name="struts.action.excludePattern" value="/api/.*?" />

</struts>


web.xml



<display-name>Application</display-name>
<welcome-file-list>
<welcome-file>index.html</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>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/api</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>


applicationContext.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU" xmlns:aop="http://ift.tt/OpNdV1"
xmlns:tx="http://ift.tt/OGfeU2"
xsi:schemaLocation="
http://ift.tt/GArMu6 http://ift.tt/GAf8ZW">
</beans>


Action Class



@Namespace("/units")
@Result(
type = "stream",
params = {
"inputName", "stream"
}
)
public class PropertyTypeAction extends BaseAction implements ActionImpl{

@PersistenceUnit
private EntityManagerFactory emf;

@Action(value="add")
public String add() {
.......

}
}


Ajax Request firebug report, XML tab



XML Parsing Error: no element found Location: moz-nullprincipal:{7fc640bd-f293-4956-8cf2-178765cec735} Line Number 1, Column 1:


My request is how can i configure struts-spring plugin to work with struts convention plugin with the annotations.


Aucun commentaire:

Enregistrer un commentaire