I got ClassNotFoundException when i tried to switch spring to use load time weaving - spring

I've added a <context:load-time-weaver/> in my application context. And i've added necessary libraries and javaagent to my pom.xml
Then i got following error
2014-05-23T17:48:11.549+0600 SEVERE Unable to find class 'com.myproject.dao.impl.BlobDataDaoTest$' in repository
java.lang.ClassNotFoundException: com.myproject.dao.impl.BlobDataDaoTest$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
at org.aspectj.weaver.World.resolveToReferenceType(World.java:485)
at org.aspectj.weaver.World.resolve(World.java:326)
How can i resolve it?

Obviously the weaver cannot find at least some of your application classes. This must be a class-loading issue. Maybe your aop.xml is not in the right location or configured in a wrong way - hard to tell with so little information.

There are external dependencies in my tests. They imported because in my tests i mock its. This Unable to find class errors all about this external classes.
2014-05-27T14:26:37.517+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
...
2014-05-27T14:26:37.517+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
...
2014-05-27T14:26:37.516+0600 SEVERE Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$ not found - unable to determine URL
at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)

It was resolved when i've updated aspectj version from 1.6.12 to 1.8

Related

Unable to find a 'com.okta.sdk.impl.http.RequestExecutorFactory'

I have a java web application secured with OKTA. I have the below code which throws the below exception,
Client client = Clients.builder()
.setOrgUrl((String)SessionUtils.getSession().getAttribute("serverUrl"))
.setClientCredentials(new TokenClientCredentials((String)SessionUtils.getSession().getAttribute("apiKey")))
.build();
When I run it, I get the below error. I have tried adding the jar by going to the buildPath of eclipse project. I am using the below dependencies in my POM and this used to work before when my project had an ANT build. But I started getting this error when I moved to Maven.
java.lang.IllegalStateException: Unable to find a
'com.okta.sdk.impl.http.RequestExecutorFactory' implementation on the
classpath. Please ensure you have added the okta-sdk-httpclient.jar
file to your runtime classpath. at
com.okta.commons.lang.Classes.lambda$loadFromService$0(Classes.java:205)
at java.util.Optional.orElseThrow(Optional.java:290) at
com.okta.commons.lang.Classes.loadFromService(Classes.java:205) at
com.okta.sdk.impl.client.BaseClient.createRequestExecutor(BaseClient.java:103)
at com.okta.sdk.impl.client.BaseClient.(BaseClient.java:72) at
com.okta.sdk.impl.client.AbstractClient.(AbstractClient.java:60)
at
com.okta.sdk.impl.client.DefaultClient.(DefaultClient.java:117)
at
com.okta.sdk.impl.client.DefaultClientBuilder.build(DefaultClientBuilder.java:322)
I could resolve this by using the okta-sdk-httpclient :v1.5.2 to match some of the other OKTA dependencies that I had in my project.
Below are the dependencies that I had in my project prior to the fix.
-okta-authn-sdk-api :v1.0.0
-okta-authn-sdk-impl :v1.0.0
-okta-http-api :v1.2.8
-okta-commons-lang :v1.2.8
-okta-config-check :v1.2.8
-okta-http-okhttp :v1.2.8
-okta-jwt-verifier :v0.5.1
-okta-jwt-verifier-impl:v0.4.0
-okta-sdk :v0.0.4
-okta-sdk-api :v1.5.2
-okta-sdk-httpclient :v6.0.0
-okta-sdk-impl :v1.5.2

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.

javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String No such method

I am getting below exception while executing springboot application:
Caused by: java.lang.NoSuchMethodError: 'javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;
at org.hibernate.validator.internal.xml.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63) ~[hibernate-validator-6.0.7.Final.jar!/:6.0.7.Final]'
I included validation-api as a dependency with latest version & also made sure no other version is coming (not using hibernate validator as well) Still it is failing. Please suggest any solution.
Check the lib folder to differing version of validation-api -- for example
jakarta.validation-api-2.0.2.jar
validation-api-1.1.0.Final.jar
And try to see if you can remove validation-api-1.1.0.Final.jar

