slf4j java.lang.LinkageError loader constraint violation - java

For the project purpose, I have to stick on the Java 1.6 for development, I have used async client jar file and incorporate it into my project to achieve the async function and developed and exported a JAR using java 1.6.
this jar included into build path of another web project running on java 7.it is working fine with java 7 64 bit and tomcat7 64 bit.But when using the java 7 32 bit and tomcat7 32 bit seeing the following error:
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type taticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory; used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:299)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at com.ning.http.client.AsyncHttpClient.<clinit>(AsyncHttpClient.java:146)
at com.netspective.ems.invoker.AsyncApiInvoker.post(AsyncApiInvoker.java:39)
at com.netspective.ems.invoker.AsyncApiInvoker.post(AsyncApiInvoker.java:32)
at com.netspective.ems.invoker.AsyncApiInvoker.post(AsyncApiInvoker.java:73)
at com.netspective.ems.api.ExceptionApi.notify(ExceptionApi.java:42)
at com.netspective.ems.NetspectiveEMS.prepareAndPostDetails(NetspectiveEMS.java:101)
at com.netspective.ems.NetspectiveEMS.log(NetspectiveEMS.java:168)
at com.netspective.watchtower.sdk.log4j.WatchtowerClientAppender.append(WatchtowerClientAppender.java:32)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.apache.commons.logging.impl.Log4JLogger.debug(Log4JLogger.java:155)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile.findResourceNames(DiscoverNamesInFile.java:178)
at org.apache.commons.discovery.tools.DiscoverClass.find(DiscoverClass.java:323)
at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:520)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:370)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:270)
at gov.max.service.appendixb.persistence.restlet.resources.common.ServiceConfig.<clinit>(ServiceConfig.java:22)
at gov.max.service.appendixb.filter.security.SecurityFilter.init(SecurityFilter.java:129)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4656)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5309)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
I have used following jar in the project
async-http-client.jar
com.fasterxml.jackson.core.jar
com.fasterxml.jackson.databind.jar
com.springsource.org.joda.time-1.6.0.jar
jackson-annotations-2.0.2.jar
jackson-databind-2.0.5-sources.jar
jackson-datatype-joda-2.0.4.jar
json-1.5.jar
slf4j-api-1.7.0.jar
Is there a way to resolve this exception? Thanks for any suggestion.

Try using slf4j-api-1.5.*.jar or older. I know that the version number of an api might not be dependent on the Java version but that would be worth a try. I tried the following when in my project for Java 1.6
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>

Another option might be marking slf4j as provided:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>

Related

Exception while visiting module-info.class java.lang.IllegalArgumentException, Payara Server

