Results 1 to 7 of 7

Thread: java.lang.IllegalStateException: No adapter for endpoint and Jaxb2 Marshallers

  1. #1
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default java.lang.IllegalStateException: No adapter for endpoint and Jaxb2 Marshallers

    Hi all.

    I've been getting the dreaded java.lang.IllegalStateExceptions with an endpoint that uses Jaxb2 to marshal. (As seen in Airline Service)

    Now, the classes that that represent the incoming messages are generated with xjc, and I've checked that the they do in fact contain the @XmlRootElement annotation as mentioned in another thread.

    I've also tried using JAXBElement<> in the method signature, but it still doesn't work.

    Any suggestions on what to try next?

  2. #2

    Default

    Could you please post the full stack trace and any useful code snippets?
    Tareq Abedrabbo

    My Twitter
    My Blog

  3. #3
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default

    Here's the last bits from the log when it fails:

    Code:
    DEBUG RMICallHandler-58 org.springframework.ws.soap.server.SoapMessageDispatcher - Endpoint invocation resulted in exception - responding with Fault
    java.lang.IllegalStateException: No adapter for endpoint [public void service.ws.MarshallingSanctionEndpoint.applySanction(service.schema.Apply) throws javax.xml.datatype.DatatypeConfigurationException]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?
    	at org.springframework.ws.server.MessageDispatcher.getEndpointAdapter(MessageDispatcher.java:279)
    	at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:220)
    	at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:168)
    and the endpoint:
    Code:
    @Endpoint
    public class MarshallingSanctionEndpoint implements WebServiceConstants {
    	
    	@PayloadRoot(localPart = "Apply", namespace="...")
    	public void applySanction(Apply request) throws DatatypeConfigurationException{
    		// Do stuff...
    	}
    }
    And here's how it's wired up:
    Code:
    <bean id="marshallingEndpoint" class="service.ws.MarshallingSanctionEndpoint" />
    Code:
    <bean id="annotationMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
    		  <property name="interceptors">
    			<list>
    				<bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor" />
    				<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
    				<bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    					<property name="xsdSchemaCollection" ref="schemaCollection" />
    					<property name="validateRequest" value="true" />
    					<property name="validateResponse" value="true" />
    				</bean>
    			</list>
    		</property>
    		<property name="order" value="1" />
    	</bean>
    
    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="contextPath" value="service.schema" />
    	</bean>

  4. #4

    Default

    From your config, I think an endpoint adapter is missing. When you use marshallers with @Endpoint you should include a similar bean definition in your config:
    Code:
    <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
        <constructor-arg ref="marshaller"/>
    </bean>
    You could find more details in this section in the reference doc.
    Tareq Abedrabbo

    My Twitter
    My Blog

  5. #5
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default

    Aha! That did the trick.

    Thank you very much.

    I must have overlooked the role of GenericMarshallingMethodEndpointAdapter's when I worked thru the example.

    I was wondering how an @Endpoint knew how to unmarshal, when it wasn't assigned a marshaller, and now I know.

    Thanks again.

  6. #6
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    97

    Default

    And because I got bitten on the arse again, this can also be caused by not declaring all contextPaths in your org.springframework.oxm.jaxb.Jaxb2Marshaller.

  7. #7

    Lightbulb Does your endpoint implement a supported interface like MessageHandle

    It is XSD related issue, you need to correct your XSD. Generally when you are playing with JAXB, this problem will occur , you must need to define request and response correctly.

    This issue is resolved. For example if your input request element is 'InsertRequest' so need to define like

    <xs:element name="InsertRequest">
    <xs:annotation>
    <xs:documentation>Root element for Record Insert Request</xs:documentation>
    </xs:annotation>
    <xs:complexType>
    <xs:sequence>
    <xs:element name="GeneralDetails" type="tns:GenralDetailsType"></xs:element>
    <xs:element name="FullDetails" type="tns:FullDetailsType"></xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    ---------------
    Previously i was defined this as mention below:- so when i am creating JAXB beans it always create two elements for this, which element (InsertRequest or InsertRequestType) need to refer in endpoint, this was the issue.

    <element name="InsertRequest" type="tns:InsertRequestType"></element>


    <complexType name="InsertRequestType">
    <sequence>
    <element name="GeneralDetails" type="tns:GenralDetailsType"></element>
    <element name="FullDetails" type="tns:FullDetailsType"></element>
    </sequence>
    </complexType>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •