5 Replies Latest reply on May 17, 2006 4:29 AM by Heiko Braun

    Java 1.5 enum in a web service

    Aviran Levy Newbie

      Hi All,

      I'm trying to create a web service on JBoss 4.0.4.CR2 using java 1.5 annotations and enum types. everything works fine with the annotatins and I use @webservice and @webmethod without problems.

      However, when I try to use java 1.5 enum types as the return types (or parameters) to any of my web methods it doesn't translate well on the wsdl. what I get is a empty complex type.

      If I use .NET and C# to create the same web service the wsdl shows a simple type with a 'restriction' element and 'enumeration' elements underneath it.

      Even when I define a String value to the java 1.5 enum type I create it's only showing it as a String parameter in the wsdl, under the complex type, as if it was a regular pojo, and without showing the acceptable enum values.

      Is anyone familiar with this problem?

      Is there any example of a web service that uses java 1.5 enums as parameters or return types?

      Maybe there is a way I don't know about to program those java 1.5 enum types so JBoss shows the acceptable values in the wsdl.

      Thanks,

      -- AV

        • 2. Re: Java 1.5 enum in a web service
          Aviran Levy Newbie

          Thanks for the reply.

          I read the jira log and I couldn't quite understand if this fix is included in the latest JBoss AS 4.0.4.CR2.

          If not, can you please point me to instructions to setting it up on 4.0.4.CR2.

          If yes, do I need to setup anything special for this fix to be applied to my 4.0.4.CR2?

          Thanks again,

          -- AV

          • 3. Re: Java 1.5 enum in a web service
            Aviran Levy Newbie

            Hi,

            I found and installed the latest jbossws1.0.0.GA. However, I'm not able to deploy a web service that used be deployable with the previous jbossws that I got with 4.0.4.CR2. The problem I have with the previous jbossws is with handling java 1.5 enums, as described on my previous post on this thread. but now I have a deploy problem with the new jbossws 1.0.0GA, when trying to deploy the web service. Bellow is the exception:

            15:22:57,198 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=TestEnumWSEJB, class=net.mycompany.testws.TestEnumWSEJB, type=STATELESS
            15:22:57,268 INFO [Ejb3Deployment] EJB3 deployment time took: 300
            15:22:57,609 WARN [EndpointMetaData] Cannot obtain style, using default: document
            15:22:57,699 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-4.0.4.RC2/server/default/deploy/TestWS.jar/
            java.lang.NoSuchMethodError: javassist.ClassPool.<init>(Z)V
             at org.jboss.ws.jaxrpc.ParameterWrapping.generateWrapper(ParameterWrapping.java:298)
             at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.processWebMethod(AnnotationsMetaDataBuilder.java:487)
             at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.setupEndpointFromAnnotations(AnnotationsMetaDataBuilder.java:154)
             at org.jboss.ws.metadata.AnnotationsMetaDataBuilderEJB3.buildMetaData(AnnotationsMetaDataBuilderEJB3.java:93)
             at org.jboss.ws.server.WebServiceDeployerEJB3.createWebServicesMetaData(WebServiceDeployerEJB3.java:91)
             at org.jboss.ws.server.WebServiceDeployer.create(WebServiceDeployer.java:103)
             at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
             at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
             at $Proxy29.create(Unknown Source)
             at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
             at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
             at $Proxy8.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:334)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:522)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:207)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:280)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
             at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:417)
             at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
             at $Proxy4.start(Unknown Source)
             at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:260)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
             at $Proxy5.deploy(Unknown Source)
             at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
             at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
             at org.jboss.Main.boot(Main.java:200)
             at org.jboss.Main$1.run(Main.java:464)
             at java.lang.Thread.run(Thread.java:595)
            


            Here is the simple web service I'm trying to deploy:

            import java.rmi.RemoteException;
            import javax.ejb.Remote;
            import javax.ejb.Stateless;
            import javax.jws.WebMethod;
            import javax.jws.WebService;
            
            @WebService(name = "EndpointInterface" ,
             targetNamespace = "http://localhost:8080",
             serviceName = "TestService")
            @Remote(TestEnumWS.class)
            @Stateless
            public class TestEnumWSEJB implements TestEnumWS {
            
             @WebMethod
             public TestStatus getUploadStatusRequest(String id)
             throws RemoteException {
             return TestStatus.COMPLETE;
             }
            }
            
            public enum TestStatus {
             COMPLETE("cpm"),
             WAITING("wng");
            
             private final String code;
             private TestStatus(String code){ this.code = code;}
             public String getValue(){ return code;}
            }
            


            Thanks for any help or pointers.

            -- AV

            • 4. Re: Java 1.5 enum in a web service
              Narasimha Goli Newbie

              We are also experiencing the same problem. Any help on this topic is really appreciated.