Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Spring and JAXWS: No mixing of @Webmethod and @Transactional Annotations allowed

  1. #11
    Join Date
    Jul 2007
    Posts
    2

    Default

    Breaking up the annotations worked for me with a relatively simple web service. I imagine this would be unwieldy with a big project though.

    Take the following interface:

    Code:
    public interface ICalculator {
    
    	int add(int a, int b);
    }
    Implement it using declarative transactions:

    Code:
    public class CalculatorImpl implements ICalculator {
    
    	@Transactional
    	public int add(int a, int b) {
    		//do some database stuff requiring the transaction
    		return a + b;
    	}
    }
    Create the web service implementation you want to expose and use Spring to inject CalculatorImpl:

    Code:
    @WebService
    public class CalculatorService implements ICalculator {
    	private ICalculator impl; 
    	
    	public void setICalculator(ICalculator impl) {
    		this.impl = impl;
    	}
    
    	@WebMethod
    	public int add(int a, int b) {
    		return impl.add(a, b);
    	}
    }

  2. #12

    Default

    The solution is given here (add impl to service declaration):

    Code:
    <wss:binding url="/services/greeterService">
       <wss:service>
          <ws:service bean="#greeter" impl="org.codehut.Greeter" />
       </wss:service>
    </wss:binding>

  3. #13
    Join Date
    Dec 2009
    Posts
    1

    Default Using SimpleJaxWsServiceExporter and AOP...

    I am exposing my standalone web service using org.springframework.remoting.jaxws.SimpleJaxWsServ iceExporter . I am running into the same issue: class $Proxy11 has neither @WebSerivce nor @WebServiceProvider annotation

    Any ideas how I can resolve this?

  4. #14
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    I guess that switching to AspectJ LTW (from proxy-based AOP) would solve your problem.

  5. #15
    Join Date
    Feb 2013
    Posts
    3

    Default

    I have the same problem and got class $Proxy45 has neither @WebSerivce nor @WebServiceProvider annotation
    I break up the annotations followed the example by eldaaran. My config file is as following:

    <bean id="psecService" class="com.pyramis.security.service.PSECServicesBe an" init-method="init" destroy-method="destroy">
    </bean>
    <wss:binding url="/services/FSECWebService">
    <wss:service>
    <ws:service bean="#FSECWebService" />
    </wss:service>
    </wss:binding>
    <bean id="FSECWebService" class="fmtc.security.ws.FSECWebService" init-method="init" destroy-method="destroy">
    <property name="psecService" ref="psecService" />
    </bean>

    Here is the exception I got:
    Feb 3, 2013 10:14:26 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBindi ng' defined in file [C:\Apps\workspace\.metadata\.plugins\org.eclipse.w st.server.core\tmp0\wtpwebapps\PSecServiceWeb\WEB-INF\classes\spring\serviceContext.xml]: Cannot create inner bean '(inner bean)' while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)#1': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: class $Proxy45 has neither @WebSerivce nor @WebServiceProvider annotation
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)#1': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: class $Proxy45 has neither @WebSerivce nor @WebServiceProvider annotation
    Caused by: java.lang.IllegalArgumentException: class $Proxy45 has neither @WebSerivce nor @WebServiceProvider annotation
    at com.sun.xml.ws.server.EndpointFactory.verifyImplem entorClass(EndpointFactory.java:287)
    at org.jvnet.jax_ws_commons.spring.SpringService.getO bject(SpringService.java:317)
    at org.jvnet.jax_ws_commons.spring.SpringService.getO bject(SpringService.java:45)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getObjectFromFactoryBean(AbstractBeanF actory.java:994)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getObjectForBeanInstance(AbstractBeanF actory.java:960)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveInnerBeanDefinition(Bea nDefinitionValueResolver.java:202)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:116)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:955)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:729)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:416)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:290)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:348)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:156)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:246)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:184)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:525)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:414)
    Feb 3, 2013 10:14:26 PM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart

    Any help will be appreciated.

  6. #16

    Default

    Aiming, unfortunately you will have to split your transactional bean from web bean and use dependency injection as eldaaran suggested above.

  7. #17
    Join Date
    Feb 2013
    Posts
    3

    Default

    dma_k, After I add impl="fmtc.security.ws.FSECWebService" suggested by you, I no longer get java.lang.IllegalArgumentException: class $Proxy45 has neither @WebSerivce nor @WebServiceProvider annotation and can start the web service.
    <wss:binding url="/services/FSECWebService">
    <wss:service>
    <ws:service bean="#FSECWebService" impl="fmtc.security.ws.FSECWebService" />
    </wss:service>
    </wss:binding>

    But when I test the service, I got a new exception. any solution for this issue?

    Feb 5, 2013 6:18:29 PM com.sun.xml.ws.server.sei.EndpointMethodHandler invoke
    SEVERE: object is not an instance of declaring class
    java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.xml.ws.api.server.InstanceResolver$1.invok e(InstanceResolver.java:197)
    at com.sun.xml.ws.server.InvokerTube$2.invoke(Invoker Tube.java:132)
    at com.sun.xml.ws.server.sei.EndpointMethodHandler.in voke(EndpointMethodHandler.java:241)
    at com.sun.xml.ws.server.sei.SEIInvokerTube.processRe quest(SEIInvokerTube.java:75)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:5 59)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:51 8)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503 )

  8. #18

    Default

    I haven't suggested to add impl="fmtc.security.ws.FSECWebService". I have suggested to separate you transactional code into a new separate bean, so that you FSECWebService does not have @Transactional annotation. Then you can wire your new transactional bean into FSECWebService in usual way. The example is given by eldaaran above.

Posting Permissions

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