Skip to main content

Module not able to find ProviderImpl

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
5 replies [Last post]
dpwr
Offline
Joined: 2007-10-28

Hi,

I have an OSGi module which has an embedded library that needs to make use of secure web-service calls, not something I can change.
My problem is that at runtime the module uses org.glassfish.metro.webservices-api-osgi and that fails to find com.sun.xml.ws.spi.ProviderImpl or com.sun.xml.internal.ws.spi.ProviderImpl. I don't understand how this is possible, surely that module must have to have access to that class? I'm using glassfish 3.1.

Any advice as to how to fix this are appreciated, I'm completely at a loss for what to try next. I'm more than happy to provide any additional information or answer any questions to get to the answer.
A very easy way to replicate this problem is by simply creating a new OSGi module with the following Activator:

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {
    public void start(BundleContext context) throws Exception {
        MyService mys = new MyService(null, null);
    }

    public void stop(BundleContext context) throws Exception {
        // TODO add deactivation code here
    }
<span class="Apple-tab-span" style="white-space: pre; "> </span>public class MyService extends Service {
<span class="Apple-tab-span" style="white-space: pre; ">   </span>public MyService(URL url, QName qname) {
<span class="Apple-tab-span" style="white-space: pre; ">     </span>super(url, qname);<span class="Apple-tab-span" style="white-space: pre; "> </span>
<span class="Apple-tab-span" style="white-space: pre; ">   }</span>
<span class="Apple-tab-span" style="white-space: pre; "> </span>}
<font size="2" face="arial, sans-serif" color="#000000" class="Apple-style-span"><span class="Apple-style-span" style="border-collapse: collapse; line-height: normal; ">} <br /></span></font>

The result on deployment will be:

SEVERE: Exception while loading the app : Activator start error in bundle uk.ac.ox.sddag.api.osgi.basicWSBlowupModule [435].
javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
    at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:68)
    at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:163)
    at javax.xml.ws.spi.Provider.provider(Provider.java:142)
    at javax.xml.ws.Service.&lt;init&gt;(Service.java:92)
    at uk.ac.ox.sddag.api.osgi.basicwsblowupmodule.Activator$MyService.&lt;init&gt;(Activator.java:22)
    at uk.ac.ox.sddag.api.osgi.basicwsblowupmodule.Activator.start(Activator.java:12)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1835)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1752)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:922)
    at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.resume(OSGiDeployedBundle.java:83)
    at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.start(OSGiDeployedBundle.java:62)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:372)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl not found by org.glassfish.metro.webservices-api-osgi [2]
    at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at javax.xml.ws.spi.FactoryFinder.safeLoadClass(FactoryFinder.java:182)
    at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:65)
    ... 41 more

For whatever reason, the org.glassfish.metro.webservices-api-osgi module does not have access to that class. What is the reason for this and how do I work around it?

It is no different when I try and use

System.setProperty(&quot;javax.xml.<wbr></wbr>ws.spi.Provider&quot;, &quot;com.sun.xml.ws.spi.<wbr></wbr>ProviderImpl&quot;);
except it fails to find that provider instead.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
leozhu
Offline
Joined: 2011-08-26

I got similar issue as dpwr's, use Glassfish 3.1.1, and try the solution to switch classloader as sahoo told, but not working

finally I just made a test to get ride of metro bundle with glassfish to use jax-ws with jdk, it works for now:

