I am having some difficulty configuring some loggers for velocity in Spring. I am using Velocity 2.1, Spring 5.2.2 and SLF4J 2.0.0
org.slf4j.simple.SimpleLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
I am trying to configure some old discarded Spring classes to build a JAR (new versions of them) to use in my application.
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, (new SimpleLoggerFactory()).getLogger("SpringVelocityConfiguration"));
This is how I am doing it. But I keep getting the exception.
The line throwing the exception is from org.apache.velocity.runtime.RuntimeInstance:
if (Logger.class.isAssignableFrom(o.getClass()))
From what I saw from the API documentation, SimpleLogger is a subclass to Logger. So it should work out isn't it?
Adding the dependency tree as requested:
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) # spring-velocity-support ---
[INFO] com.gtt.palabs:spring-velocity-support:jar:0.0.1-SNAPSHOT
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha1:provided
[INFO] +- org.slf4j:slf4j-simple:jar:2.0.0-alpha1:compile
[INFO] +- org.springframework:spring-context:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-beans:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-core:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-web:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:provided
[INFO] +- org.apache.velocity:velocity-engine-core:jar:2.1:provided
[INFO] | \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.apache.velocity.tools:velocity-tools-generic:jar:3.0:provided
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- org.apache.commons:commons-digester3:jar:3.2:compile
[INFO] | | \- cglib:cglib:jar:2.2.2:compile
[INFO] | | \- asm:asm:jar:3.3.1:compile
[INFO] | \- com.github.cliftonlabs:json-simple:jar:3.0.2:provided
[INFO] \- org.apache.velocity.tools:velocity-tools-view:jar:3.0:compile
Error:
org.apache.velocity.exception.VelocityException: Error initializing log: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:958)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:260)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:90)
at com.gtt.logicalprovisioning.velocity.utilities.VelocityBuilderSystem.<init>(VelocityBuilderSystem.java:69)
at com.gtt.logicalprovisioning.ipflex.VelocityBuilderAction.processAction(VelocityBuilderAction.java:158)
at com.gtt.logicalprovisioning.rtp.BaseActionListType.run(BaseActionListType.java:72)
Caused by: org.apache.velocity.exception.VelocityException: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:931)
... 5 more
The log line says it all:
org.apache.velocity.exception.VelocityException: Error initializing log:
com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger
object set as runtime.log.instance
is not a valid org.slf4j.Logger implementation.
It means that the old Spring classes you are working with do overwrite the runtime.instance.log property before Velocity initialization is carried on.
Related
I haven't changed its pom.xml for this project, but when I started the project recently, it reported this error: java.lang.NoSuchMethodError.
Seeing the error, it seems that it can't find the interface method I wrote.
2020-07-21 10:23:05.212 ERROR [main] ApiDescriptionReader::read[#87] : Skipping process path[/projects], method[addProject] as it has an error.java.lang.NoSuchMethodError: org.springframework.http.MediaType.equalsTypeAndSubtype(Lorg/springframework/util/MimeType;)Z
at springfox.documentation.builders.BodyParameterSpecificationProvider.lambda$create$0(BodyParameterSpecificationProvider.java:37)
... ...
I tried mvn clean install, it still doesn't work. This is the io.springfox dependency tree:
[INFO] +- org.springframework.retry:spring-retry:jar:1.2.4.RELEASE:compile
[INFO] | \- org.springframework:spring-core:jar:5.0.7.RELEASE:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.0.7.RELEASE:compile
[INFO] +- org.mybatis.spring.boot:mybatis-spring-boot-starter:jar:2.0.0:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.3.RELEASE:compile
[INFO] | \- org.springframework:spring-jdbc:jar:5.0.7.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:5.0.7.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-webflux:jar:2.0.3.RELEASE:compile
[INFO] | +- org.springframework:spring-web:jar:5.0.7.RELEASE:compile
[INFO] | \- org.springframework:spring-webflux:jar:5.0.7.RELEASE:compile
[INFO] \- org.springframework.plugin:spring-plugin-core:jar:2.0.0.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:5.0.7.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.0.7.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.0.7.RELEASE:compile
[INFO] \- org.springframework:spring-aop:jar:5.0.7.RELEASE:compile
[INFO] +- io.springfox:springfox-swagger2:jar:3.0.0-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-spi:jar:3.0.0-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-schema:jar:3.0.0-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:3.0.0-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:3.0.0-SNAPSHOT:compile
[INFO] | \- io.springfox:springfox-spring-webmvc:jar:3.0.0-SNAPSHOT:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:3.0.0-SNAPSHOT:compile
[INFO] \- io.springfox:springfox-spring-webflux:jar:3.0.0-SNAPSHOT:compile
[INFO] \- io.springfox:springfox-core:jar:3.0.0-SNAPSHOT:compile
According to the documentation this method exists since spring 5.1.4
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/util/MimeType.html#equalsTypeAndSubtype-org.springframework.util.MimeType-
You can update the version of spring that you use or decrease the version of spring-fox
I'm having a strange problem with maven. I'm not sure yet what it is but it seems that when compiling my project (with mvn clean compile) somehow a wrong version of a dependency seems to be included.
The library I want to include is commons-io version 2.4. When I check my IDE it looks like the correct version is loaded. Compiling in my IDE works fine.
However when I compile the project with maven this line of code fails:
FileUtils.write(new File(propertyService.getStatusPageLocation()), "Some string value");
Because of the error:
[ERROR] /C:/projects/my-project/client-externalclient/src/main/java/be/roots/myproject/client/externalclient/jobs/WriteStatusPageJob.java:[60,22] cannot find symbol
[ERROR] symbol: method write(java.io.File,java.lang.String)
As far as I can tell the class does have the method with that signature.
The problem seems to happen only on my pc.
A dependency:tree command shows the following info:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # shared-internal ---
[INFO] be.roots.myproject:shared-internal:bundle:3.40-SNAPSHOT
[INFO] +- be.roots.myproject:shared-external:jar:3.40-SNAPSHOT:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.7:runtime
[INFO] | \- log4j:log4j:jar:1.2.17:runtime
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:3.0.4.redhat-621107:compile
[INFO] | +- org.apache.cxf:cxf-core:jar:3.0.4.redhat-621107:compile
[INFO] | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
[INFO] | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.1:compile
[INFO] | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | \- org.apache.cxf:cxf-rt-transports-http:jar:3.0.4.redhat-621107:compile
[INFO] +- joda-time:joda-time:jar:2.5:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | \- org.objenesis:objenesis:jar:2.1:test
[INFO] +- org.powermock:powermock-api-mockito:jar:1.6.2:test
[INFO] | +- org.mockito:mockito-all:jar:1.10.19:test
[INFO] | \- org.powermock:powermock-api-support:jar:1.6.2:test
[INFO] | +- org.powermock:powermock-core:jar:1.6.2:test
[INFO] | | \- org.javassist:javassist:jar:3.19.0-GA:test
[INFO] | \- org.powermock:powermock-reflect:jar:1.6.2:test
[INFO] +- org.powermock:powermock-module-junit4:jar:1.6.2:test
[INFO] | \- org.powermock:powermock-module-junit4-common:jar:1.6.2:test
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.apache.camel:camel-sql:jar:2.15.1.redhat-621107:compile
[INFO] | +- org.apache.camel:camel-core:jar:2.15.1.redhat-621107:compile
[INFO] | +- org.springframework:spring-jdbc:jar:3.2.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-tx:jar:3.2.12.RELEASE:compile
[INFO] | +- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.2.11:compile
[INFO] +- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.1.redhat-7:test
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- com.jcraft:jsch:jar:0.1.51:compile
[INFO] +- org.springframework:spring-core:jar:3.2.12.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.springframework:spring-context-support:jar:3.2.12.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:3.2.12.RELEASE:compile
[INFO] | \- org.springframework:spring-context:jar:3.2.12.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.2.12.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile
[INFO] +- commons-net:commons-net:jar:3.3:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.6.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.6.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.3:compile
[INFO] | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.6.3:compile
[INFO] | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] +- javax:javaee-web-api:jar:6.0:provided
[INFO] \- be.roots:zxing-osgi:jar:1.0:compile
[INFO] +- com.google.zxing:javase:jar:2.3.0:compile
[INFO] \- com.google.zxing:core:jar:2.3.0:compile
which also shows the correct library being loaded.
the dependency:build-classpath command gives this list:
C:\Users\MyName\.m2\repository\be\roots\myproject\shared-external\3.40-SNAPSHOT\shared-external-3.40-SNAPSHOT.jar;C:\Users\MyName\.m2\repository\org\slf4j\slf4j-log4j12\1.7.7\slf4j-log4j12-1.7.7.jar;C:\Users\MyName\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Users\MyName\.m2\repository\org\apache\cxf\cxf-rt-frontend-jaxrs\3.0.4.redhat-621107\cxf-rt-frontend-jaxrs-3.0.4.redhat-621107.jar;C:\Users\MyName\.m2\repository\org\apache\cxf\cxf-core\3.0.4.redhat-621107\cxf-core-3.0.4.redhat-621107.jar;C:\Users\MyName\.m2\repository\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;C:\Users\MyName\.m2\repository\org\apache\ws\xmlschema\xmlschema-core\2.2.1\xmlschema-core-2.2.1.jar;C:\Users\MyName\.m2\repository\javax\ws\rs\javax.ws.rs-api\2.0.1\javax.ws.rs-api-2.0.1.jar;C:\Users\MyName\.m2\repository\javax\annotation\javax.annotation-api\1.2\javax.annotation-api-1.2.jar;C:\Users\MyName\.m2\repository\org\apache\cxf\cxf-rt-transports-http\3.0.4.redhat-621107\cxf-rt-transports-http-3.0.4.redhat-621107.jar;C:\Users\MyName\.m2\repository\joda-time\joda-time\2.5\joda-time-2.5.jar;C:\Users\MyName\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\MyName\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\MyName\.m2\repository\org\mockito\mockito-core\1.10.19\mockito-core-1.10.19.jar;C:\Users\MyName\.m2\repository\org\objenesis\objenesis\2.1\objenesis-2.1.jar;C:\Users\MyName\.m2\repository\org\powermock\powermock-api-mockito\1.6.2\powermock-api-mockito-1.6.2.jar;C:\Users\MyName\.m2\repository\org\mockito\mockito-all\1.10.19\mockito-all-1.10.19.jar;C:\Users\MyName\.m2\repository\org\powermock\powermock-api-support\1.6.2\powermock-api-support-1.6.2.jar;C:\Users\MyName\.m2\repository\org\powermock\powermock-core\1.6.2\powermock-core-1.6.2.jar;C:\Users\MyName\.m2\repository\org\javassist\javassist\3.19.0-GA\javassist-3.19.0-GA.jar;C:\Users\MyName\.m2\repository\org\powermock\powermock-reflect\1.6.2\powermock-reflect-1.6.2.jar;C:\Users\MyName\.m2\repository\org\powermock\powermock-module-junit4\1.6.2\powermock-module-junit4-1.6.2.jar;C:\Users\MyName\.m2\repository\org\powermock\powermock-module-junit4-common\1.6.2\powermock-module-junit4-common-1.6.2.jar;C:\Users\MyName\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\MyName\.m2\repository\org\apache\camel\camel-sql\2.15.1.redhat-621107\camel-sql-2.15.1.redhat-621107.jar;C:\Users\MyName\.m2\repository\org\apache\camel\camel-core\2.15.1.redhat-621107\camel-core-2.15.1.redhat-621107.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-jdbc\3.2.12.RELEASE\spring-jdbc-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-tx\3.2.12.RELEASE\spring-tx-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\com\sun\xml\bind\jaxb-core\2.2.11\jaxb-core-2.2.11.jar;C:\Users\MyName\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.11\jaxb-impl-2.2.11.jar;C:\Users\MyName\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\Users\MyName\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\MyName\.m2\repository\commons-collections\commons-collections\3.2.1.redhat-7\commons-collections-3.2.1.redhat-7.jar;C:\Users\MyName\.m2\repository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;C:\Users\MyName\.m2\repository\com\jcraft\jsch\0.1.51\jsch-0.1.51.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-core\3.2.12.RELEASE\spring-core-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-context-support\3.2.12.RELEASE\spring-context-support-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-beans\3.2.12.RELEASE\spring-beans-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-context\3.2.12.RELEASE\spring-context-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-aop\3.2.12.RELEASE\spring-aop-3.2.12.RELEASE.jar;C:\Users\MyName\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\MyName\.m2\repository\org\springframework\spring-expression\4.1.6.RELEASE\spring-expression-4.1.6.RELEASE.jar;C:\Users\MyName\.m2\repository\commons-net\commons-net\3.3\commons-net-3.3.jar;C:\Users\MyName\.m2\repository\com\google\guava\guava\18.0\guava-18.0.jar;C:\Users\MyName\.m2\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-xml\2.6.3\jackson-dataformat-xml-2.6.3.jar;C:\Users\MyName\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.6.3\jackson-core-2.6.3.jar;C:\Users\MyName\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.6.3\jackson-annotations-2.6.3.jar;C:\Users\MyName\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.6.3\jackson-databind-2.6.3.jar;C:\Users\MyName\.m2\repository\com\fasterxml\jackson\module\jackson-module-jaxb-annotations\2.6.3\jackson-module-jaxb-annotations-2.6.3.jar;C:\Users\MyName\.m2\repository\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;C:\Users\MyName\.m2\repository\javax\javaee-web-api\6.0\javaee-web-api-6.0.jar;C:\Users\MyName\.m2\repository\be\roots\zxing-osgi\1.0\zxing-osgi-1.0.jar;C:\Users\MyName\.m2\repository\com\google\zxing\javase\2.3.0\javase-2.3.0.jar;C:\Users\MyName\.m2\repository\com\google\zxing\core\2.3.0\core-2.3.0.jar
Does anyone know what else I can try to debug this issue?
Something that can be different between your IDE and the mvn command is the Java version employed. Please check your PATH
Check your maven settings in your ide.
It is possible to have a different maven path and a custom settings.xml in the IDE selected.
I have found what was wrong, it turned out to be a rather exotic problem.
For another project I have installed the advanced image API (http://www.oracle.com/technetwork/java/javase/tech/jai-142803.html) which involves adding extra .jar files to your java sdk that will be included in your core java installation.
Among all the libary's .jar files was an older version of commons-io as well, which was included as the default.
Once I removed that library everything went well.
I am trying to resolve an issue with a spring jar. I am using very old jars for A very old project.
For one project my dependency tree is having spring-core 2.0.1 and for the other it is having Spring-core 2.0.2 now. they both are coming as a dependency of one jar : spring-ws-core:jar:1.0-m3.
The issue I am having is the exception below: it turns out that the ClassUtils was changed from 2.0.1 to 2.0.2 and missed out this method. :
ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 94) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityLoadJob' defined in class path resource [dri-applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getConstructorIfAvailable(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:443)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:140)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:195)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
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)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.getConstructorIfAvailable(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.<clinit>(MethodInvokingJobDetailFactoryBean.java:73)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:84)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:60)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:52)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:640)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:626)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:381)
... 20 more
[INFO] com.sar.registry:MyServlet:war:1.0-SNAPSHOT
[INFO] +- com.sar.registry:DirectRegistry:jar:1.0-SNAPSHOT:compile
[INFO] | +- com.sar.common:Common-Utils:jar:SNAPSHOT:compile
[INFO] | +- com.sar.common:Common-Integration:jar:SNAPSHOT:compile
[INFO] | +- org.springframework:spring:jar:2.0.1:compile
***[INFO] | +- org.springframework.ws:spring-ws-core:jar:1.0-m3:compile***
[INFO] | | +- org.springframework.ws:spring-xml:jar:1.0-m3:compile
[INFO] | | +- org.springframework:spring-context:jar:2.0.1:compile
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | +- org.springframework:spring-web:jar:2.0.2:compile
[INFO] | | +- org.springframework:spring-webmvc:jar:2.0.2:compile
[INFO] | | | \- org.springframework:spring-support:jar:2.0.2:compile
[INFO] | | +- stax:stax-api:jar:1.0:compile (version managed from 1.0.1)
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.1:compile
***[INFO] | | +- org.springframework:spring-core:jar:2.0.1:compile
[INFO] | | \- org.springframework:spring-beans:jar:2.0.1:compile***
[INFO] | +- org.springframework.ws:spring-oxm:jar:1.0-m3:compile
[INFO] | +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] | +- xml-security:xmlsec:jar:1.3.0:compile
[INFO] | +- wss4j:wss4j:jar:1.5.0:compile
[INFO] | +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.3.16:provided (scope managed from compile)
[INFO] | | \- org.jvnet.mimepull:mimepull:jar:1.7:provided
[INFO] | +- quartz:quartz:jar:1.5.2:compile
[INFO] | \- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] +- com.sar.registry:MyAppApi:jar:1.0-SNAPSHOT:compile
[INFO] +- javax.servlet:servlet-api:jar:2.4:provided
[INFO] +- net.sf.saxon:saxon:jar:8.7:runtime
[INFO] +- org.springframework:spring-jmx:jar:2.0.1:runtime
[INFO] +- net.sf.saxon:saxon-dom:jar:8.7:runtime
[INFO] +- axis:axis:jar:1.4:runtime
[INFO] | +- axis:axis-wsdl4j:jar:1.5.1:runtime
[INFO] | \- commons-discovery:commons-discovery:jar:0.2:runtime
[INFO] +- taglibs:standard:jar:1.1.2:runtime
[INFO] +- javax.servlet:jstl:jar:1.1.2:runtime
[INFO] +- org.springframework:spring-mock:jar:2.0.1:test
[INFO] | \- junit:junit:jar:3.8.1:test
[INFO] +- xmlunit:xmlunit:jar:1.0:test
[INFO] \- hsqldb:hsqldb:jar:1.8.0.7:test
[INFO] ------------------------------------------------------------------------
and for the other:
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # MyApp ---
[INFO] com.sar.registry:MyApp:jar:1.0-SNAPSHOT
[INFO] +- com.sar.registry:MyAppApi:jar:1.0-SNAPSHOT:compile
[INFO] +- com.sar.common:Common-Utils:jar:SNAPSHOT:compile
[INFO] +- com.sar.common:Common-Integration:jar:SNAPSHOT:compile
[INFO] +- org.springframework:spring:jar:2.0.1:compile
***[INFO] +- org.springframework.ws:spring-ws-core:jar:1.0-m3:compile***
[INFO] | +- org.springframework.ws:spring-xml:jar:1.0-m3:compile
[INFO] | +- org.springframework:spring-context:jar:2.0.2:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-web:jar:2.0.2:compile
[INFO] | +- org.springframework:spring-webmvc:jar:2.0.2:compile
[INFO] | | \- org.springframework:spring-support:jar:2.0.2:compile
[INFO] | +- stax:stax-api:jar:1.0:compile (version managed from 1.0.1)
[INFO] | +- wsdl4j:wsdl4j:jar:1.6.1:compile
***[INFO] | +- org.springframework:spring-core:jar:2.0.2:compile
[INFO] | \- org.springframework:spring-beans:jar:2.0.2:compile***
[INFO] +- org.springframework.ws:spring-oxm:jar:1.0-m3:compile
[INFO] +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] +- xml-security:xmlsec:jar:1.3.0:compile
[INFO] +- wss4j:wss4j:jar:1.5.0:compile
[INFO] +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.3.16:compile
[INFO] | \- org.jvnet.mimepull:mimepull:jar:1.7:compile
[INFO] +- quartz:quartz:jar:1.5.2:compile
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- log4j:log4j:jar:1.2.8:test
[INFO] +- xmlunit:xmlunit:jar:1.0:test
[INFO] +- hsqldb:hsqldb:jar:1.8.0.7:test
[INFO] +- org.springframework:spring-mock:jar:2.0.1:test
[INFO] +- xerces:xercesImpl:jar:2.8.1:test
[INFO] +- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] +- net.sf.saxon:saxon:jar:8.7:test (scope not updated to runtime)
[INFO] +- net.sf.saxon:saxon-dom:jar:8.7:test
[INFO] \- axis:axis:jar:1.4:test
[INFO] +- org.apache.axis:axis-jaxrpc:jar:1.4:test
[INFO] +- org.apache.axis:axis-saaj:jar:1.4:test
[INFO] +- axis:axis-wsdl4j:jar:1.5.1:test
[INFO] \- commons-discovery:commons-discovery:jar:0.2:test
in my poms, I am not defining any versions for Spring-beans and Spring-core the only version I have defined is in the parent Pom which is org.springframework.ws:spring-ws-core:jar:1.0-m3:compile
Now how can two projects having the same jar can have different dependent jars altogether. I am on Maven3, wildfly9, java8.
Also, Somehow and strangely, the same war file works fine on my local windows wildfly9 but it gives me error on a SunOS and Linux machine.
Edit:
I got the dependencyTree Idea from NoSuchMethodError for XmlSchemaCollection.read()
and using that I found the two jars. As Harini suggested, I had already tried exclusion of the dependency and it still didn't work So I just refactored my code to have only one src and that too in the war (In wildfly war is loaded in its own classloader with its libs) So after refactoring as well, I got the same issue:
How I got to know that it was the jar issue was I did a verbose on my jvm and saw this:
[Loaded org.springframework.util.ClassUtils from vfs:/content/DirectRegistryServlet-1.0-SNAPSHOT.war/WEB-INF/lib/spring-core-2.0.1.jar]
In the spring-ws-core:jar:1.0-m3 dependency exclude the spring-core version which you are not using.Check it out for Dependency Exclusions.
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
Upon looking at the code of org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean which I am using which is actually the one causing the issue it turns out that in spring 2.0.1 this FactoryBean does not have any mention of the ClassUtils.getConstructorIfAvailable which is good. It is the Spring-2.0.2 OR spring-support-2.0.2.jar That also has this class with this line where this call is.
(I was looking at the wrong class as the issue the issue was MethodInvokingJobDetailFactoryBean coming from a different jar instead of coming from spring-2.0.1.jar, Spring-ws-2.0.1actually uses spring-mvc which uses spring-support2.0.2.jar which had the same MethodInvokingJobDetailFactoryBean ) SO I solved it: Made only one library to get the MethodInvokingJobDetailFactoryBean removed the library or excluded the library that also had this class and solved it.
Strangely I cant understand how on windows it was working without an issue and on Linux and unix it gave an issue.
I downloaded OWL API (4.0.1 and 4.0.2). But it needed plenty of dependencies that are nowhere mentioned. I downloaded dependency JARs from maven pom.xml file (found it somewhere for version OWL API 4.0.1). List of jars:
First of all, it was error with RDFFormat (need to add sesame lib, which was not in pom.xml.
But I still have "NoSuchMethodError" errors.
First one was
com.google.common.base.Objects.firstNonNull
(with Guava 17.0).I updated it to 18.0, now its
com.google.common.base.Platform.systemNanoTime
Here on stackoverflow is answer for this:
You most likely have both a recent version of Guava and either
google-collect or a version of Guava prior to 3.0 on your classpath
But no, I dont have old Guava lib named google-collect(ions).
Maven dependencies are transitive. If you don't want to use Maven for some reason you'll need to include all of them. Here's the dependency tree for owlapi 4.0.2.
[INFO] \- net.sourceforge.owlapi:owlapi-distribution:jar:4.0.2:compile
[INFO] +- org.openrdf.sesame:sesame-model:jar:2.7.12:compile
[INFO] | \- org.openrdf.sesame:sesame-util:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-binary:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-n3:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-nquads:jar:2.7.12:compile
[INFO] | \- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.openrdf.sesame:sesame-rio-ntriples:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-rdfjson:jar:2.7.12:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.2.1:compile
[INFO] +- org.openrdf.sesame:sesame-rio-rdfxml:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-trix:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-turtle:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-trig:jar:2.7.12:compile
[INFO] +- com.github.jsonld-java:jsonld-java-sesame:jar:0.5.0:compile
[INFO] | \- com.github.jsonld-java:jsonld-java:jar:0.5.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient-cache:jar:4.2.5:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.2.4:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
[INFO] +- org.semarglproject:semargl-sesame:jar:0.6.1:compile
[INFO] | +- org.semarglproject:semargl-core:jar:0.6.1:compile
[INFO] | \- org.semarglproject:semargl-rdfa:jar:0.6.1:compile
[INFO] | \- org.semarglproject:semargl-rdf:jar:0.6.1:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- com.google.inject:guice:jar:4.0-beta:compile
[INFO] | +- javax.inject:javax.inject:jar:1:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- com.google.inject.extensions:guice-multibindings:jar:4.0-beta:compile
[INFO] +- com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.io:jar:2.4:compile
[INFO] \- net.sf.trove4j:trove4j:jar:3.0.3:compile
For the most part, your life will be much easier using Maven (or some other modern build tool). It deals with dependency issues like this so you don't have to. If you're stuck with ant for some reason you could also take a look at ivy.
Thank you for you responses. I use
-verbose:class
and found out, that package for that class is from
gephi-toolkit.jar
Tt has google-collection too ... so yeah, different versions.
I am working on Hibernate3 Spring3 project starter with Tomcat 7,
I am struggling with this ClassNotFoundException - of aopalliance interceptor Jar (is this AspectJ??)
This despite the fact that the Jar exist is in the class-path.
What I don't understand from maven is, where do I use this Jar - who is dependent on this Jar?
[INFO] +- org.hibernate:hibernate-core:jar:3.3.2.GA:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- javax.transaction:jta:jar:1.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.3.2.GA:compile
[INFO] | +- org.hibernate:hibernate:jar:3.2.6.ga:compile
[INFO] | | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] | | \- asm:asm-attrs:jar:1.5.3:compile
[INFO] | +- org.hibernate:hibernate-annotations:jar:3.3.1.GA:compile
[INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.0.0.ga:compile
[INFO] | +- org.hibernate:ejb3-persistence:jar:1.0.1.GA:compile
[INFO] | \- javassist:javassist:jar:3.4.GA:compile
[INFO] +- junit:junit:jar:4.8.1:test
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] +- javax.servlet:servlet-api:jar:2.4:compile
Here is the problematic jar:
[INFO] +- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.0.5.RELEASE:test
[INFO] +- org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile
...
who is dependent on this Jar?
The Spring framework needs it for Spring AOP. Stand-alone AspectJ does not need it.