4 Replies Latest reply on Mar 20, 2007 6:34 AM by wolfc

    Create EAR with EJB3 and JAX-WS

    oskar.carlstedt

      Hello!!

      I have been struggling a whole day now with this topic. Reading a lot of forum questions and tips, but I can't find a solution. Now I hope some of you can help me.

      I want to deploy an ear file containing a jar file that contains an EJB. The ejb jar file also contains a JAX-WS-web service endpoint provider that will "lookup" a session bean containing business methods for the actual web service request.

      I have a couple of problems. JBoss (version 4.2.0.CR1). I always get the message:

      16:17:41,057 WARN [verifier] EJB spec violation:
      Bean : TestEjb
      Section: 22.2
      Warning: The Bean Provider must specify the fully-qualified name of the Java class that implements the enterprise bean's business methods in the <ejb-class> element.
      Info : Class not found on 'some.package.TestEJB': No ClassLoaders found for: some.package.TestEJB


      Of course, I don't have any TestEJB class. I really can't understand why it is questioning about it.

      I have an interface

      public interface Test {
       ...
      }
      


      And I have a class

      @Stateless
      public class TestBean implements Test {
       ...
      }
      


      My JAX-WS Service enpoint provider looks something like:
      @Stateless
      @WebServiceProvider(
       serviceName = "Test",
       portName = "TestSoap11Port",
       targetNamespace = "http://my.domain.com/test-service",
       wsdlLocation = "WEB-INF/wsdl/test-service.wsdl")
      @ServiceMode(value = Service.Mode.PAYLOAD)
      public class TestEndpointProvider implements Provider<Source> {
      
       /**
       * The sei to use
       */
       private Object sei = null;
      
       @Resource
       protected WebServiceContext webServiceContext;
      
       /**
       * Does everything that must be done. This method is a kind of dispatcher
       * that finds the business method to invoke. Invokes the method and
       * serializes the response.
       */
       public Source invoke(Source requestSource) {
      
       try {
      
       ...
      
       // instantiate the sei
       InitialContext initialContext = new InitialContext();
       sei = initialContext.lookup(some.package.Test.class.getName());
      
       // get business method
       Method wsdlJavaMethod = getWsdlJavaMethod();
      
       // invoke method
       XmlObject xmlResponseObject = (XmlObject) wsdlJavaMethod.invoke(sei, xmlRequestObject);
      
       ...
      
       } catch (RuntimeException re) {
      
       throw re;
       } catch (Exception e) {
      
       throw new WebServiceException(e);
       }
       }
      }
      


      I have tried to annotate my EJB with the @Local(Test.class) and also the EJB annotation @EJB(beanInterface=Test.class, name="Test").

      The JAX-WS service endpoint provider does also have a Stateless annotation. Can this bean mess it up?

      The other thing is that JBoss reject to load my jar files included in the EAR file. All jar dependencies are on the classpath in the META-INF/MAINIFEST.MF file (generated by maven).

      My ear file has the following structure:
      test-ear-1.0-SNAPSHOT
       META-INF
       jboss-app.xml
       lib
       ...
       test-ejb-1.0-SNAPSHOT.jar
      


      jboss-app.xml
      <!DOCTYPE jboss-app
       PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      <jboss-app>
       <loader-repository>
       some.package:loader=test-ear-1.0-SNAPSHOT
       </loader-repository>
      </jboss-app>
      


      Does anyone know how I can fix these problems? DO I need anejb-jar.xml when I'm using EJB3. Do I have to configure JBoss 4.2.0.CR1. I get the same error in JBoss 4.0.5.GA with a jboss-EJB-3.0_RC9_Patch_1 installed.



      Best
      Oskar

        • 1. Re: Create EAR with EJB3 and JAX-WS
          wolfc

          It appears that the EJB 2 deployer is picking up your jar file. What is the contents of the jar file?

          • 2. Re: Create EAR with EJB3 and JAX-WS
            oskar.carlstedt

            You might be right!

            How do I configure the ear (or the ear deployer) to detect an EJB3? The contents of my ear file is as described above:

            test-ear-1.0-SNAPSHOT
             META-INF
             jboss-app.xml
             lib
             ...
             test-ejb-1.0-SNAPSHOT.jar
            


            Shall i remove the jboss-app.xml. What does it do? Is that the file to configure for ejb3?

            //Oskar


            • 3. Re: Create EAR with EJB3 and JAX-WS
              oskar.carlstedt

              After some investigations I finally found that an web service annotated bean cannot reside in a JAR-file, it must be placed in a war file. These are my thoughts right now, so the following must be applied:

              a EJB jar file containing my EJBs
              a war file containing my JAX-WS endpoint

              so, in maven2 there will be three project for such a small thing.
              - a beans project with packaging set to "ejb"
              - a web project with packaging set to "war"
              - and a era project with packaging set to "ear" (this project is empty, except for the pom.xml)

              Thanks for the help.

              Best
              Oskar

              • 4. Re: Create EAR with EJB3 and JAX-WS
                wolfc

                It should be possible to define a web service in a jar.
                Note that WebServiceContext injection isn't working in 4.2.0.CR1 (EJBTHREE-900).