An attempt was made to call the method but it does not exist - spring

An attempt was made to call the method org.springframework.core.annotation.AnnotationUtils.isCandidateClass(Ljava/lang/Class;Ljava/lang/Class;)Z but it does not exist. Its class, org.springframework.core.annotation.AnnotationUtils, is available from the following locations:
jar:file:/C:/Users//.m2/repository/org/springframework/spring-core/5.1.3.RELEASE/spring-core-5.1.3.RELEASE.jar!/org/springframework/core/annotation/AnnotationUtils.class
It was loaded from the following location:
file:/C:/Users//.m2/repository/org/springframework/spring-core/5.1.3.RELEASE/spring-core-5.1.3.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.core.annotation.AnnotationUtils
Help me!

Please check maven dependency::tree, it must be some jar package(spring core with difference version) conflict.

Related

App not starting because of guava conflict-Correct the classpath of your application so that it contains a single, compatible version of MoreExecutors

APPLICATION FAILED TO START
Description:
An attempt was made to call the method com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService; but it does not exist. Its class, com.google.common.util.concurrent.MoreExecutors, is available from the following locations:
jar:file:/webapps/my-app/WEB-INF/lib/guava-30.1.0.jre-redhat-00003.jar!/com/google/common/util/concurrent/MoreExecutors.class
It was loaded from the following location:
file:/webapps/my-app/WEB-INF/lib/guava-30.1.0.jre-redhat-00003.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.util.concurrent.MoreExecutors
I'm using just the one dependency and cant see any conflicts.

Quarkus uber/fat jar name: does not respect project.build.finalName in version 1.13.3.Final as doc suggests

I find that Quarkus uber/fat jar name is not controlled by project.build.finalName in version 1.13.3.Final, but by <quarkus.package.output-name> or property quarkus.package.output-name. Is this a bug?
The fast-jar indeed does not respect this proprerty because everything it generates is put into a dedicated directory with a fixed name.
If the uber-jar is not respecting the property,then yeah that's a bug and please report
Add the following properties
quarkus.package.type=uber-jar
quarkus.package.runner-suffix=runner
quarkus.package.output-name=custom_name_jar

Unable to load Multimaps when added dependency with Apache Hive

I have added dependency guava for using Multimaps and also I have added Hive dependency in my project.
I am getting the following error while compiling application.
An attempt was made to call the method com.google.common.collect.Multimaps.asMap(Lcom/google/common/collect/ListMultimap;)Ljava/util/Map; but it does not exist. Its class, com.google.common.collect.Multimaps, is available from the following locations:
jar:file:/Users/sreenivas/.m2/repository/org/apache/hive/hive-exec/1.2.1/hive-exec-1.2.1.jar!/com/google/common/collect/Multimaps.class
jar:file:/Users/sreenivas/.m2/repository/com/google/guava/guava/25.1-jre/guava-25.1-jre.jar!/com/google/common/collect/Multimaps.class
It was loaded from the following location:
file:/Users/sreenivas/.m2/repository/org/apache/hive/hive-exec/1.2.1/hive-exec-1.2.1.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.Multimaps.
Can anyone suggest me how to take the latest version dependency.
It is caused by the package hive-exec include /com/google/common/collect/Multimaps.class, as shown in picture:
If you have to include these two jar (hive-exec-1.2.1.jar and guava-25.1-jre.jar), you'd better fix hive-exec's source code and repackage it.

How to troubleshoot java.lang.NoSuchMethodError?

I know that a java.lang.NoSuchMethodError means that the version of a class used for compiling is different from the version used at runtime. Usually, when I see this issue, I start the app.server in java -verbose mode, which tells me the jar file from which a class is loaded. If that jar file is not the one I intended to use, I know I'm using an incorrect version of the jar file.
Another approach I use, is to use javap to look at the method signatures of the class in the jar file I am using at runtime, to confirm that the jar does indeed contain the class with a different method signature.
I am seeing this error now in Karaf, an OSGi container and none of the above approaches are helping. java -verbose shows me the jar, javap shows me the method signature and the method signature is the same as that in the error stacktrace. In other words, I can see that the class from the jar being used at runtime does have the same method signature that the jvm says it cannot find.
Here is the exact stack trace, if it helps:
java.lang.NoSuchMethodError: org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/axiom/soap/SOAPModelBuilder;
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:179)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.wso2.carbon.authenticator.stub.AuthenticationAdminStub.login(AuthenticationAdminStub.java:659)
Are there any other approaches I can/should use? Thanks for your help.
The Karaf commands exports [ids], imports [ids] and classes [ids] can used in combination with grep (each command has a --help option).
From the bundle throwing the error (with id N), imports N | grep org.apache.axiom.om will tell you which bundle it is actually importing that package from.
And approaching from the other side, exports | grep org.apache.axiom.om will list the bundles that export that package.
I'd expect you'll see more than one line from the exports and the import command will show incorrect version is being used.
You could also use java -verbose:class to see where classes are loaded from, which might show that the problematic class is loaded from a different bundle that you expected.

I've already added tools.jar in classpath, why still java.lang.NoClassDefFoundError: com.sun.jdi.Bootstrap thrown?

I'm using the HotSwap function of javassist, it requires tools.jar in classpath, so I added -cp tools.jar when start my OSGi appliction. But when I new HotSwap() in the code of one of the bundles,
java.lang.NoClassDefFoundError: com.sun.jdi.Bootstrap
was thrown. com.sun.jdi.Bootstrap is in the tools.jar and I've already added it in classpath and also I verified it worked because if not, the following code will not work:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
The Classloader of HotSwapper cannot load classcom.sun.jdi.Bootstrap? Then why it works properly in my Eclipse environment?(I added tools.jar into the libraries of Build path)
On why NoClassDefFoundError, any clue is appreciated.
You have to make sure the system bundle exports this package. For example in Felix the file jre.properties defines what packages are exported by the system bundle. Add the package com.sun.jdi there and it should work.
In eclipse this is done in config.ini. You can use org.osgi.framework.system.packages.extra= to define additional packages to export. I would rather not use boodelegation=* as it might export unwanted packages too. See:
http://www.eclipse.org/forums/index.php/m/734358/
http://wiki.eclipse.org/Equinox_Boot_Delegation
In Equinox, you can set Boot Delegation to * to gain acess to all class in bootclass, see this wiki for details. In 3.2, it was osgi.compatibility.bootdelegation=true in config.ini.

Resources