When I try to start my payara server unknown illegalArgumentException on module-info.class error occurs,
2017-07-17T20:06:58.042+0530|Info: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
2017-07-17T20:06:58.057+0530|Info: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
2017-07-17T20:06:58.057+0530|Info: Created HTTP listener admin-listener on host/port 0.0.0.0:4848
2017-07-17T20:06:58.073+0530|Info: Created virtual server server
2017-07-17T20:06:58.073+0530|Info: Created virtual server __asadmin
2017-07-17T20:06:58.709+0530|Info: Setting JAAS app name glassfish-web
2017-07-17T20:06:58.709+0530|Info: Virtual server server loaded default web module
2017-07-17T20:06:59.010+0530|Info: Java security manager is disabled.
2017-07-17T20:06:59.011+0530|Info: Entering Security Startup Service.
2017-07-17T20:06:59.013+0530|Info: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
2017-07-17T20:06:59.094+0530|Info: Security Service(s) started successfully.
2017-07-17T20:07:00.849+0530|Info: Initializing Mojarra 2.2.14 ( 20161114-2152 unable to get svn info) for context ''
2017-07-17T20:07:02.397+0530|Severe: Exception while visiting module-info.class of size 281
java.lang.IllegalArgumentException
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:359)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:165)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:127)
at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:345)
at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:68)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:304)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:293)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-07-17T20:07:02.461+0530|Severe: Exception while visiting module-info.class of size 330
java.lang.IllegalArgumentException
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:359)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:165)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:127)
at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:345)
at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:68)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:304)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:293)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-07-17T20:07:02.461+0530|Severe: Exception while visiting module-info.class of size 449
java.lang.IllegalArgumentException
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:359)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:165)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:127)
at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:345)
at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:68)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:304)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:293)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-07-17T20:07:02.477+0530|Severe: Exception while visiting module-info.class of size 267
java.lang.IllegalArgumentException
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at org.glassfish.hk2.external.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:359)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:165)
at com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:127)
at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:345)
at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:68)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:304)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:293)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2017-07-17T20:07:02.539+0530|Info: Loading application [__admingui] at [/]
2017-07-17T20:07:02.555+0530|Info: Loading application __admingui done in 5,492 ms
2017-07-17T20:07:02.850+0530|Info: WELD-000900: 2.4.1 (Final)
2017-07-17T20:07:03.459+0530|Info: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
2017-07-17T20:07:03.475+0530|Info: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
2017-07-17T20:07:04.820+0530|Info: Cannot find the resource bundle for the name com.sun.logging.enterprise.system.core.naming for class org.glassfish.concurrent.runtime.deployer.ConcurrentObjectFactory using org.glassfish.main.concurrent.impl [41]
2017-07-17T20:07:05.185+0530|Info: Loading application [test-service] at [/test-service]
2017-07-17T20:07:05.524+0530|Info: test-service was successfully deployed in 3,672 milliseconds.
Environment used,
1. Kepler Service Release 2
2. JDK 1.8 with Java compiler level set to 1.7 in Eclipse
3. pom.xml
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.2</version>
<scope>test</scope>
</dependency>
4. Payara Server 4.1.1.171
Unable to load application, what would be the possible cause for this? How to resolve?
Using Java 7 (u80) or Java 8 (u121, u151), this error could not be eliminated with Payara versions:
4.1.2.172
4.1.1.171.0.1
5.0 beta 1
Instead, Java 8 (u151) with GlassFish 5 eliminated the class incompatibility error.
Downgrading Payara server from payara-4.1.2.172 to payara-4.1.1.171.0.1 is the fix, the possible cause would be compiler mismatch between servers, Wherein payara-4.1.1.171.0.1 works great with Java 7. More explanation from the community would be helpful for more clarity on the possible cause of error.

Grails Application doesn't deploy in tomcat

I have my grails app converted to maven project. In my pom.xml I have the below dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
My application starts with grails run-app but when I build war through maven compile install , deployment fails in tomcat with below error
ERROR context.GrailsContextLoaderListener - Error initializing Grails: class org.springframework.core.LocalVariableTableParameterNameDiscoverer$ParameterNameDiscoveringVisitor has interface org.springframework.asm.ClassVisitor as super class
java.lang.IncompatibleClassChangeError: class org.springframework.core.LocalVariableTableParameterNameDiscoverer$ParameterNameDiscoveringVisitor has interface org.springframework.asm.ClassVisitor as super class
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
If your app runs with run-app, you should be able to build with grails war and deploy that way instead of using Maven.
https://grails.github.io/grails-doc/latest/ref/Command%20Line/war.html
By default the war command creates a web application archive (WAR) file using the application name and version number. The war command is different from most commands since it runs in the production environment by default instead of development, but like any script the environment can be specified using the standard convention:

Resteasy deploy fails randomly on glassfish 4.1

