Reputation: 41
I get the NoSuchMethodError when trying build the REST service using jersey. Any help would be much appreciated.
My POM.xml :
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
My web.xml :
<servlet>
<servlet-name>Rest</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>com.example.serversideauthservice.resources.AuthResource</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Rest</servlet-name>
<url-pattern>/auth/*</url-pattern>
</servlet-mapping>
Not sure what I am doing wrong, but when I checked the API docs, it seems I have the right version in the mvn dependancies.
Here is the stacktrace during run time.
[INFO] INFO: Scanning for root resource and provider classes in the packages:
[INFO] com.example.serversideauthservice.resources.AuthResource
[INFO] Feb 21, 2015 2:35:26 PM com.google.apphosting.utils.jetty.JettyLogger warn
**[INFO] WARNING: failed Rest: java.lang.NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoaderPA()Ljava/security/PrivilegedAction;**
[INFO] Feb 21, 2015 2:35:26 PM com.google.apphosting.utils.jetty.JettyLogger warn
[INFO] WARNING: failed com.google.appengine.tools.development.DevAppEngineWebAppContext@7f74a932{/,D:\taxmarkets_main\taxmarket\target\taxmarket-1.0-SNAPSHOT}: java.lang.NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoaderPA()Ljava/security/PrivilegedAction;
[INFO] Feb 21, 2015 2:35:26 PM com.google.apphosting.utils.jetty.JettyLogger warn
[INFO] WARNING: failed JettyContainerService$ApiProxyHandler@660382ce: java.lang.NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoaderPA()Ljava/security/PrivilegedAction;
[INFO] Feb 21, 2015 2:35:26 PM com.google.apphosting.utils.jetty.JettyLogger warn
[INFO] WARNING: Error starting handlers
[INFO] java.lang.NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoaderPA()Ljava/security/PrivilegedAction;
[INFO] at com.sun.jersey.spi.scanning.AnnotationScannerListener.<init>(AnnotationScannerListener.java:94)
[INFO] at com.sun.jersey.spi.scanning.PathProviderScannerListener.<init>(PathProviderScannerListener.java:59)
[INFO] at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
[INFO] at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
[INFO] at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
[INFO] at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
[INFO] at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:696)
[INFO] at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674)
[INFO] at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:205)
Upvotes: 2
Views: 6774
Reputation: 1479
I had the following exception: java.lang.IllegalAccessError: tried to access method com.sun.jersey.core.spi.factory.ResponseImpl.<init etc.
This may suggest that there is an internal Weblogic issue. I was updating the same deployment with newer wars. After a period, it looks like the update process is not unloading the old war dependencies. I removed manually from the weblogic directories the deployed war files. I wasn't able to remove two wars: the current one and the replaced one, while the managed server was running. Directories of interest: 12.1.3\user_projects\domains\wl_server\servers\managed_1\stage, 12.1.3\user_projects\domains\wl_server\servers\managed_1\tmp_WL_user, 12.1.3\user_projects\domains\wl_server\servers\AdminServer\upload.
After stopping the managed server, I could remove the old war, leaving only the latest war. On managed_1 start, the latest war is working without the weird exception.
Upvotes: 0
Reputation: 11
I faced the issue too recently. Check if class with name com.sun.jersey.core.reflection.ReflectionHelper
is present in any other jar.
For me I had caliper.jar
also, and it was being loaded from there instead. That class did not have getContextClassLoaderPA.
Do a grep -ir com.sun.jersey.core.reflection.ReflectionHelper *
to see if any other jar shows up the same class.
Upvotes: 1