Déploiement CXF sur JOnAS 5
Bonjour,
j'ai suivi un tutoriel pour réaliser un service web CXF que j'ai pu déployer avec succès sur Tomcat 7. J'essaye de le déployer sur JOnAS 5.2.4 mais j'obtiens l'erreur suivante :
Code:
1 2 3 4 5 6
|
exception :
javax.servlet.ServletException: Servlet.init() for servlet WebServicePort threw exception
root cause :
java.lang.ClassCastException: org.springframework.web.context.support.XmlWebApplicationContext cannot be cast to java.lang.Exception |
Voici la structure de mon projet :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
+ wsp-tutorial
| + service
| | + src
| | | + main
| | | | + java
| | | | | + service
| | | | | | - DoubleItPortTypeImpl.java
| | | + assembly
| | | | - jaxws-jar.xml
| | - pom.xml
| + war
| | + src
| | | + main
| | | | +webapp
| | | | | + WEB-INF
| | | | | | - cxf-servlet.xml
| | | | | | - web.xml
| | - pom.xml
| - pom.xml |
Voici le contenu du pom parent (wsp-tutorial\pom.xml) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>re.bruno.tests</groupId>
<artifactId>web-service-jonas</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Test: Web Service on JOnAS</name>
<packaging>pom</packaging>
<modules>
<module>service</module>
<module>war</module>
</modules>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf.version>2.7.6</cxf.version>
</properties>
<dependencies>
<!--
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency> -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-anttasks</artifactId>
<version>2.1.10</version>
</dependency>
<dependency>
<groupId>org.ow2.bundles</groupId>
<artifactId>ow2-bundles-externals-cxf-2.2</artifactId>
<version>1.0.19</version>
</dependency>
<dependency>
<groupId>org.ow2.jonas</groupId>
<artifactId>jonas-webservices-cxf-2.2</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<!--downloadJavadocs>true</downloadJavadocs-->
<!--useProjectReferences>false</useProjectReferences-->
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project> |
Voici le pom fils contenu par le répertoire 'service' (wsp-tutorial\service\pom.xml) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>re.bruno.tests</groupId>
<artifactId>web-service-jonas</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web-service-jonas-service</artifactId>
<name>-- Web Service Provider</name>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!--
Below plugin provides a separate JAR for the JAX-WS artifacts (i.e.,
the objects created by running wsdl2java or wsimport), as this JAR
will also be used by the SOAP client. More info:
http://maven.apache.org/plugins/maven-assembly-plugin/
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>src/assembly/jaxws-jar.xml</descriptor>
</descriptors>
<appendAssemblyId>true</appendAssemblyId>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>service</Export-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<configuration>
<sourceRoot>
${basedir}/target/generated-sources
</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>
${basedir}/src/main/resources/DoubleIt.wsdl
</wsdl>
<wsdlLocation>classpath:DoubleIt.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- Name of the generated WAR file -->
<finalName>doubleit</finalName>
</build>
</project> |
Voici le pom fils contenu par le sous-dossier 'war' (wsp-tutorial\war\pom.xml) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>re.bruno.tests</groupId>
<artifactId>web-service-jonas</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web-service-jonas-war</artifactId>
<name>-- Service WAR file</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>re.bruno.tests</groupId>
<artifactId>web-service-jonas-service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<directory>../service/src/main/resources</directory>
<targetPath>WEB-INF/wsdl</targetPath>
<includes>
<include>*.wsdl</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<container>
<containerId>jonas5x</containerId>
<type>installed</type>
<home>C:\java\jonas\jonas-full-5.2.4\</home>
</container>
<configuration>
<type>existing</type>
<home>C:\java\jonas\jonas-full-5.2.4\</home>
<properties>
<cargo.servlet.port>9000</cargo.servlet.port>
<cargo.hostname>localhost</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.jonas.server.name>jonas</cargo.jonas.server.name>
<cargo.jonas.domain.name>jonas</cargo.jonas.domain.name>
</properties>
</configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>${project.packaging}</type>
<classifier>${config.classifier}</classifier>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
<!-- Name of the generated WAR file -->
<finalName>doubleit</finalName>
</build>
</project> |
Voici le contenu de service\src\assembly\jaxws-jar.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
<assembly>
<id>jaxws</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>DoubleIt.wsdl</include>
<include>org/**</include>
</includes>
</fileSet>
</fileSets>
</assembly> |
voici le contenu de war\src\main\webapp\WEB-INF\cxf-servlet.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<!-- Import statement optional but often required if you're declaring
other CXF beans in this file such as CXF's JMX MBeans -->
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<jaxws:endpoint
id="doubleit"
implementor="service.DoubleItPortTypeImpl"
wsdlLocation="WEB-INF/wsdl/DoubleIt.wsdl"
address="/doubleit">
</jaxws:endpoint>
</beans> |
Enfin voila le contenu de war\src\main\webapp\WEB-INF\web.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Sample web service provider</display-name>
<listener>
<!-- For Metro, use this listener-class instead:
com.sun.xml.ws.transport.http.servlet.WSServletContextListener -->
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- Remove below context-param element if using Metro -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/cxf/cxf.xml
</param-value>
</context-param>
<servlet>
<servlet-name>WebServicePort</servlet-name>
<!-- For Metro, use this servlet-class instead:
com.sun.xml.ws.transport.http.servlet.WSServlet -->
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WebServicePort</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app> |
merci d'avance pour votre aide :ccool: