4 Replies Latest reply on Feb 14, 2007 4:33 PM by Thomas Diesler

    enumerations in jboss ws...

    Michael Wiles Newbie

      I have an xsd which has an enumeration type:

      <xsd:simpleType name="IncomeTypeEnum">
      <xsd:restriction base="xsd:string">
      <xsd:enumeration value="pension" id="pension"/>
      <xsd:enumeration value="salary" />
      </xsd:restriction>
      </xsd:simpleType>

      The mapping snippet for that enum looks like this:

      <java-xml-type-mapping>
      <java-type>za.co.sanlam.employeebenefits.IncomeTypeEnum</java-type>
      <root-type-qname xmlns:rtq="http://sanlam.co.za/employeebenefits/dto/1">rtq:IncomeTypeEnum</root-type-qname>
      <qname-scope>simpleType</qname-scope>
      <variable-mapping>
      <java-variable-name>pension</java-variable-name>
      <xml-element-name>pension</xml-element-name>
      </variable-mapping>
      <variable-mapping>
      <java-variable-name>salary</java-variable-name>
      <xml-element-name>salary</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>

      But when I deploy the web service I get the following error:

      19:10:45,359 ERROR [MainDeployer] Could not start deployment: file:/C:/usr/jboss-4.0.5.GA/server/default/tmp/deploy/tmp50100EAR.ear-contents/EJB.jar
      org.jboss.ws.WSException: Attribute pension found in jaxrpc-mapping but not in the schema: {http://sanlam.co.za/employeebenefits/dto/1}IncomeTypeEnum
      at org.jboss.ws.jaxb.SchemaBindingBuilder.processXmlAttributeName(SchemaBindingBuilder.java:260)
      at org.jboss.ws.jaxb.SchemaBindingBuilder.processNonArrayType(SchemaBindingBuilder.java:207)
      at org.jboss.ws.jaxb.SchemaBindingBuilder.processJavaXmlTypeMapping(SchemaBindingBuilder.java:147)
      at org.jboss.ws.jaxb.SchemaBindingBuilder.bindSchemaToJava(SchemaBindingBuilder.java:119)
      at org.jboss.ws.jaxb.SchemaBindingBuilder.buildSchemaBinding(SchemaBindingBuilder.java:99)
      at org.jboss.ws.metadata.ServiceMetaData.getSchemaBinding(ServiceMetaData.java:332)
      at org.jboss.ws.metadata.ServiceMetaData.eagerInitialize(ServiceMetaData.java:400)
      at org.jboss.ws.metadata.UnifiedMetaData.eagerInitialize(UnifiedMetaData.java:147)
      at org.jboss.ws.server.ServiceEndpoint.start(ServiceEndpoint.java:106)
      at org.jboss.ws.server.ServiceEndpointManager.startServiceEndpoint(ServiceEndpointManager.java:529)
      at org.jboss.ws.deployment.ServiceEndpointDeployer.start(ServiceEndpointDeployer.java:144)
      at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:104)
      at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
      at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.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)

      Has anyone done enumerations with jboss and could shed some light on what is going on? I

      The java code for the enumration is as follows...

      It does not seem as this is the problem as if I remove the java class, the error persists.

      public class IncomeTypeEnum {
      private java.lang.String _value_;
      private static java.util.HashMap _table_ = new java.util.HashMap();

      // Constructor
      protected IncomeTypeEnum(java.lang.String value) {
      _value_ = value;
      _table_.put(_value_,this);
      };

      public static final java.lang.String _pension = "pension";
      public static final java.lang.String _salary = "salary";
      public static final IncomeTypeEnum pension = new IncomeTypeEnum(_pension);
      public static final IncomeTypeEnum salary = new IncomeTypeEnum(_salary);
      public java.lang.String getValue() { return _value_;}
      public static IncomeTypeEnum fromValue(java.lang.String value)
      throws java.lang.IllegalArgumentException {
      IncomeTypeEnum enum = (IncomeTypeEnum)
      _table_.get(value);
      if (enum==null) throw new java.lang.IllegalArgumentException();
      return enum;
      }
      public static IncomeTypeEnum fromString(java.lang.String value)
      throws java.lang.IllegalArgumentException {
      return fromValue(value);
      }
      public boolean equals(java.lang.Object obj) {return (obj == this);}
      public int hashCode() { return toString().hashCode();}
      public java.lang.String toString() { return _value_;}

      }

      I've tried everything to find the answer to my problem but just can't get anything. Hopefully it's quite a simple solution.

      Michael Wiles
      Java Developer

        • 1. Re: enumerations in jboss ws...
          Tejas Jani Newbie

          I am having the same issue. I am not sure what to modify in the mapping file, once I have written the additional type classes for all enum types.

          Any help is highly appreciated.

          thanks

          • 2. Re: enumerations in jboss ws...
            Michael Wiles Newbie

            It's like when you're trying to break into a house - you assume the door is locked and can't figure out why you can't open it!

            Well turns out that all that mapping stuff for the enum is surplus to requirements as far as jboss is concerned. You just remove it and it works fine!

            <java-xml-type-mapping>
             <java-type>za.co.sanlam.employeebenefits.IncomeTypeEnum</java-type>
             <root-type-qname xmlns:rtq="http://sanlam.co.za/employeebenefits/dto/1">rtq:IncomeTypeEnum</root-type-qname>
             <qname-scope>simpleType</qname-scope>
             <variable-mapping>
             <java-variable-name>pension</java-variable-name>
             <xml-element-name>pension</xml-element-name>
             </variable-mapping>
             <variable-mapping>
             <java-variable-name>salary</java-variable-name>
             <xml-element-name>salary</xml-element-name>
             </variable-mapping>
             </java-xml-type-mapping>
            


            I took a simple remote interface which took as a parameter an object following the enum pattern and generated the wsdl and mapping file with jboss and no mappings for the values in the enumeration were generated.

            The lines in red above are not necessary in jboss, and it uses the fromValue method to resolve the enum data type. Very impressive.

            What I didn't mention is that the jaxrpc mapping file was generated by wsdl2java from WAS which generates mapping files which have this stuff included. I'm not so sure why it even bothers as that information is available from the wsdl. I removed the mapping and tested my simple web service and it behaved just fine.


            • 3. Re: enumerations in jboss ws...
              Tejas Jani Newbie

              Interesting....

              Here is what I have...

              (1) I have written a enum type class PromotionDetailType using the enum pattern, one of the enum values is 'Ad'

              (2) There is another class PromotionDetail where this enum class is being referenced and there are getters and setters for getting/setting the enum values such as

              public void setDetailSubType(PerformanceDetailType detailType)
               { this.detailType=detailType; }
              
               public PerformanceDetailType getDetailType() { return detailType ;}
              

              (3) Now I try to send a SOAP request with the following in the client
               <PromotionDetail>
               <PerformanceDetailType>Ad</PerformanceDetailType>
               </PromotionDetail>
              


              This gives me the following error:

              Caused by: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Failed
              o set value 'Ad' for property 'detailType' defined in com.demandtec.webservices.heb.PromotionDetail@1e3f2e5 on instance
              com.demandtec.webservices.heb.PromotionDetail@1e3f2e5
              


              I dont have any mappings defined for the enum classes in the mapping file.

              Any hints would be highly appreciated.

              thanks