Announcement Announcement Module
Collapse
No announcement yet.
Spring and Websphere CE context and web service integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring and Websphere CE context and web service integration

    Hello,

    I am trying to expose one of my Spring webapp Pojo as a WebService under WebSphere CE 2.1 (based on Geronimo). I want to use Spring's autowiring in this Pojo.
    I did as follow :

    Pojo =

    Code:
    @WebService(serviceName="MyPojoWS")
    public class MyPojo extends SpringBeanAutowiringSupport {
    
     @Autowired
     MyInterface myInterface = null;
    
     public void myWebMethod() {
         myInterface.doSmthg();
     }
    }
    Spring configuration :
    My whole webapp share the same Spring "application context" configured with the ContextLoaderListener.
    I did not forget to scan the package containing MyPojo.
    Was CE configuration
    I did not forget to declare within web.xml my web service as a servlet.

    At deploy time, my WebService is instantiated twice : once from a org.apache.geronimo.axis2.pojo.POJOWebService, with no current web application context (and so myInterface == null), and a second time from org.apache.geronimo.webservices.POJOWebServiceServ let.init, with the correct application context (myInterface gets instantiated).

    First :
    Code:
    	at mytest.MyPojo.<init>(MyPojo.java:36)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at org.apache.xbean.recipe.ReflectionUtil$ConstructorFactory.create(ReflectionUtil.java:882)
    	at org.apache.xbean.recipe.ObjectRecipe.internalCreate(ObjectRecipe.java:272)
    	at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:96)
    	at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:61)
    	at org.apache.geronimo.j2ee.annotation.Holder.newInstance(Holder.java:173)
    	at org.apache.geronimo.jaxws.annotations.AnnotationHolder.newInstance(AnnotationHolder.java:39)
    	at org.apache.geronimo.axis2.pojo.POJOWebServiceContainer.init(POJOWebServiceContainer.java:82)
    	at org.apache.geronimo.axis2.pojo.POJOWebServiceContainerFactoryGBean.getWebServiceContainer(POJOWebServiceContainerFactoryGBean.java:94)
    	at org.apache.geronimo.tomcat.TomcatWebAppContext.createWebServices(TomcatWebAppContext.java:281)
    	at org.apache.geronimo.tomcat.TomcatWebAppContext.<init>(TomcatWebAppContext.java:255)
    Second :
    Code:
    	at mytest.MyPojo.<init>(MyPojo.java:36)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at java.lang.Class.newInstance0(Class.java:355)
    	at java.lang.Class.newInstance(Class.java:308)
    	at org.apache.geronimo.webservices.POJOWebServiceServlet.init(POJOWebServiceServlet.java:60)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1064)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4051)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
    	at org.apache.geronimo.tomcat.GeronimoStandardContext.access$201(GeronimoStandardContext.java:63)
    	at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:398)
    	at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
    	at org.apache.geronimo.tomcat.GeronimoStandardContext.start(GeronimoStandardContext.java:251)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    	at org.apache.geronimo.tomcat.TomcatContainer.addContext(TomcatContainer.java:364)
    	at org.apache.geronimo.tomcat.TomcatWebAppContext.doStart(TomcatWebAppContext.java:512)
    As I test my WS with an external client, I always hit the first WebService instance (myInterface == null).

    When I withdraw my web.xml geronimo web service specific declaration, the first web service is still instantiated, not the second (too bad for me).

    When I withdraw only SpringBeanAutowiringSupport, I don't see any differences : the autowiring works fine in the second instantiation of the web service... but still is useless as I can't reach it...

    Any help would be appreciated !
    JavaPelp
Working...
X