1.start glassfish and add -Dcom.sun.xml.ws.monitoring.endpoint=false on Configurations -> server-config ->add jvm option. refer to(http://stackoverflow.com/questions/4983731/how-do-i-disable-metro-on-gla...)

2.stop glassfish

3,move these files to a backup directory (since I want to recover it if anything wrong):

glassfish\modules\endoserd\

jaxb-api-osgi.jar

webservices-api-osgi.jar

glassfish\modules\

jaxb-osgi.jar

jaxr-api-osgi.jar

jaxrpc-api-osgi.jar

jsr109-impl.jar

metro-glue.jar

soap-tcp.jar

stax2-api.jar

webservices.security.jar

webservices-connector.jar

webservices-extra-jdk-packages.jar

webservices-osgi.jar

woodstox-core-asl.jar

4.add these to glassfish\osgi\felix\conf\config.properties , behind the content that list under "endorsed-standard-packages="

don't forget to add ", \" to the last line you append to and add bellows in another line, and start with a blank in each line.

com.sun.xml.internal.ws, \
com.sun.xml.internal.ws.addressing, \
com.sun.xml.internal.ws.addressing.model, \
com.sun.xml.internal.ws.addressing.v200408, \
com.sun.xml.internal.ws.api, \
com.sun.xml.internal.ws.api.addressing, \
com.sun.xml.internal.ws.api.client, \
com.sun.xml.internal.ws.api.fastinfoset, \
com.sun.xml.internal.ws.api.handler, \
com.sun.xml.internal.ws.api.message, \
com.sun.xml.internal.ws.api.message.stream, \
com.sun.xml.internal.ws.api.model, \
com.sun.xml.internal.ws.api.model.soap, \
com.sun.xml.internal.ws.api.model.wsdl, \
com.sun.xml.internal.ws.api.pipe, \
com.sun.xml.internal.ws.api.pipe.help, \
com.sun.xml.internal.ws.api.server, \
com.sun.xml.internal.ws.api.streaming, \
com.sun.xml.internal.ws.api.wsdl, \
com.sun.xml.internal.ws.api.wsdl.parser, \
com.sun.xml.internal.ws.api.wsdl.writer, \
com.sun.xml.internal.ws.binding, \
com.sun.xml.internal.ws.client, \
com.sun.xml.internal.ws.client.dispatch, \
com.sun.xml.internal.ws.client.sei, \
com.sun.xml.internal.ws.developer, \
com.sun.xml.internal.ws.encoding, \
com.sun.xml.internal.ws.encoding.fastinfoset, \
com.sun.xml.internal.ws.encoding.soap, \
com.sun.xml.internal.ws.encoding.soap.streaming, \
com.sun.xml.internal.ws.encoding.xml, \
com.sun.xml.internal.ws.fault, \
com.sun.xml.internal.ws.handler, \
com.sun.xml.internal.ws.message, \
com.sun.xml.internal.ws.message.jaxb, \
com.sun.xml.internal.ws.message.saaj, \
com.sun.xml.internal.ws.message.source, \
com.sun.xml.internal.ws.message.stream, \
com.sun.xml.internal.ws.model, \
com.sun.xml.internal.ws.model.soap, \
com.sun.xml.internal.ws.model.wsdl, \
com.sun.xml.internal.ws.org.objectweb.asm, \
com.sun.xml.internal.ws.protocol, \
com.sun.xml.internal.ws.protocol.soap, \
com.sun.xml.internal.ws.protocol.xml, \
com.sun.xml.internal.ws.resources, \
com.sun.xml.internal.ws.server, \
com.sun.xml.internal.ws.server.provider, \
com.sun.xml.internal.ws.server.sei, \
com.sun.xml.internal.ws.spi, \
com.sun.xml.internal.ws.streaming, \
com.sun.xml.internal.ws.transport, \
com.sun.xml.internal.ws.transport.http, \
com.sun.xml.internal.ws.transport.http.client, \
com.sun.xml.internal.ws.transport.http.server, \
com.sun.xml.internal.ws.util, \
com.sun.xml.internal.ws.util.exception, \
com.sun.xml.internal.ws.util.localization, \
com.sun.xml.internal.ws.util.pipe, \
com.sun.xml.internal.ws.util.xml, \
com.sun.xml.internal.ws.wsdl, \
com.sun.xml.internal.ws.wsdl.parser, \
com.sun.xml.internal.ws.wsdl.writer, \
com.sun.xml.internal.ws.wsdl.writer.document, \
com.sun.xml.internal.ws.wsdl.writer.document.http, \
com.sun.xml.internal.ws.wsdl.writer.document.soap, \
com.sun.xml.internal.ws.wsdl.writer.document.soap12, \
com.sun.xml.internal.ws.wsdl.writer.document.xsd

5. restart glassfish to see if anythign wrong (which works on my case)

6,deploy you bundle to test.(maybe you need use DynamicImport-Package if you do not import som package explicitly)

since I do not published any webservice on glassfish(just have some osgi bundle work as webservice client), and really do not have time to do further test with that, so this may not really help.

I just make this test, and did not use it in production entironment yet.

Glassfish is really good and advanced, hope this issue could be solved and we can use the metro inside it.

ss141213
Offline
Joined: 2005-03-30

It's a bug in web services implementation. There used to be a similar
bug [1] in JAXB which JAXB team fixed. WS team need to do the same.

Try the work around suggested in [2]. File a bug never-the-less.

Sahoo

[1] http://java.net/jira/browse/GLASSFISH-11748
[2] http://www.java.net/node/704073#comment-798841
On Monday 04 July 2011 05:12 PM, forums@java.net wrote:
>
>
>
> Hi,
>
>
>
>
>
>
> I have an OSGi module which has an embedded library that needs to make
> use of
> secure web-service calls, not something I can change.
> My problem is that at runtime the module uses
> org.glassfish.metro.webservices-api-osgi and that fails to find
> com.sun.xml.ws.spi.ProviderImpl or
> com.sun.xml.internal.ws.spi.ProviderImpl.
> I don't understand how this is possible, surely that module must have
> to have
> access to that class? I'm using glassfish 3.1.
>
> Any advice as to how to fix this are appreciated, I'm completely at a
> loss
> for what to try next. I'm more than happy to provide any additional
> information or answer any questions to get to the answer.
> A very easy way to replicate this problem is by simply creating a new
> OSGi
> module with the following Activator:
>
>
> import java.net.URL; import javax.xml.namespace.QName; import
> javax.xml.ws.Service; import org.osgi.framework.BundleActivator; import
> org.osgi.framework.BundleContext; public class Activator implements
> BundleActivator { public void start(BundleContext context) throws
> Exception {
> MyService mys = new MyService(null, null); } public void
> stop(BundleContext
> context) throws Exception { // TODO add deactivation code here }
> public class
> MyService extends Service { public MyService(URL url, QName qname) {
> super(url, qname); } } }
> .. The result on deployment will be:
>
>
>
>
>
> SEVERE: Exception while loading the app : Activator start error in bundle
> uk.ac.ox.sddag.api.osgi.basicWSBlowupModule [435].
> javax.xml.ws.WebServiceException: Provider
> com.sun.xml.internal.ws.spi.ProviderImpl not found at
> javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:68) at
> javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:163) at
> javax.xml.ws.spi.Provider.provider(Provider.java:142) at
> javax.xml.ws.Service.(Service.java:92) at
> uk.ac.ox.sddag.api.osgi.basicwsblowupmodule.Activator$MyService.(Activator.java:22)
>
> at
> uk.ac.ox.sddag.api.osgi.basicwsblowupmodule.Activator.start(Activator.java:12)
>
> at
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
>
> at org.apache.felix.framework.Felix.activateBundle(Felix.java:1835) at
> org.apache.felix.framework.Felix.startBundle(Felix.java:1752) at
> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:922) at
> org.glassfish.extras.osgicontainer.OSGiDeployedBundle.resume(OSGiDeployedBundle.java:83)
>
> at
> org.glassfish.extras.osgicontainer.OSGiDeployedBundle.start(OSGiDeployedBundle.java:62)
>
> at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) at
> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) at
> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
>
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
>
> at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:372)
>
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
>
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
>
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
>
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
>
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
>
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
>
> at
> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
> at
> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222) at
>
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
> at
> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
> at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
>
> at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
> at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>
> at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
> at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
> at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>
> at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
>
> at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
>
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
>
> at java.lang.Thread.run(Thread.java:680) Caused by:
> java.lang.ClassNotFoundException:
> com.sun.xml.internal.ws.spi.ProviderImpl
> not found by org.glassfish.metro.webservices-api-osgi [2] at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
>
> at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71) at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at
> java.lang.Class.forName0(Native Method) at
> java.lang.Class.forName(Class.java:169) at
> javax.xml.ws.spi.FactoryFinder.safeLoadClass(FactoryFinder.java:182) at
> javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:65) ...
> 41 more
> For whatever reason, the org.glassfish.metro.webservices-api-osgi
> module does
> not have access to that class. What is the reason for this and how do
> I work
> around it?
>
> It is no different when I try and use
>
> System.setProperty("javax.xml.ws.spi.Provider",
> "com.sun.xml.ws.spi.ProviderImpl"); except it fails to find that provider
> instead.
>
>
>
> --
>
> [Message sent by forum member 'dpwr']
>
> View Post: http://forums.java.net/node/818465
>
>

