问题
I have integrated within a JSF app a few webservices through Jersey
. Everything works fine, even the OAuth identification is working. BUT! When starting my webserver, I ALWAYS get this error :
INFO: Scanning for root resource and provider classes in the packages:
com.mysite.webService
INFO: Root resource classes found:
class com.mysite.webService.Accounts
INFO: No provider classes found.
INFO: Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 03:31 PM'
SEVERE: The provider class, class com.sun.jersey.oauth.server.OAuthProviderInjectionProvider, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.RuntimeException: No OAuthProvider implementation found in the list of providers.
at com.sun.jersey.oauth.server.OAuthProviderInjectionProvider.<init>(OAuthProviderInjectionProvider.java:71)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
(edit2: above is now solved)
and this warning:
...
WARNING: Provider com.sun.xml.internal.bind.v2.ContextFactory not found
javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory not found
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by com.sun.jersey.glassfish.v3.osgi.jersey-gf-server [157]]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:148)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:361)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)
at com.sun.jersey.server.impl.wadl.WadlApplicationContextImpl.<init>(WadlApplicationContextImpl.java:95)
Here is my web.xml
relevant entries :
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>my.site.webService</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
My classes look as such :
@Path("/rest")
public class MyClass {
@GET
@Path("/{id}/results")
@Produces("application/json")
public String getResults(@Context HttpContext hc, @PathParam("id")) {
//...
}
}
I am using Majorra 2.1.20
on Glassfish 2.1.2.2
with PrimeFaces 3.4.1
and Jersey 1.17
as addons. Developping in Eclipse Juno
if this affects anything.
Edit
This does not prevent me from having everything in working order with regards to webservices. But everytime I republish something on Glassfish, the error shows up.
As mentioned in an answer below, this should have been fixed in version 1.7 according to JIRA bug JERSEY-709. But I am very well on v. 1.17 and I'm still getting this.
I have also added a Warning I am getting within the stack trace. If this can help determine the issue!
Searching the web : I have found The same unresolved issue here
Edit 2
As answered below, updating my OAuthClient.jar
did solve the first error
. I am STILL getting the WARNING: Provider com.sun.xml.internal.bind.v2.ContextFactory not found
.
Edit 3 - Attempted Solution
Tried updating JAXB after what I thought would be a lead on this question. This did not lead to anything successful. Same warning. When removing the Jersey bits in my web.xml
this warning stops showing (just to confirm this is really initiating the issue).
回答1:
In another context : standalone Java App, using Maven
In pom.xml, jaxb was defined using this lines :
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
Project compilation is successful, but when running, I received the same Exception (java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory)
Issue was solved adding this lines before jaxb-api dependency
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.2</version>
</dependency>
回答2:
This error has gone away when upgrading to Jersey 1.18.
See https://java.net/jira/browse/JERSEY-1932
To upgrade Glassfish to Jersey 1.18 see : https://jersey.java.net/nonav/documentation/1.18/glassfish.html
回答3:
This should have been fixed in v1.7 as per JERSEY-709.
回答4:
M8, I met this as well on:
NetBeans 7.2
Glassfish 3.1.2.2 which have jersey 1.11, and jersey-oauth 1.11.
But it could work with:
NetBeans 7.3
Glassfish 3.1.2.2 which have jersey 1.11 (I didn't modify jars in glassfish/module folder)
jersey 1.13 and jersey-oauth 1.13 (which is packed in war)
Then the exception no longer exist.
I'm still not quite sure how it is solved, but I hope this can help you.
来源:https://stackoverflow.com/questions/15416579/warning-provider-com-sun-xml-internal-bind-v2-contextfactory-not-found