1 2 Previous Next 23 Replies Latest reply on Apr 1, 2006 12:37 PM by irisel Go to original post
      • 15. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
        forjbpm

        oh g8!
        Hi Jose, Can you please tell me what are the steps you have taken to expose your session EJb as webservice?
        what are the files/packages required and what should be the directory structure?
        It seems that its absolutely not working for me :-(

        Thanks and Regards,

        • 16. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
          irisel

          Hello,

          If you would be more explicit...

          1. Copy your EJB Remote interface to extend Remote instead. That's all you have to change. It's my com.irisel.oms.ws.OMBrowserEndpoint interface.

          2. Modify your ejb-jar.xml to include <service-endpoint> like in my file, referencing the new interface we created in step 1.

          3. Generate mappings, wsdl, etc. by running ant task (my ws_compile task). Delete the rest of the classes, we don't need them for the server, as it is the EJB which will serve the requests.

          4. Write webservices.xml to associate mappings, wsdl, interface and EJB servant. This is the glue that make things work.

          5. Packaging: Now include in the EJB Jar the ejb-jar.xml, mappings, wsdl description under META-INF/wsdl, jboss.xml and webservices.xml. I modified the packaging configuration that is explained in the JBoss tutorial for this purpose. You can derive my folder structure from my packaging-build.xml below.

          At this point, install your EJB and make sure it is running by going to http://localhost:8080/ws4ee. View services and click on the wsdl link. It should show the wsdl description of your service.

          5. Run ant task to generate client stubs. The web service must be up and running for it to retrieve the wsdl description. To create the task follow my target_wscompile_client. Some, if not all, of the generated classes are identical to those we deleted in step 3, but I change the destination package to ...ws.client for clarity. In the server package I only have the interface created in step 1.

          6. Test the web service using the stubs generated. My test program is below. (My OMBrowserWebServiceLocator class extends the "Impl" class to be able to set the destination URL, which is hardcoded in the "Stub" class).

          For me the most difficult part was to solve the references between the beans, the web app and the web service. It helped me very much the tips of the xml editor of JBoss IDE.

          Hope it helps. If it works, tell us so !

          Regards,
          Jose.

          packaging-build.xml:

          <?xml version="1.0" encoding="UTF-8"?>
          <project default="_packaging_generation_" name="Packaging Generator">
          <target name="_packaging_generation_" depends="N400004,N40004F,N40007A,deploy"/>
          <target name="N400004" description="OMBrowserEJB.jar">
          <jar destfile="OMBrowserEJB.jar">
          <zipfileset dir="src/META-INF" prefix="META-INF">
          <include name="ejb-jar.xml"/>
          </zipfileset>
          <zipfileset dir="src/META-INF" prefix="META-INF">
          <include name="jboss.xml"/>
          </zipfileset>
          <zipfileset dir="C:/IRISEL/eclipse/oms/ext/lib" prefix="lib">
          <include name="mysql-connector.jar"/>
          </zipfileset>
          <zipfileset dir="src/META-INF/wsdl" prefix="META-INF/wsdl">
          <include name="OMBrowserWebService.wsdl"/>
          </zipfileset>
          <zipfileset dir="src/META-INF" prefix="META-INF">
          <include name="jaxrpc-mapping.xml"/>
          </zipfileset>
          <zipfileset dir="src/META-INF" prefix="META-INF">
          <include name="webservices.xml"/>
          </zipfileset>
          <zipfileset dir="build" includes="com/**/*.class, com/**/*.properties"/>
          <zipfileset dir="C:/IRISEL/eclipse/oms/build" includes="com/**/*.class, **/*.properties"/>
          </jar>
          </target>
          <target name="N40004F" description="OMBrowser.war">
          <jar destfile="OMBrowser.war">
          <zipfileset dir="src/WEB-INF" prefix="WEB-INF">
          <include name="web.xml"/>
          </zipfileset>
          <zipfileset dir="src/WEB-INF" prefix="WEB-INF">
          <include name="jboss-web.xml"/>
          </zipfileset>
          <zipfileset dir="build" prefix="WEB-INF/classes" includes="com/irisel/oms/servlet/*.class"/>
          <zipfileset dir="html"/>
          </jar>
          </target>
          <target name="N40007A" description="OMBrowser.ear">
          <jar destfile="OMBrowser.ear">
          <zipfileset dir="src/META-INF" prefix="META-INF">
          <include name="application.xml"/>
          </zipfileset>
          <zipfileset dir=".">
          <include name="OMBrowserEJB.jar"/>
          </zipfileset>
          <zipfileset dir=".">
          <include name="OMBrowser.war"/>
          </zipfileset>
          </jar>
          </target>
          <target name="deploy">
           <!--<property name="jboss.deploy" value="C:\Program Files\JBoss-4.0.4RC1\server\default\deploy" />-->
           <copy overwrite="true" file="OMBrowser.ear" tofile="C:\Program Files\JBoss-4.0.4RC1\server\default\deploy\OMBrowser.ear" >
           </copy>
          </target>
          </project>
          


          Test program:

          
          package com.irisel.oms.ws.client;
          
          import org.apache.log4j.Logger;
          
          import com.irisel.oms.olapi.beans.AppVO;
          import com.irisel.oms.olapi.beans.XMLBean;
          
          import junit.framework.*;
          
          public class OMBrowserWebServiceTest extends TestCase {
          
           public static final String KEY_WS_PORT = "wsPort";
          
           OMBrowserWebServiceLocator locator;
           com.irisel.oms.ws.client.OMBrowserEndpoint svc;
           com.irisel.modules.PackageConfiguration config;
           Logger log4j;
          
           public static Test suite() {
           return new TestSuite(OMBrowserWebServiceTest.class);
           }
          
           protected void setUp() {
           try {
           log4j = Logger.getLogger(this.getClass());
          
           // Load Configuration
           final java.io.InputStream in = getClass().getResourceAsStream(
           "/config.properties");
          
           this.config = com.irisel.modules.PackageManager.getInstance()
           .getPackageConfiguration();
          
           locator = new OMBrowserWebServiceLocator();
           this.config.load(in);
           String wsPort = config.getConfigProperty(KEY_WS_PORT);
           log4j.info("Web Service Port: "+wsPort);
           svc = locator.getOMBrowserEndpointPort(wsPort);
           }
           catch (Exception e) {
           e.printStackTrace();
           }
           }
          
           public void testEcho() {
           try {
           assertEquals(svc.echo("hola!"),"HOLA!");
           } catch (Throwable e) {
           fail(e.getMessage());
           }
           }
          
          
           /**
           * @param args
           */
           public static void main(String[] args) {
           junit.textui.TestRunner.run(suite());
           }
          
          }
          


          • 17. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
            irisel


            Maybe these files help you:

            Config file for wscompile to generate server:

            wscompile.config.xml

            
            <?xml version="1.0" encoding="UTF-8"?>
            
            <configuration
            
            xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
            
            <!-- <service> or <wsdl> or <modelfile> -->
            
            <service name="OMBrowserWebService"
            
             targetNamespace="http://com.irisel.oms.ws"
             typeNamespace="http://com.irisel.oms.ws/types"
             packageName="com.irisel.oms.ws">
            
             <interface
             name="com.irisel.oms.ws.OMBrowserEndpoint"
             />
            
            </service>
            
            
            </configuration>
            
            


            Webservices.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <webservices 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://www.ibm.com/webservices/xsd/j2ee_webservice_1.1.xsd">
             <webservice-description>
             <webservice-description-name>
             OMBrowserWebService
             </webservice-description-name>
             <wsdl-file>META-INF/wsdl/OMBrowserWebService.wsdl</wsdl-file>
             <jaxrpc-mapping-file>
             META-INF/jaxrpc-mapping.xml
             </jaxrpc-mapping-file>
             <port-component>
             <port-component-name>OMBrowserEndpointPort</port-component-name>
             <wsdl-port>OMBrowserEndpointPort</wsdl-port>
             <service-endpoint-interface>
             com.irisel.oms.ws.OMBrowserEndpoint
             </service-endpoint-interface>
             <service-impl-bean>
             <ejb-link>OMGenEJB</ejb-link>
             </service-impl-bean>
             </port-component>
             </webservice-description>
            </webservices>


            JBoss.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
            
            <jboss>
            
             <enterprise-beans>
            
             <!--
             To add beans that you have deployment descriptor info for, add
             a file to your XDoclet merge directory called jboss-beans.xml that contains
             the <session></session>, <entity></entity> and <message-driven></message-driven>
             markup for those beans.
             -->
            
             <session>
             <ejb-name>OMGenEJB</ejb-name>
             <jndi-name>ejb/OMGenEJB</jndi-name>
            
             </session>
             <session>
             <ejb-name>OMBrowserEJB</ejb-name>
             <jndi-name>ejb/OMBrowserEJB</jndi-name>
            
             </session>
            
             <!--
             write a merge file jboss-webservices.ent for webservice-description
             -->
            
             </enterprise-beans>
            
             <resource-managers>
             </resource-managers>
            
             <!--
             | for container settings, you can merge in jboss-container.xml
             | this can contain <invoker-proxy-bindings/> and <container-configurations/>
             -->
            
            </jboss>
            




            • 18. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
              irisel

              ejb-jar.xml

              <?xml version="1.0" encoding="UTF-8" ?>
              <ejb-jar 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/ejb-jar_2_1.xsd"
               version="2.1">
              
               <description><![CDATA[No Description.]]></description>
               <display-name>Generated by XDoclet</display-name>
              
               <enterprise-beans>
              
               <!-- Session Beans -->
               <session >
               <description><![CDATA[Generic EJB]]></description>
               <display-name>Generic Enterprise Bean</display-name>
              
               <ejb-name>OMGenEJB</ejb-name>
               <home>com.irisel.oms.ejb.interfaces.OMGenEJBHome</home>
               <remote>com.irisel.oms.ejb.interfaces.OMGenEJB</remote>
               <service-endpoint>com.irisel.oms.ws.OMBrowserEndpoint</service-endpoint>
               <ejb-class>com.irisel.oms.ejb.browser.OMGenBean</ejb-class>
               <session-type>Stateless</session-type>
               <transaction-type>Container</transaction-type>
              
               </session>
              
               <session >
               <description><![CDATA[Description for OMBrowser]]></description>
               <display-name>OMBrowser Enterprise Bean</display-name>
              
               <ejb-name>OMBrowserEJB</ejb-name>
              
               <home>com.irisel.oms.ejb.interfaces.OMBrowserEJBHome</home>
               <remote>com.irisel.oms.ejb.interfaces.OMBrowserEJB</remote>
               <ejb-class>com.irisel.oms.ejb.browser.OMBrowserBean</ejb-class>
               <session-type>Stateless</session-type>
               <transaction-type>Container</transaction-type>
              
               </session>
              
               <!--
               To add session beans that you have deployment descriptor info for, add
               a file to your XDoclet merge directory called session-beans.xml that contains
               the <session></session> markup for those beans.
               -->
              
               <!-- Entity Beans -->
               <!--
               To add entity beans that you have deployment descriptor info for, add
               a file to your XDoclet merge directory called entity-beans.xml that contains
               the <entity></entity> markup for those beans.
               -->
              
               <!-- Message Driven Beans -->
               <!--
               To add message driven beans that you have deployment descriptor info for, add
               a file to your XDoclet merge directory called message-driven-beans.xml that contains
               the <message-driven></message-driven> markup for those beans.
               -->
              
               </enterprise-beans>
              
               <!-- Relationships -->
              
               <!-- Assembly Descriptor -->
               <!--
               To specify your own assembly descriptor info here, add a file to your
               XDoclet merge directory called assembly-descriptor.xml that contains
               the <assembly-descriptor></assembly-descriptor> markup.
               -->
              
               <assembly-descriptor >
               <!--
               To specify additional security-role elements, add a file in the merge
               directory called ejb-security-roles.xml that contains them.
               -->
              
               <!-- method permissions -->
               <!--
               To specify additional method-permission elements, add a file in the merge
               directory called ejb-method-permissions.ent that contains them.
               -->
              
               <!-- transactions -->
               <!--
               To specify additional container-transaction elements, add a file in the merge
               directory called ejb-container-transactions.ent that contains them.
               -->
              
               <!-- finder transactions -->
              
               <!-- message destinations -->
               <!--
               To specify additional message-destination elements, add a file in the merge
               directory called ejb-message-destinations.ent that contains them.
               -->
              
               <!-- exclude list -->
               <!--
               To specify an exclude-list element, add a file in the merge directory
               called ejb-exclude-list.xml that contains it.
               -->
               </assembly-descriptor>
              
              </ejb-jar>
              


              • 19. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
                forjbpm

                Thanks Jose,
                Now Something from my side :-)
                for webservices you dont need remote/home interface
                so in your session bean edit

                **
                 * @ejb.bean name="ExegenixWork1"
                 * display-name="Name for ExegenixWork1"
                 * description="Description for ExegenixWork1"
                 * jndi-name="ejb/ExegenixWork1"
                 * type="Stateless"
                 * view-type="service-endpoint"
                 *
                 * @ejb.interface
                 *
                 * service-endpoint-class="com.interfaces.ExegenixWork1Bean"
                 * service-endpoint-pattern = "{0}Service"
                 *
                 */


                and before each of your business method

                /**
                 * Business method
                 * @ejb.interface-method view-type = "service-endpoint"
                 */
                


                In your generated Xdoclet-build.xml file
                add
                 <service-endpoint pattern="{0}Service"/>
                

                and then run Xdoclet
                In my case it creates com.interfaces.ExegenixWork1Bean with Remote interface which you can directly use for your webservice

                I hope this helps and gets rid of unwanted editing :-)

                Again, Thanks a lot for detailed explanation I will follow your steps/

                • 20. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
                  forjbpm

                  I have been following / again followed the same steps but I still get the exception mentioned at
                  http://jboss.org/index.html?module=bb&op=viewtopic&t=79562
                  this time I followed your steps till 5. but after that I get above error
                  :-(

                  • 21. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
                    pierroot

                    For creating a client for an existing web service in a very simple way : download the WTP (Web Tools Platform) plugin for eclipse (forget about the JBoss-IDE for now) and just do a new > web service client.

                    This works like a charme for the most simple tasks you have to do with web services. I didn't try it with EJB and other stuff though but it might help beginners.

                    You can download it on the eclipse.org site.

                    • 22. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
                      forjbpm

                      huh!!!
                      Finally I found my problem, Thanks a lot to Jose,thomas and others who contributed
                      Its really really very stupid thing but in my webservices.xml file
                      I was using

                      <service-endpoint> instead of <service-endpoint-interface>
                      


                      • 23. Re: java.lang.NoClassDefFoundError: org/apache/axis/client/S
                        irisel

                        Ok, that's cool. I'll try it.

                        Regards,
                        Jose.

                        1 2 Previous Next