conflict in slf4j dependency - spring-boot

I`m using spring boot 2.6.6 and logback and slf4j. when I run application in my local computer in IntellijA IDE using "Run configuration", application starts normally. but when I build app with goal "clean package" and then run with command line "java -jar myApp.war" the following error occures:
SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.context.logging.LoggingApplicationListener
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:438)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:431)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:263)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:241)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at com.fanap.kidzy.vidzy.VidzyApplication.main(VidzyApplication.java:16)
... 8 more
Caused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1088)
at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1074)
at org.springframework.boot.context.properties.bind.Bindable.mapOf(Bindable.java:267)
at org.springframework.boot.context.logging.LoggingApplicationListener.<clinit>(LoggingApplicationListener.java:98)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:452)
... 15 more
I analyzed the pom with "dependency analyzer" plugin but slf4j 1.7.6 or 1.6 not exists!

Related

Jacoco integration with Spring boot app giving Error while instrumenting

I have to get the coverage for my integration tests for spring boot app. Now when I am trying to use javaagent in startup for my spring boot app I am getting an error . Also I have used the below args in JAVA_OPTS
-javaagent:/tmp/jacocoagent.jar=destfile=/mnt/shared/jacoco.exec
at org.jacoco.agent.rt.internal_035b120.CoverageTransformer.transform(CoverageTransformer.java:93)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:459)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
Caused by: java.io.IOException: Error while instrumenting xxx/xxx/core/config/CoreAutoConfiguration$$FastClassBySpringCGLIB$$e1df4252.
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrumentError(Instrumenter.java:158)
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrument(Instrumenter.java:108)
at org.jacoco.agent.rt.internal_035b120.CoverageTransformer.transform(CoverageTransformer.java:91)
... 52 more
Caused by: java.lang.IllegalStateException: Cannot process instrumented class xxx/xxx/core/config/CoreAutoConfiguration$$FastClassBySpringCGLIB$$e1df4252. Please supply original non-instrumented classes.
at org.jacoco.agent.rt.internal_035b120.core.internal.instr.InstrSupport.assertNotInstrumented(InstrSupport.java:237)
at org.jacoco.agent.rt.internal_035b120.core.internal.instr.ClassInstrumenter.visitField(ClassInstrumenter.java:55)
at org.jacoco.agent.rt.internal_035b120.asm.ClassVisitor.visitField(ClassVisitor.java:287)
at org.jacoco.agent.rt.internal_035b120.asm.ClassReader.readField(ClassReader.java:906)
at org.jacoco.agent.rt.internal_035b120.asm.ClassReader.accept(ClassReader.java:683)
at org.jacoco.agent.rt.internal_035b120.asm.ClassReader.accept(ClassReader.java:400)
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrument(Instrumenter.java:88)
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrument(Instrumenter.java:106)
... 53 more
java.lang.instrument.IllegalClassFormatException: Error while instrumenting xxx/xxx/core/config/CoreAutoConfiguration$$EnhancerBySpringCGLIB$$e954c394$$FastClassBySpringCGLIB$$3d9ac05.
at org.jacoco.agent.rt.internal_035b120.CoverageTransformer.transform(CoverageTransformer.java:93)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:459)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
Caused by: java.io.IOException: Error while instrumenting xxx/xxx/core/config/CoreAutoConfiguration$$EnhancerBySpringCGLIB$$e954c394$$FastClassBySpringCGLIB$$3d9ac05.
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrumentError(Instrumenter.java:158)
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrument(Instrumenter.java:108)
at org.jacoco.agent.rt.internal_035b120.CoverageTransformer.transform(CoverageTransformer.java:91)
... 52 more
Caused by: java.lang.IllegalStateException: Cannot process instrumented class xxx/xxx/core/config/CoreAutoConfiguration$$EnhancerBySpringCGLIB$$e954c394$$FastClassBySpringCGLIB$$3d9ac05. Please supply original non-instrumented classes.
at org.jacoco.agent.rt.internal_035b120.core.internal.instr.InstrSupport.assertNotInstrumented(InstrSupport.java:237)
at org.jacoco.agent.rt.internal_035b120.core.internal.instr.ClassInstrumenter.visitField(ClassInstrumenter.java:55)
at org.jacoco.agent.rt.internal_035b120.asm.ClassVisitor.visitField(ClassVisitor.java:287)
at org.jacoco.agent.rt.internal_035b120.asm.ClassReader.readField(ClassReader.java:906)
at org.jacoco.agent.rt.internal_035b120.asm.ClassReader.accept(ClassReader.java:683)
at org.jacoco.agent.rt.internal_035b120.asm.ClassReader.accept(ClassReader.java:400)
at org.jacoco.agent.rt.internal_035b120.core.instr.Instrumenter.instrument(Instrumenter.java:88)

why I am getting java.lang.ClassNotFoundException:com.google.api.client.json.JsonFactory when running on OSGi framework

I am new to OSGi and I made a method which will call the Google translate API. When I called that method in a main it is working fine. And also I used Eclipse for coding and exported the project into a jar file from Eclipse and installed it on the apache felix framework. When I start the bundle I get the following exceptions,
I added all the external jar files to build path also.
org.osgi.framework.BundleException: Activator start error in bundle EnglishToSinhalaServicePublisher [58].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2452)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.gogo.command.Basic.start(Basic.java:739)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:139)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
at englishtosinhalaservicepublisher.Activator.start(Activator.java:46)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:698)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2402)
... 19 more
Caused by: java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory not found by EnglishToSinhalaServicePublisher [58]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1597)
at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 22 more
java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
g!

Hygieia Installation Error

We got this error while Hygieia dashboard installation. Please confirm if anyone has come across this. this looks related to spring boot and got it while I was installing the UI for Hygieia
2017-07-11 20:50:41,551 ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat servlet container
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:165) ~[spring-boot-1.3.0.RELEASE.jar!/:
1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:290) ~[spring-boot-1.3.0
.RELEASE.jar!/:1.3.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) ~[spring-boot-1.3.0.RELEASE.jar!/:1
.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar!/:1.3.0.R
ELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) ~[spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) ~[spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) [spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
at com.capitalone.dashboard.Application.main(Application.java:37) [api.jar!/:2.0.5-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_131]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [api.jar!/:2.0.5-SNAPSHOT]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_131]
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159) ~[spring-boot-1.3.0.RELEASE.jar!/:
1.3.0.RELEASE]
... 15 common frames omitted
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat servlet container
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:165)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:290)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
at com.capitalone.dashboard.Application.main(Application.java:37)
... 6 more
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159)
... 15 more
Is this the full log ? You should always send the complete log.
Besides your question is wrong, there is nothing to install as far as Hygieia is considered.
there are simple steps that one needs to follow, namely -
1.Get the repo in you system
2.setup all the requirements of Hygieia (Mongodb, maven etc etc)
3.mvn clean install on the root directory
Create proper properties file for the jars
Run Hygieia
But Even I have faced a lot of problems with setting up Hygieia, so you should take care of these -
Always get the fresh/latest code from github
If you are on corporate/Company N/W then do ensure you have proxies to maven and system proxy setup.
If you add the full trace log then I just might get the problem
You need to follow some steps
Download Hygieia rep from this link:
https://github.com/Hygieia/Hygieia
Install maven and java :-
https://linuxize.com/post/how-to-install-apache-maven-on-ubuntu-18-04/
Also need to download subdivision-collector folder inside this directory
Hygieia/collectors/scm:-
https://github.com/Hygieia/hygieia-scm-subversion-collector
Now open \Hygieia folder and run
$ mvn clean install

Runnable JAR file error: Unsupported major.minor version 51.0

I made an application in Java (version 7) with Eclipse (Indigo) when I exported my application interface on a Runnable JAR file on my computer and tried it worked fine, then I tried on another computer and I get this problem
Exception in thread "main" java.lang.UnsupportedClassVersionError: cliente/Princ
ipal : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:56)
I saw other post that this can be because the other computer have an older version of Java than mine, can somebody confirm this please?.
Yes, that is the error when you try to run Java bytecode with an older version that the version you build it with.
You will find more information in this question.

Tomcat 7 : Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

I have installed tomcat7 in my windows xp pc and on starting the service, i cannot access localhost:8080 in my browser and found the following in tomcat7 log files.
2013-05-15 15:00:30 Commons Daemon procrun stderr initialized
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number
in class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Tomcat 7 requires a minimum of Java 6. The most likely cause is that you are trying to run Tomcat on Java 5 or earlier.
The alternative is that you have added something to your Tomcat install that has been compiled with a later version of Java that you are running. In this case, get a clean Tomcat install running first and then deal with the class version problem (either by running Tomcat with a later version of Java or by recompiling whatever it is you have added for Java 6 or earlier).

Resources