dpwr
Offline
Joined: 2007-10-28

Thanks, where do I get the org.glassfish.common internal-api dependency from? I can't seem to find it anywhere.

Thanks

dpwr
Offline
Joined: 2007-10-28

I picked it up from here: http://www.mvnbrowser.com/artifact-details.html?groupId=org.glassfish.common&artifactId=internal-api&version=3.2-b06&tab=FILES#tabs

The code does not make sense though so maybe that is not right:

ClassLoader ccl = Globals.get(ClassLoaderHierarchy.class).getCommonClassLoader();

getCommonClassLoader does not exist as a method.

JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class);

Not a valid argument for that method.

My imports:

import java.net.URL;
import javax.naming.spi.ObjectFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.glassfish.internal.api.Globals;
import org.glassfish.internal.api.ClassLoaderHierarchy;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
If you could give me some more hints to get this solved I would be eternally grateful, I've been stuck in my tracks for a week. :-(

ss141213
Offline
Joined: 2005-03-30

Add the following repo in your pom.xml:

glassfish-nexus-repo
Nexus repository collection for Glassfish
http://maven.glassfish.org/content/groups/glassfish

never

I suggest you use version 3.1 of internal-api.

I do see getCommonClassLoader() as a method in ClassLoaderHierarchy.

Your problem about ObjectFactory is that you are using wrong
ObjectFactory. JAXB uses javax.xml.bind...ObjectFactory.

