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

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.

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

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

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

EJB application won't deploy in OC4J with Java7

An EJB application which works using Java6 JRE fails to deploy with Java7, it throws the following error:
14/01/13 13:33:23 WARNING: Application.setConfig Application:
accesscontrolapp is in failed state as initialization failed.
oracle.classloader.util.AnnotatedNoClassDefFoundError:
Missing class: org.apache.crimson.tree.ElementNode
Dependent class: com.sun.enterprise.deployment.xml.EjbBundleNode
Loader: oc4j:10.1.3
Code-Source: .../oc4j_standalone/j2ee/home/lib/oc4j-internal.jar
Configuration: in META-INF/boot.xml in
...\oc4j_standalone\j2ee\home\oc4j.jar
The missing class is not available from any code-source or loader in
the system.
I located the missing class in j2ee/home/lib/crimson_1_1_3.jar so I don't understand, why the error?
The error message refers to META-INF/boot.xml within oc4j.jar, if you look at that file it reads:
<code-source path="lib/crimson_1_1_3.jar" if="java.specification.version == /1\.[5-6]/"/>
This was apparently done to prevent loading of crimson in java 1.4. If you change this to read '[5-9]' then this works for Java 1.7 and presumably 1.8 and 1.9 as well.

how to force jboss to use hibernate-entitymanager.jar from WAR instead of Jboss_home directory

My problem is as follows I use in my WS app Hibernate-entitymanager-3.5.6-FINAL jar, JBOSS 4.2.3 have in his direction hibernate if i am not wrong 3.3.x which make conflict of versions. Don't redirect me to ClassLoader related articles of JBOSS i have read them, and put this in JBOSS_HOME\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF\jboss-web.xml
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
pl.mycompany:archive=hibernate-entitymanager
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
can anyone give me a hint what am i missing?
See article ClassLoadingConfiguration:
They mention about unique-archive-name
For jboss-service.xml:
<server>
<loader-repository>
com.example:archive=unique-archive-name
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
...
The isolated EAR or WAR repository will load its libraries in this order:
WEB-INF/lib (for WARs)
libraries in server/default/lib
tomcat-libraries in server/default/deploy/jbossweb-tomcat50.sar (jboss-3.2.6).
The libraries in server/default/lib get mixed together with jbossweb-tomcat50.sar in no specific order (for details look into the loader-repository in the JMX-console).
Second solution: Remove hibernate classes from jboss (move to endorsed).

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