IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JOnAS Java Discussion :

Déploiement CXF sur JOnAS 5


Sujet :

JOnAS Java

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2012
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2012
    Messages : 10
    Points : 9
    Points
    9
    Par défaut 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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  2. #2
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    Salut,
    l´erreur vient du fait que tu essaies de caster un Objet dans une sous-classe ou sous-type dont il n´est pas l´instance.
    Exemple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Object x = new Integer(0);
    System.out.println((String)x);
    Montres nous le code de la classe: DoubleItPortTypeImpl.java

    Eric

  3. #3
    Futur Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2012
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2012
    Messages : 10
    Points : 9
    Points
    9
    Par défaut
    Désolé de la réponse tardive, j'habites l'île de la Réunion et nous avons été privé d’électricité après le passage du cyclone Bejisa...

    Pour rappel, le webservice fonctionne bien sous tomcat 7 (j'ai testé avec SoapUI)

    Voici le code de la classe DoubleItPortTypeImpl :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    package service;
     
    import javax.jws.WebService;
    import org.example.contract.doubleit.DoubleItPortType;
     
    @WebService(targetNamespace = "http://www.example.org/contract/DoubleIt", 
                portName="DoubleItPort",
                serviceName="DoubleItService", 
                endpointInterface="org.example.contract.doubleit.DoubleItPortType")
    public class DoubleItPortTypeImpl implements DoubleItPortType {
     
        public int doubleIt(int numberToDouble) {
            return numberToDouble * 2;
        }
    }

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2012
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2012
    Messages : 10
    Points : 9
    Points
    9
    Par défaut
    Quelqu'un pour me venir en aide ? snif snif

  5. #5
    Futur Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2012
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2012
    Messages : 10
    Points : 9
    Points
    9
    Par défaut
    j'ai trouvé la solution.. mon problème venait d'un conflit avec le service jaxws. J'ai donc procédé de la manière suivante :

    - dans le fichier <jonas_folder>/conf/jonas.properties repérer la ligne suivante et y supprimer jaxws:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    jonas.services    jtm,db,resource,ejb3,jaxws,web,ear,depmonitor
    - ne pas oublier d'inclure la dépendance suivante dans votre projet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
                <dependency>
                     <groupId>org.springframework</groupId>
                     <artifactId>spring-web</artifactId>
                     <version>3.0.7.RELEASE</version>
                </dependency>
    - ensuite redémarrer jonas :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    jonas stop
    jonas start

Discussions similaires

  1. Déploiement d’un WebService/CXF sur WebSphere 7.0
    Par plopGtg dans le forum Services Web
    Réponses: 0
    Dernier message: 06/06/2013, 15h08
  2. Déploiement de WS avec CXF sur JOnAS
    Par iftolotfi dans le forum JOnAS
    Réponses: 4
    Dernier message: 01/12/2010, 11h26
  3. Réponses: 1
    Dernier message: 14/04/2010, 18h32
  4. Déploiement Avancé avec JONAS
    Par alhabas dans le forum JOnAS
    Réponses: 1
    Dernier message: 20/03/2007, 13h17
  5. [Déploiement] local sur serveur -> local sur ma machine
    Par annalady dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 01/09/2006, 13h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo