I've done some testing and moving aroung some library (I've put the library rt.jar in the main application and not in the bundle), but now I've got a different problem:

java.lang.RuntimeException: javax.xml.bind.JAXBException: "org.okkam.client.data" doesnt contain ObjectFactory.class or jaxb.index
    at org.okkam.client.util.XMLEntityConverter.init(Unknown Source)
    at org.okkam.client.util.XMLEntityConverter.xmlToEntity(Unknown Source)
at it.uniroma2.art.maskkot.osgi.service.Maskkot.inquireOkkamForIds(Maskkot.java:130)

Doing a search on internet I've found this site:
http://stackoverflow.com/questions/1043109/why-cant-jaxb-find-my-jaxb-index-when-running-inside-apache-felix

where someone said:

"JAXB can't find jaxb.index, because by default, newInstance(String) uses the current thread's class loader (as returned by Thread.getContextClassLoader()). This doesn't work inside Felix, because the OSGi bundles and the framework's threads have separate class loaders.

The solution is to get a suitable class loader from somewhere and use newInstance(String, ClassLoader). I got a suitable class loader from one of the classes in the package that contains jaxb.index, a sensible choice for flexibility reasons probably is ObjectFactory:

ClassLoader cl = my.package.name.ObjectFactory.class.getClassLoader();
JAXBContext jc = JAXBContext.newInstance("my.package.name", cl);

Maybe you could also get at the class loader that the Bundle instance is using, but I couldn't figure out how, and the above solution seems safe to me."


I've quite understand his solution, but I'm not able to implemented it because in my case the code that does the newInstance request is inside a third party jar which it is inside my bundle, so I'm not able to change the code.

Does someone have any suggestions because  I'm really stuck.

Thanks,

Andrea


Il 20/05/2010 12:05, Andrea Turbati ha scritto:
Thank you for the answer.

I add in the manifest javax.jws in the Import-Package and now it seems that I've resolved that problem, but a new one has appeared:

GRAVE: interface com.sun.xml.internal.ws.developer.WSBindingProvider is not visible from class loader java.lang.IllegalArgumentException: interface com.sun.xml.internal.ws.developer.WSBindingProvider is not visible from class loader
    at java.lang.reflect.Proxy.getProxyClass(Unknown Source)
    at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
    at javax.xml.ws.Service.getPort(Unknown Source)
at org.okkam.core.ws.WebServicesService.getWebServicesPort(WebServicesService.java:56)


And I don't understand the reason because in my bundle I've put in the directory lib the library rt.jar and in the manifest I have:

Bundle-ClassPath: .,
 lib/rt.jar,
 lib/okkam-proxy-1.0.jar,
 lib/okkam-client-2.0.0.1.jar,
 lib/commons-logging-1.0.4.jar,


So I don't undestand the reason of the "not visible from class loader" error.

By the way to which class loader is the error refearing to? I think it should be the bundle classloader, but that classloader should have access to that interface

Thanks,

Andrea


Il 19/05/2010 18:59, Richard S. Hall ha scritto:
See the FAQ:

http://felix.apache.org/site/apache-felix-osgi-faq.html

Perhaps your annotation packages are not available to your bundle.

-> richard

On 5/19/10 6:48, Andrea Turbati wrote:
Hi,
In my bundle I'm trying to use a library (Okkam library) to retrieve same information from a web service and I get the following error:

com.sun.xml.internal.ws.model.RuntimeModelerException: A WebService annotation is not present on class: org.okkam.core.ws.WebServices at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown Source)
    at javax.xml.ws.Service.getPort(Unknown Source)
at org.okkam.core.ws.WebServicesService.getWebServicesPort(WebServicesService.java:56) at org.okkam.proxyclient.WebServicesClientManager.createOkkamWebServiceInstance(WebServicesClientManager.java:57) at org.okkam.proxyclient.WebServicesClientManager.<init>(WebServicesClientManager.java:44)
    at org.okkam.client.wsclient.EnsPublicClient.init(Unknown Source)
    at org.okkam.client.wsclient.EnsPublicClient.<init>(Unknown Source)
    ....


I'm not very prepared on WebServices, so I don't know what I'm doing wrong and how can I solved it. The some code works in an non-OSGi enviroment.

I've also tried to include in the bundle various library from jdk1.6.0_20\jre\lib (and also change the manifest accordingly) but the error remain the same.

Thanks,

Andrea

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to