0

I have tried to deploy an simple JAX-WS web service on Karaf as an OSGi bundle. After export the web service as a War file and deploy it into the /deploy folder in Karaf, I found it can not be reached by http://localhost:8181/HelloWebService/helloWebService

My code is easy and I just use this https://github.com/yngwietiger/HelloWebService.git .

The web.xml is like this below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee         http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     id="WebApp_ID" version="2.5">

<display-name>jaxwsExample</display-name>

<listener>
    <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>

<servlet>
    <servlet-name>helloWebService</servlet-name>
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>helloWebService</servlet-name>
    <url-pattern>/helloWebService</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>myservlet</servlet-name>
    <servlet-class>com.webservices.demo.MyServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>myservlet</servlet-name>
    <url-pattern>/myservlet</url-pattern>
</servlet-mapping>

<session-config>
    <session-timeout>120</session-timeout>
</session-config>

And the log is :

2015-09-17 14:59:59,712 | INFO  | raf-4.0.1/deploy | fileinstall                      | 4 - org.apache.felix.fileinstall - 3.5.0 | Updating bundle HelloWebService / 0.0.0
2015-09-17 14:59:59,712 | INFO  | raf-4.0.1/deploy | Activator                        | 89 - org.ops4j.pax.web.pax-web-extender-war - 4.2.0 | Destroying extension for bundle HelloWebService
2015-09-17 14:59:59,716 | INFO  | raf-4.0.1/deploy | HttpServiceFactoryImpl           | 93 - org.ops4j.pax.web.pax-web-runtime - 4.2.0 | Unbinding bundle: [HelloWebService [231]]
2015-09-17 15:00:02,251 | INFO  | raf-4.0.1/deploy | HttpServiceFactoryImpl           | 93 - org.ops4j.pax.web.pax-web-runtime - 4.2.0 | Binding bundle: [HelloWebService [231]] to http service
2015-09-17 15:00:02,254 | INFO  | raf-4.0.1/deploy | fileinstall                      | 4 - org.apache.felix.fileinstall - 3.5.0 | Started bundle: webbundle:file:/E:/Software/apache-karaf-4.0.1/deploy/HelloWebService.war?Web-ContextPath=HelloWebService&Bundle-SymbolicName=HelloWebService&Bundle-Version=0.0.0
2015-09-17 15:00:02,258 | INFO  | pool-24-thread-3 | JettyServerWrapper               | 91 - org.ops4j.pax.web.pax-web-jetty - 4.2.0 | will add org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer to ServletContainerInitializers
2015-09-17 15:00:09,800 | INFO  | pool-24-thread-3 | JettyServerWrapper               | 91 - org.ops4j.pax.web.pax-web-jetty - 4.2.0 | added ServletContainerInitializer: org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer
2015-09-17 15:00:09,800 | INFO  | pool-24-thread-3 | JettyServerWrapper               | 91 - org.ops4j.pax.web.pax-web-jetty - 4.2.0 | will add org.apache.jasper.servlet.JasperInitializer to ServletContainerInitializers
2015-09-17 15:00:09,801 | INFO  | pool-24-thread-3 | JettyServerWrapper               | 91 - org.ops4j.pax.web.pax-web-jetty - 4.2.0 | Skipt org.apache.jasper.servlet.JasperInitializer, because specialized handler will be present
2015-09-17 15:00:09,806 | INFO  | pool-24-thread-3 | HttpServiceContext               | 91 - org.ops4j.pax.web.pax-web-jetty - 4.2.0 | registering context WebAppHttpContext{HelloWebService - 231}, with context-name: HelloWebService

And by using web:list, it shows the 231 bundle is active and keep deploying all the time.

======================================================================

how to deploy a standard JAX-WS web service(not JXC, just simple JAX-WS web service) with OSGi?
By using Karaf or bulid an Jetty OSGi enviroment or something else...

1 Answers1

0

The example you are mentioned uses maven. It builds generic WAR file that contains no correct OSGi manifest and generates nothing JaxWS-related. In order to create OSGi WAB (web archive bundle) that exposes Web Services you have to use appropriate maven plugins, for example: jaxws-maven-plugin for WSDL generation; maven-war-plugin along with with maven-bundle-plugin to build WAB. Actually, maven-bundle-plugin can build WABs by itself.

Dmitry
  • 124
  • 1
  • 6
  • Thanks. But according to the document of [Karaf deployer](http://karaf.apache.org/manual/latest/users-guide/deployers.html) and [Karaf webcontainer](http://karaf.apache.org/manual/latest/users-guide/webcontainer.html), it says with the war feature installed, we can simplely install the WAR with commond like: bundle: install -s "webbundle:file:/E:/Software/apache-karaf-4.0.1/deploy/HelloWebService.war?Web-ContextPath=HelloWebService&Bundle-SymbolicName=HelloWebService&Bundle-Version=0.0.0" – Guohui Wan Sep 18 '15 at 01:44
  • That is true but this solution will be osgi container dependent. In any case, you have to generate Jax-WS related info. – Dmitry Sep 18 '15 at 09:24
  • You mean a web.xml contains com.sun.xml.ws.transport.http.servlet.WSServletContextListener and a sun-jaxws.xml? I have put these into it. – Guohui Wan Sep 18 '15 at 10:04
  • I wrote a simple JAX-WS webservice, and export it into a war file, and it works fine in Tomcat. Then I want to deploy it into karaf with the commond bundle: install -s "webbundle:file:/D:/Software/webTest.war?Web-C‌​ontextPath=/webTest&Bundle-SymbolicName=/webTest&Bundle-Version=0.0‌​.0". But it does not work well. – Guohui Wan Sep 18 '15 at 10:06