java.lang.NoSuchMethodError: org/springframework/beans/MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)

While deploying application on weblogic 11g I get following error.
java.lang.NoSuchMethodError: org/springframework/beans/MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;
I have following spring jars in my application
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aopalliance-sources-1.0.0.jar
org.springframework.beans-3.2.1.RELEASE.jar
org.springframework.context-3.2.1.RELEASE.jar
org.springframework.core-3.2.1.RELEASE.jar
org.springframework.expression-3.2.1.RELEASE.jar
org.springframework.jdbc-3.2.1.RELEASE.jar
org.springframework.transaction-3.2.1.RELEASE.jar
org.springframework.web.servlet-3.2.1.RELEASE.jar
org.springframework.web-3.2.1.RELEASE.jar
spring-aop-3.2.1.RELEASE.jar
And I have following other jars as well
commons-beanutils.jar,
commons-collections.jar,
commons-dbcp-1.4.jar,
commons-digester.jar,
commons-io-1.1.jar,
dom4j-1.3.jar,
jackson-core-asl-1.4.2.jar,
jackson-mapper-asl-1.4.2.jar,
jcommon-1.0.16.jar,
jfreechart-1.0.13.jar,
jstl-1.2.jar,
ojdbc6-11.2.0.3.jar,
slf4j.api-1.6.1.jar,
slf4j-nop-1.6.1.jar,
log4j-1.2.17.jar ,
Please help
You obviously have another version of this class in classpath. Do you have spring-beans in system classloader?
As Oracle documentation says, WebLogic web deployment descriptor weblogic.xml has a special element prefer-web-inf-classes.
By setting this element to true, you are changing classloader policy such that classes from application are loaded in preference to system classloader classes.

JDOM + Jaxen + Websphere 7 = java.lang.NoClassDefFoundError: org.jaxen.BaseXPath

I would like to use JDOM in a Webapp project. This works just fine. But now I want to add some stuff using XPath, but if I try to work with an XPath, I just get an exception:
com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet MyServlet in application MyProjectEAR. Exception created : java.lang.NoClassDefFoundError: org.jaxen.BaseXPath
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:72)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:136)
at org.jdom.xpath.XPath.newInstance(XPath.java:126)
at org.jdom.xpath.XPath.selectNodes(XPath.java:337)
[..]
Caused by: java.lang.ClassNotFoundException: org.jaxen.BaseXPath
at java.net.URLClassLoader.findClass(URLClassLoader.java:421)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:652)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:540)
at java.lang.ClassLoader.loadClass(ClassLoader.java:618)
... 35 more
The jaxen.jar is in my classpath, and the org.jaxen.BaseXPath class is there just fine. Why is Websphere not finding it? It works with all the other libraries I have there. When googling I found this, where someone says that he has a conflicting version somewhere and I should make sure that jars from my web app directory have precedence. In eclise' Built Path Configuration I set Web App Libraries above the WebSphere library (only the src dir is now above the web app libs), but that did not change anything. Unfortunatelly I did not really understand the part about the EAR which seems important...?
Update: In the meantime this gave me a new clue. I found on WebSphere's Administration Console the classpath and a list with all jars that are considered by the class loaders. These are quite a number and I searched them with a little grep and unzip -l magic and figured that the file /opt/ibm/WebSphere/PortalServer/wcm/prereq.wcm/wcm/shared/app/jdom.jar contains jdom (without the jaxen stuff). So maybe this jdom jar is loaded, but jaxen in an incompatible version is loaded from my lib directory?
Additionally I found in WebSphere's Administration Console the "parent first/last" setting for my application, but everything is grayed out! I can't switch to parent last :-(.
What can I do to find and fix the problem?

Resources