facebook

NullpointerEx. during client generation

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #263860 Reply

    Bumbes
    Member

    Hi,

    as long as I want to throw a CustomException within my service I receive an error during client generation:

    !ENTRY com.genuitec.eclipse.ws.xfire 4 0 2006-12-23 10:56:08.125
    !MESSAGE Error generating services
    !STACK 0
    java.lang.NullPointerException
        at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.getExceptionClass(AbstractServiceGenerator.java:279)
        at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generateFaults(AbstractServiceGenerator.java:264)
        at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generateOperation(AbstractServiceGenerator.java:229)
        at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generate(AbstractServiceGenerator.java:110)
        at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generate(AbstractServiceGenerator.java:62)
        at org.codehaus.xfire.gen.jsr181.ServiceInterfaceGenerator.generate(ServiceInterfaceGenerator.java:48)
        at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generate(AbstractServiceGenerator.java:49)
        at org.codehaus.xfire.gen.Wsdl11Generator.generate(Wsdl11Generator.java:132)
        at com.genuitec.eclipse.ws.xfire.generator.WSGenJob.run(WSGenJob.java:92)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

    Even extending XFireFault or FaultInfoException does not work. I just had a look inside the AbstractServiceGenerator’s getExceptionClass method:

    private JClass getExceptionClass(GenerationContext context, FaultInfo faultInfo)
        {
            Map<String,JClass> exClasses = (Map<String,JClass>) 
                context.getProperty(FaultGenerator.EXCEPTION_CLASSES);
            
            return exClasses.get(faultInfo.getMessageName());
        }

    so I guess I somehow miss sth. within my exception. Any Ideas where I am wrong?

    Best regards,
    Patrick

    #263867 Reply

    Brian Fernandes
    Moderator

    Patrick,

    I assume you’re developing your service bottom up (starting with POJOs?) – could you paste the relevant POJOs here or email them to support@genuitec.com ATTN Brian? If you’re developing your services starting from a WSDL file, can you send us that instead?

    If you do not throw this exception – does the client generation work as expected?

    #263868 Reply

    Bumbes
    Member

    Hi Brian,

    the error only occurs if I throw my own CustomException. As long as I throw java.lang.Exception everything works fine. I cropped everything but one method off the Interface and Implementation class (you’re right I’m using the bottom-up approach).

    public interface UtilityServiceInterface {
    public String generateKey(ClientCredentials credentials) throws ServiceException;
    }

    as long as a ServiceException is thrown, client generation fails with above exception. (While the service itself seems to work)

    The exception looks like this, so nothing magic happens here:

    
    public class ServiceException extends XFireFault  {
    
    
        public ServiceException() {
            super();
        }
        
        public ServiceException(Throwable cause) {
            super(cause);
        }
        
        public ServiceException(String message) {
            super(message, new QName(null, "Server.ServiceException"));
            
        }
        
        public ServiceException(String message, int key) {
            super(key + ": " + message, new QName(null, "Server.ServiceException"));
        }
    }

    The XFIRE generated WSDL contains some strange reference for ServiceException:

    <xsd:complexType name="ServiceException">
    <xsd:sequence>
    <xsd:element minOccurs="0" name="detail" nillable="true" type="xsd:anyType"/>
    <xsd:element minOccurs="0" name="faultCode" nillable="true" type="ns2:QName"/>
    <xsd:element minOccurs="0" name="message" nillable="true" type="xsd:string"/>
    <xsd:element minOccurs="0" name="namespaces" nillable="true" type="tns:anyType2anyType2anyTypeMapMap"/>
    <xsd:element minOccurs="0" name="reason" nillable="true" type="xsd:string"/>
    <xsd:element minOccurs="0" name="role" nillable="true" type="xsd:string"/>
    <xsd:element minOccurs="0" name="subCode" nillable="true" type="ns2:QName"/>
    </xsd:sequence>
    </xsd:complexType>

    With tns:anyType2anyType2anyTypeMapMap defined as:

    <xsd:complexType name="anyType2anyType2anyTypeMapMap">
    <xsd:sequence>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="entry">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs="1" minOccurs="0" name="key" type="xsd:anyType"/>
    <xsd:element maxOccurs="1" minOccurs="0" name="value" type="tns:anyType2anyTypeMap"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="anyType2anyTypeMap">
    <xsd:sequence>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="entry">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs="1" minOccurs="0" name="key" type="xsd:anyType"/>
    <xsd:element maxOccurs="1" minOccurs="0" name="value" type="xsd:anyType"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>

    Maybe that gives a clue about whats wrong with my code. If custom exceptions are not intended to be used during the generation process, I can live with that. I simply liked the idea about custom faults by simply using typed Exceptions.

    Thanks in advance (and thanks for myEclipse)

    Patrick

    #265505 Reply

    waterdata1
    Member

    I am experiencing a similar problem. I too am using a web service that throws a custom exception (although let’s not assume that is actually the problem). A web service client proxy is generated with noproblems using WTP-1.5, NetBeans-5.5, Microsoft C# 2005, etc. Can you please advise what might be causeing this problem? Thanks — David Coyle, US Geological Survey, dlcoyle@usgs.gov

    Here is a snippet from the MyEclipse-5.5M1 workspace log file:

    !ENTRY org.eclipse.wst.internet.cache 1 0 2007-02-02 00:17:25.137
    !MESSAGE wtp.autotest.noninteractive is set. Licenses dialogs will not be displayed.

    !ENTRY com.genuitec.eclipse.ws.xfire 4 0 2007-02-02 00:17:57.263
    !MESSAGE Error generating services
    !STACK 0
    java.lang.NullPointerException
    at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.getExceptionClass(AbstractServiceGenerator.java:294)
    at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generateFaults(AbstractServiceGenerator.java:273)
    at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generateOperation(AbstractServiceGenerator.java:238)
    at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generate(AbstractServiceGenerator.java:119)
    at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generate(AbstractServiceGenerator.java:63)
    at org.codehaus.xfire.gen.jsr181.ServiceInterfaceGenerator.generate(ServiceInterfaceGenerator.java:48)
    at org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.generate(AbstractServiceGenerator.java:50)
    at org.codehaus.xfire.gen.Wsdl11Generator.generate(Wsdl11Generator.java:164)
    at com.genuitec.eclipse.ws.xfire.generator.WSGenJob.run(WSGenJob.java:209)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: NullpointerEx. during client generation

You must be logged in to post in the forum log in