Last, but not the least, I don't understand if you are trying out JAXB
workaround as an experiment or what. Your problem of ProviderImpl should
go away by simply switching the thread's context class loader
temporarily to common class loader.

Thanks,
Sahoo

On Tuesday 05 July 2011 09:42 PM, forums@java.net wrote:
> I picked it up from here:
> http://www.mvnbrowser.com/artifact-details.html?groupId=org.glassfish.co...
>
> [1]
>
> The code does not make sense though so maybe that is not right:
>
> ClassLoader ccl =
> Globals.get(ClassLoaderHierarchy.class).getCommonClassLoader();
>
> getCommonClassLoader does not exist as a method.
>
> JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class);
>
> Not a valid argument for that method.
>
> My imports:
>
> import java.net.URL; import javax.naming.spi.ObjectFactory; import
> javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import
> javax.xml.namespace.QName; import javax.xml.ws.Service; import
> org.glassfish.internal.api.Globals; import
> org.glassfish.internal.api.ClassLoaderHierarchy; import
> org.osgi.framework.BundleActivator; import
> org.osgi.framework.BundleContext;
> If you could give me some more hints to get this solved I would be
> eternally grateful, I've been stuck in my tracks for a week. :-(
>
>
> [1]
> http://www.mvnbrowser.com/artifact-details.html?groupId=org.glassfish.co...
>
> --
>
> [Message sent by forum member 'dpwr']
>
> View Post: http://forums.java.net/node/818465
>
>