Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] OSGi and javax.jws.WebService with Java 11

Hi Lars,

The stack trace above leads me to hypothesis that the Java ServiceLoader pattern is used. There are multiple ways to make it work but both require providing proper OSGi metadata, i.e. the Maven PDE/M2E stuff is not sophisticated enough to provide good OSGi metadata out of the box. IMO it can only be used for "simple" jars (not doing any fancy class loading stuff) or jars providing proper metadata already.

On possible approach is this:
https://blog.osgi.org/2013/02/javautilserviceloader-in-osgi.html

The other one is using fragments, which allows the API bundle to discover the "META-INF/services" files with its built in mechanism.

-Gunnar

-- 
Gunnar Wagenknecht
gunnar@xxxxxxxxxxxxxxx, http://guw.io/


> On May 6, 2021, at 15:14, Lars Vogel <lars.vogel@xxxxxxxxxxx> wrote:
> 
> Hi,
> 
> I'm trying to migrate an RCP client to Java 11. All good so far only
> the webservice which was part of Java 8 refused to start with an
> sun.xml.internal.ws.spi.ProviderImpl exception.
> 
> Exception:
> Caused by: javax.xml.ws.WebServiceException: Provider
> com.sun.xml.internal.ws.spi.ProviderImpl not found
> at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61)
> at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58)
> at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:103)
> at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:112)
> at javax.xml.ws.spi.Provider.provider(Provider.java:96)
> at javax.xml.ws.Endpoint.publish(Endpoint.java:254)
> at eupen.rcp.core.handers.StartWebserviceHandler.execute(StartWebserviceHandler.java:15)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:564)
> at org.eclipse.e4.c
> 
> Example:
> 
> import javax.jws.WebMethod;
> import javax.jws.WebService;
> 
> @WebService
> public class WebServiceExample {
>    private String message = new String("Hello, ");
> 
>    public void Hello() {}
> 
>    @WebMethod
>    public String sayHello(String name) {
>        return message + name + ".";
>    }
> }
> 
> And I start it via:
> ----
> import org.eclipse.e4.core.di.annotations.Execute;
> 
> import javax.xml.ws.Endpoint;
> 
> public class StartWebserviceHandler {
> 
> @Execute
> public void execute() {
>  String url = "http://localhost:4434/miniwebservice";;
>      Endpoint.publish( url, new WebServiceExample() );
> }
> }
> 
> ---------
> 
> 
> I started to add libraries from Maven central via the new PDE / M2e
> integration but it seems that this pull and endless list of
> dependencies into the classpath.
> 
> Is anyone aware of a working example using such a Webservice inside
> OSGi with Java 11 or higher?
> 
> Best regards, Lars
> 
> -- 
> Eclipse Platform project co-lead
> CEO vogella GmbH
> 
> Haindaalwisch 17a, 22395 Hamburg
> Amtsgericht Hamburg: HRB 127058
> Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
> USt-IdNr.: DE284122352
> Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/equinox-dev



Back to the top