3 Replies Latest reply on Aug 16, 2010 2:01 PM by derkd

    CXF Webservice client with Seam 1.2.1 on OC4J 10.1.3 not working

    derkd
      I have some problems getting my webservice client to work...
      I have a CXF webservice client in my Seam web app which I deploy on OC4J 10.1.3.4.

      I'm getting the following error:


      javax.xml.ws.WebServiceException: org.apache.cxf.binding.soap.SoapFault: The AXIS engine could not find a target service to invoke!
        targetService is BOCPort@wsdl

       
      I'm trying to connect to an Axis1 webservice. I tried to make a connectiong with an standalone java application and that worked, but I can't get it to
      work in my Seam web app.

      I'm using Maven2 to build my web app and use the following files for the CXF webservice client (version 2.2):

                      <dependency>
                              <groupId>org.apache.cxf</groupId>
                              <artifactId>cxf-rt-core</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <dependency>
                              <groupId>org.apache.cxf</groupId>
                              <artifactId>cxf-rt-frontend-simple</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <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-databinding-aegis</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <dependency>
                              <groupId>org.apache.cxf</groupId>
                              <artifactId>cxf-rt-transports-local</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-rt-transports-http-jetty</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <dependency>
                              <groupId>org.apache.cxf</groupId>
                              <artifactId>cxf-rt-transports-jms</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <dependency>
                              <groupId>org.apache.cxf</groupId>
                              <artifactId>cxf-rt-management</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <dependency>
                              <groupId>org.apache.cxf</groupId>
                              <artifactId>cxf-common-utilities</artifactId>
                              <version>${cxf.version}</version>
                      </dependency>
                      <dependency>
                              <groupId>org.mortbay.jetty</groupId>
                              <artifactId>jetty</artifactId>
                              <version>6.1.6</version>
                      </dependency>

                     
      I know that when you implement a webservice in Seam you have to create a config file in xml, but do you also have to do that with a webservice client?

      This is the code to make a call to the webservice:


                      BOCPortType boc = null;
             
              factory = new JaxWsProxyFactoryBean();
              System.out.println("new JaxWsClientFactoryBean created...");
              factory.getInInterceptors().add(new LoggingInInterceptor());
              factory.getOutInterceptors().add(new LoggingOutInterceptor());
              factory.setServiceClass(BOCPortType.class);
              factory.setAddress(url);
              System.out.println("setting the url to connect to: " + url);
              boc = (BOCPortType) factory.create();
                      List<BeroepSector> beroepSectoren = boc.getAllBeroepSector();


      my components.xml looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
              xmlns:core="http://jboss.com/products/seam/core"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation=
              "http://jboss.com/products/seam/core
              http://jboss.com/products/seam/core-1.1.xsd
              http://jboss.com/products/seam/components
              http://jboss.com/products/seam/components-1.1.xsd">
             
              <core:init debug="false" jndi-pattern="java:comp/env/bocwebapp/#{ejbName}/local"/>   

              <core:manager conversation-timeout="120000"
                              concurrent-request-timeout="500"
                              conversation-id-parameter="cid"/>

      </components>


      my faces-config.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
      <faces-config>

               <application>
                      <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                      <locale-config>
                              <default-locale>en_US</default-locale>
                      </locale-config>
              </application>

              <lifecycle>
                      <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
              </lifecycle>
             
      </faces-config>


      my web.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
              version="2.4">

              <!-- Seam -->

              <listener>
                      <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
              </listener>
             
              <servlet>
                      <servlet-name>Faces Servlet</servlet-name>
                      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                      <load-on-startup>1</load-on-startup>
              </servlet>
              <!-- Faces Servlet Mapping -->
              <servlet-mapping>
                      <servlet-name>Faces Servlet</servlet-name>
                      <url-pattern>*.seam</url-pattern>
              </servlet-mapping>

              <servlet-mapping>
                      <servlet-name>Seam Remoting</servlet-name>
                      <url-pattern>/seam/remoting/*</url-pattern>
              </servlet-mapping>
             
              <servlet>
              <servlet-name>Seam Resource Servlet</servlet-name>
              <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
          </servlet>
         
          <servlet-mapping>
              <servlet-name>Seam Resource Servlet</servlet-name>
              <url-pattern>/seam/resource/*</url-pattern>
          </servlet-mapping>

              <context-param>
                      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                      <param-value>client</param-value>
              </context-param>

              <!-- <context-param>
                      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                      <param-value>.jspx</param-value>
              </context-param>-->
              <context-param>
              <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
              <param-value>.xhtml</param-value>
          </context-param>

             

              <servlet>
                      <servlet-name>Seam Remoting</servlet-name>
                      <servlet-class>org.jboss.seam.remoting.SeamRemotingServlet</servlet-class>
                      <load-on-startup>2</load-on-startup>
              </servlet>

      <!-- Plugging the "Blue Sky" skin into the project -->
      <context-param>
         <param-name>org.richfaces.SKIN</param-name>
         <param-value>blueSky</param-value>
      </context-param>

      <!-- Making the RichFaces skin spread to standard HTML controls -->
      <context-param>
            <param-name>org.richfaces.CONTROL_SKINNING</param-name>
            <param-value>enable</param-value>
      </context-param>

      <!-- Defining and mapping the RichFaces filter -->
      <filter>
         <display-name>RichFaces Filter</display-name>
         <filter-name>richfaces</filter-name>
         <filter-class>org.ajax4jsf.Filter</filter-class>
      </filter>

      <filter-mapping>
         <filter-name>richfaces</filter-name>
         <servlet-name>Faces Servlet</servlet-name>
         <dispatcher>REQUEST</dispatcher>
         <dispatcher>FORWARD</dispatcher>
         <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>

      <security-constraint>
              <display-name>Restrict raw XHTML Documents</display-name>
              <web-resource-collection>
                  <web-resource-name>XHTML</web-resource-name>
                  <url-pattern>*.xhtml</url-pattern>
              </web-resource-collection>
              <auth-constraint/>
          </security-constraint>
         
          <welcome-file-list>
              <welcome-file>index.html</welcome-file>
          </welcome-file-list>

      </web-app>


      I also have an orion-application.xml to prevent loading some old oracle jar files:

      <?xml version="1.0"?>

      <orion-application  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-application-10_0.xsd"  deployment-version="10.1.3.1.0" default-data-source="jdbc/OracleDS" component-classification="external" schema-major-version="10" schema-minor-version="0" >
              <web-module id="bocwebapp" path="bocwebapp-web.war" />
              <imported-shared-libraries>
                      <remove-inherited name="oracle.toplink"/>
                      <remove-inherited name="oracle.persistence"/>
                      <remove-inherited name="oracle.xml"/>
                      <remove-inherited name="oracle.xml.security"/>
                      <remove-inherited name="apache.commons.logging"/>
                      <remove-inherited name="oracle.jwsdl"/>
                      <remove-inherited name="oracle.ws.jaxrpc"/>
              </imported-shared-libraries>
              <log>
                      <file path="application.log" />
              </log>
      </orion-application>


      I can't figure out why it isn't working, I hope someone can help me out on this... I'm struggeling with this for over a week now... :(
        • 1. Re: CXF Webservice client with Seam 1.2.1 on OC4J 10.1.3 not working
          derkd

          BTW I managed to get this working in a standalone java app so I guess the code is OK, I can't get it working in Seam :(
          sorry for the layout, I tried to use the code blocks but I got errors, so that's why I did it in plain text.

          • 2. Re: CXF Webservice client with Seam 1.2.1 on OC4J 10.1.3 not working
            gabonio

            Hi! I have the exact same problem here, my standalone WS client works great, but when I try to get it to work through SEAM, the whole thing goes nuts... Did you mannage to fix it?? and if you did whould you mind telling me how?


            Thanx!!

            • 3. Re: CXF Webservice client with Seam 1.2.1 on OC4J 10.1.3 not working
              derkd

              Yes I got this thing working. It has been a while ago, I can't remember what it was...
              Eventually I build the webclient jar in a separate project and added the jar to my initial project later. That worked!


              here is the pom of the separate webclient jar:




              <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><your groupId></groupId>
                   <artifactId><your app name>-webservice-client-CXF</artifactId>
                   <name>boc-webservice-client-CXF</name>
                   <version>1.2-test</version>
                   <packaging>jar</packaging>
                    <properties>
                       <cxf.version>2.2.2</cxf.version>
                     </properties>
                   <dependencies>     
                           <dependency>
                             <groupId>org.apache.cxf</groupId>
                             <artifactId>cxf-rt-core</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <dependency>
                             <groupId>org.apache.cxf</groupId>
                             <artifactId>cxf-rt-frontend-simple</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <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-databinding-aegis</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <dependency>
                             <groupId>org.apache.cxf</groupId>
                             <artifactId>cxf-rt-transports-local</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-rt-transports-http-jetty</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <dependency>
                             <groupId>org.apache.cxf</groupId>
                             <artifactId>cxf-rt-transports-jms</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <dependency>
                             <groupId>org.apache.cxf</groupId>
                             <artifactId>cxf-rt-management</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <dependency>
                             <groupId>org.apache.cxf</groupId>
                             <artifactId>cxf-common-utilities</artifactId>
                             <version>${cxf.version}</version>
                        </dependency>
                        <!-- <dependency>
                             <groupId>org.mortbay.jetty</groupId>
                             <artifactId>jetty</artifactId>
                             <version>6.1.6</version>
                        </dependency>-->
                       <dependency>
                         <groupId>junit</groupId>
                         <artifactId>junit</artifactId>
                         <version>4.4</version>
                         <scope>test</scope>
                       </dependency>
                  </dependencies>
                  
                  <build>
                    <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <!-- best lock down version of the plugin too -->
                        <configuration>
                             <source>1.5</source>
                             <target>1.5</target>
                        </configuration>
                        </plugin> 
                        <plugin>
                          <groupId>org.apache.cxf</groupId>
                          <artifactId>cxf-codegen-plugin</artifactId>
                          <version>${cxf.version}</version>
                             <executions>
                               <execution>
                                  <id>generate-sources</id>
                                  <phase>generate-sources</phase>
                                    <configuration>
                                       <sourceRoot>${project.build.directory}/webservice-client/generated</sourceRoot>                                
                                         <wsdlOptions>
                                            <wsdlOption>
                                              <packagenames>
                                                <packagename><your package name></packagename>
                                              </packagenames>
                                              
                                              <wsdl>${basedir}/src/main/resources/boc.wsdl</wsdl>
                                              </wsdlOption>
                                         </wsdlOptions>
                                    </configuration>
                                  <goals>
                                       <goal>wsdl2java</goal>
                                  </goals>
                             </execution>
                          </executions>
                        </plugin>
                     </plugins>
                   </build>
              
                  
              </project>



              Add the jar to your ejb project and set it to compile scope. Hope this will help you.


              Regards,


              Derk