edit the pom.xml file:

change the spring version to 2.5.5.
this is below <!– Framework dependency versions –>
delete the dependency with the artifactId ‘xfire-java5′ and ‘xfire-spring’
insert the cxf dependencies:

    <dependency>
    	<groupId>org.apache.cxf</groupId>
      	<artifactId>cxf-api</artifactId>
      	<version>2.1.3</version>
    </dependency>
    <dependency>
      	<groupId>org.apache.cxf</groupId>
    	<artifactId>cxf-rt-frontend-jaxws</artifactId>
    	<version>2.1.3</version>
            <exclusions>
                  <!-- http://www.jroller.com/melix/entry/apache_cxf_maven_javamail_awful -->
                  <exclusion>
                       <groupId>org.apache.geronimo.specs</groupId>
                       <artifactId>geronimo-javamail_1.4_spec</artifactId>
                  </exclusion>
            </exclusions>
    </dependency>
    <dependency>
    	<groupId>org.apache.cxf</groupId>
    	<artifactId>cxf-rt-transports-http</artifactId>
    	<version>2.1.3</version>
    </dependency>

exclude also asm and the cglib from the hibernate dependency

    <exclusion>
    	<groupId>asm</groupId>
    	<artifactId>asm</artifactId>
    </exclusion>
    <exclusion>
    	<groupId>asm</groupId>
    	<artifactId>asm-attrs</artifactId>
    </exclusion>
    <exclusion>
    	<groupId>cglib</groupId>
    	<artifactId>cglib</artifactId>
    </exclusion>

add the asm-all and cglib dependencies to the top level <dependencies>:

    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm-all</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2</version>
    </dependency>

add the spring-core and spring-web dependency:

    <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>${spring.version}</version>
    </dependency>
    <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <version>${spring.version}</version>
    </dependency>

edit the web.xml file and change /WEB-INF/xfire-servlet.xml in the <param-value> of the <!– Context Configuration locations for Spring XML files to /WEB-INF/cxf-servlet.xml

also replace the servlet named xfire to

    <servlet>
          <servlet-name>CXFServlet</servlet-name>
          <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
    </servlet>

and also the xfire servlet mapping to

    <servlet-mapping>
          <servlet-name>CXFServlet</servlet-name>
          <url-pattern>/services/*</url-pattern>
    </servlet-mapping> 

delete WEB-INF/xfire-servlet.xml and make a new file there called cxf-servlet.xml which has this content:

    <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 resource="classpath:cxf/cxf.xml" />
            <import resource="classpath:cxf/cxf-extension-soap.xml" />
            <import resource="classpath:cxf/cxf-servlet.xml" />
    
            <!-- #errorManager points to my manager(with the @webservice annotation)
                 defined in my applicationContext.xml-->
            <jaxws:endpoint
              id="errorService"
              implementor="#errorManager"
              address="/ErrorService" />
    </beans>

now something i had to do:
download cxf from here and copy the cxf folder from META-INF there to your /WEB-INF/classes/ path. otherwise it will not find the cxf/cxf.xml …

execute:

    mvn jetty:run

and check for your service at http://127.0.0.1:8080/services

i see this here:
picture-4

————————————————————
supporting REST like services here
———————————————————–

references:

http://cwiki.apache.org/CXF20DOC/writing-a-service-with-spring.html

http://forum.springframework.org/showthread.php?p=179390

http://www.jroller.com/melix/entry/apache_cxf_maven_javamail_awful ( p3t0r)

Tagged with:
 

9 Responses to “migrate appfuse from xfire to cxf”

  1. p3t0r says:

    I think you really want the exclude the (broken) mail api which comes with CXF! More info here:

    http://www.jroller.com/melix/entry/apache_cxf_maven_javamail_awful

  2. Appfuser says:

    “download cxf from here and copy the cxf folder from META-INF there to your /WEB-INF/classes/ path. otherwise it will not find the cxf/cxf.xml”

    Where is that folder in that package? Should I modify the content of the xml-files?

  3. nils petersohn says:

    no you don’t need to modify the content of the xml files.
    download http://apache.linux-mirror.org/cxf/2.1.3/apache-cxf-2.1.3.tar.gz and extract the jar file lib/cxf-2.1.3.jar.
    in there is the folder META-INF/cxf thats the folder i mean.
    i know its no good doing this, somehow you have to download the right package with maven. check out my post here.
    http://www.nabble.com/Re%3A-CXF-and-AppFuse-2.0.1-p21329504s2369.html
    with this maven conf i didn’t have to extract and copy the META-INF/cxf folder.

  4. Appfuser says:

    Thank you for your quick reply!

    I still get the following exception when running jetty:run. Some problems with the pom.xml?

    ——-

    Error creating bean with name ‘sessionFactory’ defined in class path resource [applicationContext-dao.xml]: Invocation of init method
    failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V:

  5. nils petersohn says:

    It seems that asm ist still missing. did you exclude it from the hibernate dependency and include it at the top level? please look at the post again. you can send me your pom.xml to nils@schoenhouse.de and i will look over it.

  6. Appfuser says:

    Thanks!

    It was just a misconfiguration in my pom.xml.

    Nice migration guide!

  7. nils petersohn says:

    thanx, took me a while to get everyting together, but rest is still not working. i think the jsr311 has to be completed first…

  8. nils petersohn says:

    i m not sure if jsr311 is the cause of my rest problems though

  9. [...] cxf, maven, migrate, spring, update, webservice … jetty remote debugging with maven for appfuse in [...]

Leave a Reply