Hi,

we are trying to inject Spring Services into an Axis2 Service Class.
Unfortunately the Spring application Context is loaded AFTER Webapp
initializes the Axis2 Servlet.

My first approach was to use a SpringInit-Java Class that gets the
application-Context:
http://code.google.com/p/openmeetings/source/browse/branches/dev/injection/src/userservice/org/openmeetings/axis/services/SpringInit.java

and in the services.xml I defined the initialization like that:
<service name="SpringInit"
class="org.openmeetings.axis.services.SpringInit">
    <description>Init Spring Framework</description>
    <parameter
name="ServiceClass">org.openmeetings.axis.services.SpringInit</parameter>
    <parameter name="ServiceTCCL">composite</parameter>
    <parameter name="load-on-startup">true</parameter>
    <operation name="springInit">
      <messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    </operation>
  </service>

=> The problem is: Spring initializes *TWO TIMES*:
1) When my Axis2 SpringInit class initializes, it loads the
applicationContext
2) When the Serlvet Container also has a hook (that one I cannot change)
that loads the webapp.

2. Approache without the SpringInit in the services.xml
If I simply do specify a service like that:
  <service name="UserService" >
    <description>User Service</description>
    <parameter name="ServiceObjectSupplier"
locked="false">org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier</parameter>
    <parameter name="SpringBeanName"
locked="false">userServiceSoap</parameter>
    <messageReceivers>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-only";

class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-out";
            class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass"
locked="xsd:false">org.openmeetings.axis.services.UserService</parameter>
  </service>

Source code of Service.xml:
http://code.google.com/p/openmeetings/source/browse/branches/dev/injection/src/META-INF/services.xml

WITHOUT loading additionally with SpringInit I do get: UserService?WSDL =>
is generated fine.
BUT when I do invoek any method in the Service I do get an exception:
*Axis2 Can't find Spring's ApplicationContext*

Who can help me with that?
Is there a way to initialize the SpringInit AFTER the webapp is loaded
somehow? I mean I cannot be the only person that has a Spring aware
Web-Application and simply want's to inject the SpringBeans into Axis2 but
WITHOUT Axis2 actually STARTING Spring cause Spring is already loaded via
the Web-Container.


Thanks a lot
Sebastian Wagner

-- 
Sebastian Wagner
http://www.webbase-design.de
http://openmeetings.googlecode.com
http://www.wagner-sebastian.com
seba.wag...@gmail.com

Reply via email to