Back Forum Reply New

Spring Web Services in OSGI

.fromserver package is not visible in the OSGI environment

2) Deploy as a WAR file in OSGI. Since I'm not deploying Java code packaging up as a WAR may be overkill. So I'm trying to find options that avoid the need for a web.xml.

3) Write an extension to Spring WS similar to the embedded from server that allows registering with an OSGI fromService.

4) Similar to (1) and (3) but use embedded Jetty instead of an OSGI service reference.

Has anyone done this - any help appreciated

Thanks

Dave

What I have done for now is extend the MessageDisspatcherServlet like this:Code:
public class OsgiMessageDispatcherServlet extends MessageDispatcherServlet implements ApplicationContextAware
{   private ApplicationContext applicationContext;
   protected WebApplicationContext createWebApplicationContext(WebApplicationContext webApplicationContext)   throws BeansException   {
ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext)
BeanUtils.instantiateClass(org..web.context.support.StaticWebApplicationContext.class);
wac.setParent(applicationContext);
wac.setServletContext(getServletContext());
wac.refresh();
return wac;   }
   public void setApplicationContext(ApplicationContext applicationContext)   {       this.applicationContext = applicationContext;   }
}
This can then be set up in a spring config file like this
Code:
lt;osgi:service ref=quot;osgiMessageDispatcherServletquot; interface=quot;javax.servlet.Servletquot;gt;
lt;osgi:service-propertiesgt;
lt;beans:entry key=quot;aliasquot; value=quot;/servicequot;/gt;
lt;beans:entry key=quot;servlet-namequot; value=quot;osgiMessageDispatcherServletquot;/gt;
lt;/osgi:service-propertiesgt;
lt;/osgi:servicegt;

lt;beans:bean id=quot;osgiMessageDispatcherServletquot; class=quot;com.test.spring.ws.OsgiMessageDispatcherServletquot;/gt;

lt;beans:bean id=quot;endpointMappingsquot; class=quot;org..ws.server.endpoint.mapping.PayloadRootQNameEndpointMappingquot;gt;
.....
The Servlet will then pick up a reference to the surrounding application context and any endpoint mappings, wsdl definitions etc as usual.

If this is deployed into an OSGI environment with both jetty and the PAX web extender whiteboard installed then the whiteboard will automatically pick up the OSGI exposed servlet and register it with the jetty OSGI from service.

Does this seem a sensible approach? If so then could the Spring Web Services project be extended to include the code above or something similar as an enhancement?

Dave

Hi,

i'm having problem with standard spring WS. I made WS which runs under jetty without problem. I tried to setup manifest and deploy it as war to dm server but couple of errors have been throwns.

My template.mf looks like:

Code:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: WS module
Bundle-SymbolicName: testws.war
Bundle-Vendor: VitekTajzich
Bundle-Version: 1.0.0.SNAPSHOT
Module-Type: web
Web-ContextPath: testws
Import-Bundle: com..freemarker;version=quot;[2.3.12,2.3.12]quot;,org..ws;version=quot;[1.5.5,1.5.5]quot;
Import-Template: org..aop.support;version=quot;[2.5.6.A,3.0.0)quot;,org..beans;version=quot;[2.5.6.A,3.0.0)quot;
Exceptions thrown by dm server

Code:
Unsatisfied leaf constraints:   Bundle: xyz_1.0.0.SNAPSHOT - Import-Package: path.to.stubs.v1_0; version=quot;1.0.0quot;     Did you mean: 'com..server.io.core'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.soap.addressing.core; version=quot;0.0.0quot;     Did you mean: 'org..jca.cci.core'?   Bundle: org..bundle.ws.oxm-tiger_1.5.5 - Import-Package: org..oxm.mime; version=quot;0.0.0quot;     Did you mean: 'org..orm.jdo'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.server.endpoint.support; version=quot;0.0.0quot;     Did you mean: 'org..web.servlet.support'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.context; version=quot;0.0.0quot;     Did you mean: 'org..ui.context'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.soap.server; version=quot;0.0.0quot;     Did you mean: 'org..web.servlet'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.server; version=quot;0.0.0quot;     Did you mean: 'org..web.servlet'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Fragment-Host: org..bundle.ws.core; bundle-version=quot;0.0.0quot;   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.server.endpoint; version=quot;0.0.0quot;     Did you mean: 'org..jca.endpoint'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws.soap; version=quot;0.0.0quot;     Did you mean: 'org..aop'?   Bundle: org..bundle.ws.oxm-tiger_1.5.5 - Fragment-Host: org..bundle.ws.oxm; bundle-version=quot;0.0.0quot;   Bundle: xyz_1.0.0.SNAPSHOT - Import-Package: my.api.domain; version=quot;0.0.0quot;     Did you mean: 'com..server.web.dm'?   Bundle: org..bundle.ws.core-tiger_1.5.5 - Import-Package: org..ws; version=quot;0.0.0quot;     Did you mean: 'org..ui'?
Has anyone managed Spring WS running on DM Server as a bundle?

Is there some example?

positequot;.  I use java 1.6.0-14 and eclipse 3.5.1.R35x_v20090827.  Does anybody have a hint what's wrong with this?  Thank you, Peter

Hello,
I forgot to attach the zip...
Thanks, Peter

Hi

I am also trying to deploy a osgi web bundle.  In my web.xml I have the following only:

lt;servletgt;       lt;servlet-namegt;spring-wslt;/servlet-namegt;       lt;servlet-classgt;org..ws.transport.from.Messag  eDispatcherServletlt;/servlet-classgt;   lt;/servletgt;
   lt;servlet-mappinggt;       lt;servlet-namegt;spring-wslt;/servlet-namegt;       lt;ucl-patterngt;/*lt;/ucl-patterngt;   lt;/servlet-mappinggt;where I also have a spring-ws-servlet.xml.  When I deploy the war bundle on dm-server I am getting the following error :

java.lang.NoClassDefFoundError: org..ws.transport.from.MessageDispa  tcherServlet not found from bundle [com.gehc.ce.web [dictionary.web] (com.gehc.ce.web)]I have the org.g.ws-core library in the WEB-INF/lib/ folder.
Can anybody help on how to resolve this error?
thanks

Sonam

With the debugger's help it turned out that the mapping was not working (endPointNotFound ) because the org..ws.server.endpoint.annotation.  Endpoint and org..ws.server.endpoint.annotation.  PayloadRoot annotations are not available on the MyServiceEndpoint class.

This page helped to realize that the annotation is not found at runtime because the annotation class is not available to the bundle:

site/apache-felix-osgi-faq.html

So the solution for this was to import org..ws.server.endpoint.annotation in the bundle.

There was an other similar problem with the adapter: quot;No adapter for endpoint...quot;. Annotations from the quot;javax.xml.bind.annotationquot; package are used in the JAXB generated classes therefore that package must be imported as well.

I attached the working demo (string reverser).
¥
Back Forum Reply New