I have a problem with my REST-Application using Resteasy.
When I deploy the application with this dependencies
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
<version>3.0.11.Final</version>
</dependency>
as described here in Chapter 3.5 sometimes the server deploys the application correctly and everything works fine.
But sometimes I get
Error invoking ServletContainerInitializer
org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer
java.lang.NullPointerException
at org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer.register(ResteasyServletInitializer.java:109)
at org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer.onStartup(ResteasyServletInitializer.java:80)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:6031)
at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:774)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5929)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:406)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:243)
at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:329)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:377)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:227)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:84)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
]]
In the sources of ResteasyServletInitializer line 109 is this (with context)
ServletRegistration.Dynamic reg = servletContext.addServlet(applicationClass.getName(), HttpServlet30Dispatcher.class);
reg.setLoadOnStartup(1); //Line 109
reg.setAsyncSupported(true);
reg.setInitParameter("javax.ws.rs.Application", applicationClass.getName());
So I assume this is a Glassfish bug and Glassfish fails to properly return the correct object.
I have not found that this happens with redeployments, after clearing osgi-cache, etc. It seems to be pretty random.
This seems to be related and I tried adding
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
But it still fails sometimes although I would say it fails a little bit less often.
The accepted answer from the post is deprecated as by the resteasy reference 3.9. RESTEasy as a ServletContextListener so I do not want to try this.
This seems like avoiding the problem, not solving it.
My Glassfish version is GlassFish Server Open Source Edition 4.1 (build 13).
Please help me with this one.
Cheers
I ended up avoiding this issue by ensuring the application WAR did not include RESTEasy.
So I build two wars now: one with RESTEasy (as required for deploying on Tomcat and Wildfly), another without (for deploying on Glassfish). That seems better than requiring changing the Glassfish install, but accomplishes the same: avoids having two JAX-RS implementations installed.

NoSuchMethodError on startup in Java Jersey app

I've been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey version is being loaded, I think?
Any pointers in the right direction will be appreciated.
Here's the effective pom: http://pastebin.com/NacsWTjz
And the actual pom: http://pastebin.com/H6sHe4ce
2015-02-13 13:43:40,870 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/middleware-server] - StandardWrapper.Throwable
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Note: Please see above comments for further discussion and tips.
This error usual means that you have a both a JAX-RS 1 and JAX-RS 2 jar on the classpath. Jersey 2 uses JAX-RS 2 (javax.ws.rs-api-2.0.1.jar), but if you have the jsr311-api.jar also, which is JAX-RS 1, there is a javax.ws.rs.core.Application in each jar. But the jsr311-api Application doesn't have the method getProperties() (hence NoSuchMethodError).
I've come to the conclusion that all you need to do is add the above exclusion to the swagger dependency. The Jackson 2.0 provider (which depends on JAX-RS 1) seems to be overridden by a 2.4.1 provider (which uses the new version). So we don't need to add it ourselves. When it's overridden, it seems to leave behind the jsr311-api.jar. So if we exclude it, no one can attempt to use it, which looks to be the current problem
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.11</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
We are using jersey-json 1.9 which has a dependency on jersey-core which also happen to have a javax.ws.rs.core.Application class.
So our fix is to exclude the jersey-core from jersey-json:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
</exclusions>
</dependency>
the problem is related about "com.sun.jersey:jersey-core:jar:1.18.3" (or any 1.* version) because old versions of Jersey didn't have that "public Map getProperties()" method.
And one of your dependencies use Jersey version 1 (you can check that in running mvn dependency:tree and search all jersey-core version used)
Me I have resolved the problem deleting all com.sun.jersey dependancies (old api) and using the new one org.glassfish.jersey API
https://mvnrepository.com/artifact/org.glassfish.jersey.core

java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.includeClassesUrl

I am getting following exceptions while deploying i am using tomcat 7. I am using netbeans7.4 for development.
I have included struts2.3.15 jar files and hibernet jar files.
SEVERE: Exception starting filter struts2
java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.includeClassesUrl(Lcom/opensymphony/xwork2/util/finder/ClassLoaderInterface;Lcom/opensymphony/xwork2/util/finder/UrlSet$FileProtocolNormalizer;)Lcom/opensymphony/xwork2/util/finder/UrlSet;
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildUrlSet(PackageBasedActionConfigBuilder.java:442)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.readUrls(PackageBasedActionConfigBuilder.java:410)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:389)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:347)
at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4746)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5399)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
How to resolve this.
java.lang.NoSuchMethodError:
Error is Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.
Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
Try to download latest version of jar file
NoSuchMethodError: is generally thrown when there is conflict for the methods in included jars or may be due to different version of included dependent jars. Try removing unnecessary jars and if still issue is not resolved check the version of included jars

Categories

Resources