6 Replies Latest reply on Apr 29, 2008 9:30 PM by Peter Pei Guo

    Cannot expose EJB 3 as WS

    Peter Pei Guo Newbie

      Hi,

      I developed a very simple EJB 3 bean, I can deploy it with no error, but the web service is not exposed.
      This is what I did:
      1) Wrote the code as shown below;
      2) compile and jar into hello.jar;
      3) copy the jar to server/default/deploy;

      Please help, what did I miss? I am using 4.2.2.GA
      Hello.java:

      package org.jboss.ws.hello;
      
      
      import java.rmi.Remote;
      
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      
      @WebService
      public interface Hello extends Remote {
       @WebMethod
       String echo(String e);
      }
      

      HelloBean.java:
      package org.jboss.ws.hello;
      
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.*;
      import javax.jws.soap.*;
      
      @Stateless
      @WebService(endpointInterface = "org.jboss.ws.hello.Hello")
      @Remote(Hello.class)
      public class HelloBean {
       public String echo(String e) {
       return "Web Service Echo + " + e;
       }
      }
      


        • 1. Re: Cannot expose EJB 3 as WS
          Peter Pei Guo Newbie

          I can resolve by specify wsdlLocation in a config.xml file. Wondering why... tried to specify this wsdlLocation using @WebService and didn't work.

          • 2. Re: Cannot expose EJB 3 as WS
            Peter Pei Guo Newbie

            Checked out the specification for @WebService, it says that wsdlLocation points to a predefined wsdl, obviously does not work for my purpose here.

            I still wonder whether I can avoid the config.xml file. Is it not true that EJB 3 suppose to remove the need of those xml files.

            • 3. Re: Cannot expose EJB 3 as WS
              Richard Opalka Master

              Strange, it works for me.

              Here's my EJB3 archive content:

              jar -tvf jaxws.jar
               0 Mon Apr 28 08:17:42 CEST 2008 META-INF/
               106 Mon Apr 28 08:17:40 CEST 2008 META-INF/MANIFEST.MF
               0 Mon Apr 28 08:20:04 CEST 2008 org/
               0 Mon Apr 28 08:20:04 CEST 2008 org/jboss/
               0 Mon Apr 28 08:20:04 CEST 2008 org/jboss/ws/
               0 Mon Apr 28 08:20:04 CEST 2008 org/jboss/ws/hello/
               290 Mon Apr 28 08:20:04 CEST 2008 org/jboss/ws/hello/Hello.class
               834 Mon Apr 28 08:20:04 CEST 2008 org/jboss/ws/hello/HelloBean.class


              Here's my server console output:
              08:22:02,562 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              08:22:02,577 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=jaxws.jar,name=HelloBean,service=EJB3 with dependencies:
              08:22:02,854 INFO [EJBContainer] STARTED EJB: org.jboss.ws.hello.HelloBean ejbName: HelloBean
              08:22:02,982 INFO [EJB3Deployer] Deployed: file:/opt/svn/jbossas/tags/JBoss_4_2_2_GA/build/output/jboss-4.2.2.GA/server/default/deploy/jaxws.jar
              08:22:03,161 INFO [DefaultEndpointRegistry] register: jboss.ws:context=jaxws,endpoint=HelloBean
              08:22:06,156 INFO [WSDLFilePublisher] WSDL published to: file:/opt/svn/jbossas/tags/JBoss_4_2_2_GA/build/output/jboss-4.2.2.GA/server/default/data/wsdl/jaxws.jar/HelloBeanService9073.wsdl
              08:22:06,504 INFO [TomcatDeployer] deploy, ctxPath=/jaxws, warUrl=.../tmp/deploy/jaxws.jar9072.war/


              and I'm able to access WSDL here:

              http://127.0.0.1:8080/jaxws/HelloBean?wsdl



              • 4. Re: Cannot expose EJB 3 as WS
                Peter Pei Guo Newbie

                Hm... After I read your reply, I tried two things but both failed, not sure what we did differently (I am using 4.2.2.GA).
                1) I removed the config.xml file, when I deploy I got this:

                15:07:45,192 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
                
                --- Packages waiting for a deployer ---
                org.jboss.deployment.DeploymentInfo@9f91cc6f { url=file:/C:/jboss-4.2.2.GA/serve
                r/default/deploy/endpoint/Hello.class }
                 deployer: null
                 status: null
                 state: INIT_WAITING_DEPLOYER
                 watch: file:/C:/jboss-4.2.2.GA/server/default/deploy/endpoint/Hello.class
                 altDD: null
                 lastDeployed: 1209420465192
                 lastModified: 1209420465192
                 mbeans:
                
                --- Incompletely deployed packages ---
                org.jboss.deployment.DeploymentInfo@9f91cc6f { url=file:/C:/jboss-4.2.2.GA/serve
                r/default/deploy/endpoint/Hello.class }
                 deployer: null
                 status: null
                 state: INIT_WAITING_DEPLOYER
                 watch: file:/C:/jboss-4.2.2.GA/server/default/deploy/endpoint/Hello.class
                 altDD: null
                 lastDeployed: 1209420465192
                 lastModified: 1209420465192
                 mbeans:
                


                2) the config.xml is still removed like option, but I added wsdlLocation in my code like this:
                @Stateless
                @WebService(endpointInterface="org.jboss.tutorial.webservice.bean.Calculator", wsdlLocation="http://localhost:8080/tutorial/CalculatorBean?wsdl")
                

                And I got this:
                15:10:27,020 ERROR [MainDeployer] Could not start deployment: file:/C:/jboss-4.2
                .2.GA/server/default/deploy/tutorial.jar
                org.jboss.ws.metadata.wsdl.WSDLException: Cannot parse wsdlLocation: http://loca
                lhost:8080/tutorial/CalculatorBean?wsdl
                 at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDefini
                tionsFactory.java:183)
                 at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsF
                actory.java:108)
                 at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.pr
                ocessOrGenerateWSDL(JAXWSWebServiceMetaDataBuilder.java:373)
                 at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.bu
                ildWebServiceMetaData(JAXWSWebServiceMetaDataBuilder.java:158)
                 at org.jboss.ws.metadata.builder.jaxws.JAXWSServerMetaDataBuilder.setupP
                roviderOrWebService(JAXWSServerMetaDataBuilder.java:50)
                 at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilderEJB3.buildMet
                aData(JAXWSMetaDataBuilderEJB3.java:78)
                 at org.jboss.wsf.stack.jbws.UnifiedMetaDataDeploymentAspect.create(Unifi
                edMetaDataDeploymentAspect.java:71)
                 at org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl.deploy
                (DeploymentAspectManagerImpl.java:115)
                 at org.jboss.wsf.container.jboss42.ArchiveDeployerHook.deploy(ArchiveDep
                loyerHook.java:97)
                 at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInt
                erceptor.java:90)
                 at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.
                start(SubDeployerInterceptorSupport.java:188)
                 at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterce
                ptor.java:95)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy34.start(Unknown Source)
                 at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                 at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                sorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                er.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
                or.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
                BeanOperationInterceptor.java:142)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy9.deploy(Unknown Source)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
                tScanner.java:421)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
                canner.java:610)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                doScan(AbstractDeploymentScanner.java:263)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                loop(AbstractDeploymentScanner.java:274)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                run(AbstractDeploymentScanner.java:225)
                Caused by: java.io.FileNotFoundException: http://localhost:8080/tutorial/Calcula
                torBean?wsdl
                 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
                nection.java:1151)
                 at java.net.URL.openStream(URL.java:1007)
                 at org.jboss.ws.core.utils.ResourceURL.openStream(ResourceURL.java:57)
                 at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDefini
                tionsFactory.java:166)
                 ... 37 more
                
                


                • 5. Re: Cannot expose EJB 3 as WS
                  Peter Johnson Master

                  Try renaming the directory server/default/deploy/endpoint to server/default/deploy/endpoint.jar. You need the .jar suffix to let the deployer know what type of application to deploy.

                  Remove the wsdlLocation attribute. When you use it, it should reference a file in the archive, like this:

                  wsdlLocation="wsdl/CalculatorBeanService.wsdl"

                  And the file must exist in the archive.

                  • 6. Re: Cannot expose EJB 3 as WS
                    Peter Pei Guo Newbie

                    Thanks and you are right!