Announcement Announcement Module
Collapse
No announcement yet.
Unable to load context from WebService Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to load context from WebService

    Hi.

    My webservice server class, DARTSoapBindingImpl, needs a bean called ServiceRequestPlugin that is managed by Spring. Searching the forum I found the commom solution to create an BeanFactory that implements ApplicationContextAware and that is what I did.

    Code:
    public class BeanFactory implements ApplicationContextAware {
    
    	private static ApplicationContext ctx;
    	
    	public void setApplicationContext(ApplicationContext ctx)
    			throws BeansException {
    		
    		this.ctx = ctx;
    
    	}
    	
    	public static ServiceRequestPlugin getServiceRequestPlugin(){
    		return (ServiceRequestPlugin)ctx.getBean("serviceRequestPlugin");
    	}
    
    }
    And then on my xml I registered the factory (package name removed for simplicity):

    Code:
    	<bean name="beanFactory" class="com.....BeanFactory">
    	</bean>

    Then, on my webservice class which is managed by AXIS 1.4, I request the bean using:

    Code:
    ServiceRequestPlugin serviceRequestPlugin = BeanFactory.getServiceRequestPlugin();
    But, this throws a NullPointerException because inside the getServiceRequestPlugin method, the context ctx is null.

    I am sure that Spring is injecting the context because I set a breakpoint in the setApplicationContext method, and when starting Tomcat the eclipse debugger shows me that ctx has a value.

    So, it is like axis has a different instance of the beanFactory than Tomcat/Spring have.

    I don't know how or if it is even possible to inject this class into my webservice because axis and spring are not (yet) integrated, so how can I possible retrieve this bean from spring?

    Additional info, everything is under the same web app. Instead of having axis as a different webapp, I put all axis jar files and web.xml entries into my webapp.

    Any help is much appreciated.

    Thank you very much,

    Rafael

  • #2
    ok, someone here helped me to fix this. The webservices were deployed in a different context than my webapp. Since we use liferay as a portal framework I got confused with the URLs.

    Thanks

    Comment

    Working...
    X