Results 1 to 7 of 7

Thread: Annotation Configurations?

  1. #1
    Join Date
    Oct 2008
    Posts
    107

    Default Annotation Configurations?

    Hi,

    I am trying to use the @Endpoint and @PayloadRoot annotations and am having a bit of difficulty...

    I have a class that is annotated as follows:

    Code:
    @Endpoint
    public class ProfilerImpl implements Profiler {
    
    	private static Log log = LogFactory.getLog(Profiler.class);
    	
    	@Autowired private DirectoryService directoryService;
    	@Autowired private NetworkService networkService;
    	@Autowired private BillingService billingService;
    	
    	@PayloadRoot(localPart="getDirectoryProfile", namespace="http://www.company.com/profile")
    	public Profile getDirectoryProfile(Profile profile) {
    		...
    	}
    
    	@PayloadRoot(localPart="getNetworkProfile", namespace="http://www.company.com/profile")
    	public Profile getNetworkProfile(Profile profile) {
                   ...
    	}
    
    	@PayloadRoot(localPart="validateAccountAssociations", namespace="http://www.company.com/profile")
    	public Profile validateAccountAssociations(Profile profile) {
                    ...
    	}
    
    }
    my spring-ws-servlet.xml is set as follows:

    Code:
    	<bean id="profilerEndpoint" class="com.company.aggregate.profile.device.ProfilerImpl" />
    	
    	<bean id="endpointAdapter" class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
    		<constructor-arg ref="marshaller" />
    	</bean>
    	
    	<oxm:jibx-marshaller id="marshaller" target-class="com.company.aggregate.profile.device.Profile"/>
    	
    	<bean id="profileDevice" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
    		<property name="schemaCollection" ref="schemaCollection" />
    		<property name="portTypeName" value="ProfileDevice" />
    		<property name="locationUri" value="/services/" />
    		<property name="targetNamespace" value="http://www.company.com/information/services" />
    	</bean>
    	
    	<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
    		<property name="xsds">
    			<list>
    				<value>/WEB-INF/classes/values.xsd</value>
    				<value>/WEB-INF/classes/directory.xsd</value>
    				<value>/WEB-INF/classes/device.xsd</value>
    			</list>
    		</property>
    		<property name="inline" value="true" />
    	</bean>
    When the wsdl is produced, there are no operations...

    if I add the PayloadRootAnnotationMethodEndpointMapping to the above configuration:

    Code:
        <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"/>
    I get the following errors:

    Code:
    <Sep 22, 2009 4:06:50 PM GMT-05:00> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@25191a3 - appName: 'comcast-aggregate-profile-device', name: 'comcast-aggregate-profile-device-0.0.1-SNAPSHOT.war', context-path: '/comcast-aggregate-profile-device', spec-version: '2.5', request: weblogic.servlet.internal.ServletRequestImpl@2bc543c[
    GET /comcast-aggregate-profile-device/services/profileDevice.wsdl HTTP/1.1
    User-Agent: Jakarta Commons-HttpClient/3.0.1
    
    ]] Root cause of ServletException.
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping#0' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.context.ApplicationContextException: Cannot map endpoint [public com.comcast.aggregate.profile.device.Profile com.comcast.aggregate.profile.device.ProfilerImpl.getDirectoryProfile(com.comcast.aggregate.profile.device.Profile)] on registration key [{http://www.comcast.com/profile}getDirectoryProfile]: there's already endpoint [public com.comcast.aggregate.profile.device.Profile com.comcast.aggregate.profile.device.ProfilerImpl.getDirectoryProfile(com.comcast.aggregate.profile.device.Profile)] mapped
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            Truncated. see log file for complete stacktrace
    org.springframework.context.ApplicationContextException: Cannot map endpoint [public com.comcast.aggregate.profile.device.Profile com.comcast.aggregate.profile.device.ProfilerImpl.getDirectoryProfile(com.comcast.aggregate.profile.device.Profile)] on registration key [{http://www.comcast.com/profile}getDirectoryProfile]: there's already endpoint [public com.comcast.aggregate.profile.device.Profile com.comcast.aggregate.profile.device.ProfilerImpl.getDirectoryProfile(com.comcast.aggregate.profile.device.Profile)] mapped
            at org.springframework.ws.server.endpoint.mapping.AbstractMethodEndpointMapping.registerEndpoint(AbstractMethodEndpointMapping.java:93)
            at org.springframework.ws.server.endpoint.mapping.AbstractMethodEndpointMapping$2.doWith(AbstractMethodEndpointMapping.java:141)
            at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:466)
            at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:443)
            at org.springframework.ws.server.endpoint.mapping.AbstractMethodEndpointMapping.registerMethods(AbstractMethodEndpointMapping.java:136)
            Truncated. see log file for complete stacktrace
    >

    I tried removing the <context:annotation-config /> declaration but that did not seem to correct the issue? What is the correct way to establish the endpoint mapping when using annotation configuration?

    Thanks.

    Keith

  2. #2
    Join Date
    Sep 2009
    Posts
    1

    Default

    Hi,

    try commenting the following

    <context:component-scan base-package ....

  3. #3
    Join Date
    Oct 2008
    Posts
    107

    Default

    I actually have one of those declared already... I just didn't include that statement in my post (why? i don't know). Maybe that is why I am getting the duplicate endpoints?

    If that is the case... then I think I am still missing something because I do not get operations declarations in the WSDL when the PayloadRootAnnotationMethodEndpointMapping is not declared. (Since I get the duplicate exception... I can't actually verify is this declaration is fixing the problem however. Is it required with the component-scan and annotation-config declarations?)

    Thanks.

    Keith

  4. #4
    Join Date
    Oct 2008
    Posts
    107

    Default

    Grrr... I figured out that I was not getting the operations to populate because I am using the DefaultWsdl11Definition which sources the SuffixBasedPortTypesProvider to create the operations declarations and I did not have a wrapper around my classes with the operation name ending in request/response. However, now I added that and am getting HTTP 404 - Not Found errors...

    Code:
    2009-09-24 16:48:43,267 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN  org.springframework.ws.server.EndpointNotFound  No endpoint mapping found for [SaajSoapMessage {http://www.company.com/services}getDirectoryProfileRequest]
    The message appears to come through with the request message name set as the localPart. Unfortunately, when I update my code and set the localPart accordingly, the mapping is still not found:

    Code:
    @PayloadRoot(localPart="getDirectoryProfileRequest", namespace="http://www.company.com/services")
    Code:
    2009-09-24 16:53:28,818 [[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN  org.springframework.ws.server.EndpointNotFound  No endpoint mapping found for [SaajSoapMessage {http://www.company.com/services}getDirectoryProfileRequest]
    Am I missing a component?

    Thanks.

    Keith

  5. #5
    Join Date
    Oct 2008
    Posts
    107

    Default

    This is my current config:

    Code:
    	<context:annotation-config />
    	<context:component-scan base-package="com.company" />
    	
    	<import resource="classpath*:serviceContext.xml" />
    	
    	<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
    		<constructor-arg ref="marshaller" />
    	</bean>
    	
    	<oxm:jaxb2-marshaller id="marshaller">
    		<oxm:class-to-be-bound name="com.company.task.dupmac.Duplication" />
    		<oxm:class-to-be-bound name="com.company.task.dupmac.Profile" />
    	</oxm:jaxb2-marshaller>
    	
    	<bean id="profileDevice" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
    		<property name="schemaCollection" ref="schemaCollection" />
    		<property name="portTypeName" value="ProfileDevice" />
    		<property name="locationUri" value="/services/" />
    		<property name="targetNamespace" value="http://www.company.com/information/services" />
    	</bean>
    	
    	<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
    		<property name="xsds">
    			<list>
    				<value>/WEB-INF/xsd/wrapper.xsd</value>
    			</list>
    		</property>
    		<property name="inline" value="true" />
    	</bean>
    Thanks.

    Keith

  6. #6
    Join Date
    Oct 2008
    Posts
    107

    Default

    Ok... I was missing the PayloadRootAnnotationMethodEndpointMapping declaration (which is required even with annotation config, I see)... however, now I am getting:

    Code:
    2009-09-24 18:44:35,918 [[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.springframework.ws.soap.server.SoapMessageDispatcher  Endpoint invocation resulted in exception - responding with Fault
    java.lang.IllegalStateException: No adapter for endpoint [public com.company.task.dupmac.Profile com.company.task.dupmac.ProfilerImpl.getDirectoryProfile(com.company.task.dupmac.request.DirectoryProfileRequest)]: 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)
            at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
            at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
            at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
            at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
            at weblogic.security.service.SecurityManager.runAs(Unknown Source)
            at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
            at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
            at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
            at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
            at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    2009-09-24 18:44:35,921 [[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG org.springframework.ws.server.MessageTracing.sent  Sent response [SaajSoapMessage {http://schemas.xmlsoap.org/soap/envelope/}Fault] for request [SaajSoapMessage {http://www.company.com/services}directoryProfileRequest]
    I do have the GenericMarshallingMethodEndpointAdapter declared... is there some way that I need to associate it to the class?

    The example doesn't seem to show any interfaces or classes being extended:

    http://static.springsource.org/sprin...er-at-endpoint

    Thanks.

    Keith

  7. #7
    Join Date
    Oct 2008
    Posts
    107

    Default Case Closed.

    A few glitches along the way... ultimately I had a missing @XmlRootElement definition in my return object. It was a little tricky to debug - I had to trace through the code to figure out why the marshaller was claiming it was unsupported - but I found it.

    Just wanted to say - well done on the framework... very nice indeed!

    Thanks.

    Keith

Posting Permissions

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