One obvious way would be of course to manually grab the ServletContext and get the Bean from it like: public ServletContext getServletContext() { MessageContext mc = MessageContext.getCurrentMessageContext(); return (ServletContext) mc.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT); }
and then you could do it like that: ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); FileProcessor fileProcessor = (FileProcessor) context.getBean("openmeetings.FileProcessor"); However this is neither fine and would require that we proxy all Web-Service Call into an internal Service that is spring aware instead of just injecting the Beans into the Axis2 Service Class. => so the bean DOES really exist, its just that Axis2 should: NOT startup Spring SHOULD find the Beans to generate the WSDL and service definitions. It seems to me a bit impossible right? We try to create a WSDL from a bean while Spring is not initialized but we don't want Axis to init Spring. ... but somehow isn't this the usual scenario? Sebastian 2011/8/21 seba.wag...@gmail.com <seba.wag...@gmail.com> > > 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 -- Sebastian Wagner http://www.webbase-design.de http://openmeetings.googlecode.com http://www.wagner-sebastian.com seba.wag...@gmail.com --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org For additional commands, e-mail: java-user-h...@axis.apache.org