I got several IllegalStateException
,CannotCompileException
and LinkageError
at the time of application running on WebSphere 9.0 java 8 . These this is stack trace of error :
Caused by: java.lang.IllegalStateException: javassist.CannotCompileException: by java.lang.LinkageError: org.springframework.aop.framework.ProxyCreatorSupport
at org.springframework.aop.framework.JavassistApplicationContext.<clinit>(JavassistApplicationContext.java:61)
... 114 more
Caused by: javassist.CannotCompileException: by java.lang.LinkageError: org.springframework.aop.framework.ProxyCreatorSupport
at javassist.ClassPool.toClass(ClassPool.java:1120)
at javassist.ClassPool.toClass(ClassPool.java:1063)
at javassist.ClassPool.toClass(ClassPool.java:1021)
at javassist.CtClass.toClass(CtClass.java:1259)
at org.springframework.aop.framework.JavassistApplicationContext.<clinit>(JavassistApplicationContext.java:59)
... 114 more
Caused by: java.lang.LinkageError: org.springframework.aop.framework.ProxyCreatorSupport
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:346)
at java.lang.ClassLoader.defineClass(ClassLoader.java:283)
at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at javassist.ClassPool.toClass2(ClassPool.java:1133)
at javassist.ClassPool.toClass(ClassPool.java:1114)
... 118 more
and also i am getting java.lang.ExceptionInInitializerError
:
com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E:
Exception caught while initializing context: {0} java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:141)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:130)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:437)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:258)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
And in pom.xml
File, I have following dependency.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.16</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<!-- Javassist -->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>[1.1.1,)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
<version>[1.0.3,)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4jVersion}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4jVersion}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<!--<scope>provided</scope>-->
</dependency>
<!-- Global Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>ibmpkcs</artifactId>
<version>8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showDeprecation>${maven.compiler.showDeprecation}</showDeprecation>
<showWarnings>${maven.compiler.showWarnings}</showWarnings>
<encoding>UTF-8</encoding>
<debug>${maven.compiler.debug}</debug>
<optimize>${maven.compiler.optimize}</optimize>
</configuration>
</plugin>
</build>
<properties>
<spring.version>4.2.5.RELEASE</spring.version>
<spring-ws.version>2.4.0.RELEASE</spring-ws.version>
<spring-security.version>4.0.0.RELEASE</spring-security.version>
<slf4jVersion>1.6.1</slf4jVersion>
<maven.test.skip>true</maven.test.skip>
<junit.version>4.8.2</junit.version>
<hibernate.version>3.5.6-Final</hibernate.version>
</properties>
i am using spring 4.2.5.RELEASE version
and javassist 3.19.0-GA
version .
and in the web app, I can see following jar files after installing the application on WebSphere /WEB-INF/lib
aopalliance-1.0.jar
commons-io-1.4.jar
jcl-over-slf4j-1.6.1.jar
spring-aop-4.2.5.RELEASE.jar
spring-expression-4.2.5.RELEASE.jar
bcprov-jdk16-1.46.jar
freemarker-2.3.16.jar
log4j-1.2.14.jar
spring-beans-4.2.5.RELEASE.jar
spring-web-4.2.5.RELEASE.jar
commons-codec-1.4.jar
ibmpkcs-8.0.jar
slf4j-api-1.6.1.jar
spring-context-4.2.5.RELEASE.jar
spring-webmvc-4.2.5.RELEASE.jar
commons-fileupload-1.2.2.jar
javassist-3.19.0-GA.jar
slf4j-log4j12-1.6.1.jar
spring-core-4.2.5.RELEASE.jar
also in web.xml
i am using org.springframework.aop.framework.JavassistApplicationContext
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.aop.framework.JavassistApplicationContext</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listenerclass>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
and in class path /WEB-INF/classes/org/springframework/aop/framework
i have some javassist classes .
JavassistAopProxy$1.class
JavassistAopProxy$EqualsInterceptor.class
JavassistAopProxy$JavassistMethodInvocation.class
JavassistAopProxy.class JavassistAopProxy$AdvisedDispatcher.class
JavassistAopProxy$ExProxyFactory.class JavassistAopProxy$MethodInterceptor.class
JavassistAopProxyFactory.class JavassistAopProxy$CompositeInterceptor.class
JavassistAopProxy$FixedChainStaticTargetInterceptor.class
JavassistAopProxy$StaticDispatcher.class JavassistApplicationContext.class JavassistAopProxy$DynamicAdvisedInterceptor.class
JavassistAopProxy$HashCodeInterceptor.class
JavassistAopProxy$UnadvisedInterceptor.class
Any suggestions on this error? I have tried following methods to
class loader parent last method on server and application
Update spring to latest version
removed javascript jar files from
/WEB-INF/lib
path
I can't understand what is this error means. Any explanations and suggestions to solve this error. It was working fine in WebSphere 6 with Java 1.6
update :
mvn dependency:tree
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myapp-parent ---
[INFO] com.test:myapp-parent:pom:6.2.0
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.ibm:ibmpkcs:jar:8.0:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Web Application Package 6.2.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myapp-webapp ---
[INFO] com.test:myapp-webapp:war:6.2.0
[INFO] +- org.springframework:spring-webmvc:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.2.5.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-core:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.2.5.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.2.5.RELEASE:compile
[INFO] +- commons-codec:commons-codec:jar:1.4:compile
[INFO] +- commons-io:commons-io:jar:1.4:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.freemarker:freemarker:jar:2.3.16:compile
[INFO] +- org.springframework:spring-test:jar:4.2.5.RELEASE:test
[INFO] +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] +- org.bouncycastle:bcprov-jdk16:jar:1.46:compile
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.ibm:ibmpkcs:jar:8.0:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Enterprise Application Package 6.2.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myapp-ear ---
[INFO] com.test:myapp-ear:ear:6.2.0
[INFO] +- com.test:myapp-webapp:war:6.2.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:provided
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:provided
[INFO] +- log4j:log4j:jar:1.2.14:provided
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.ibm:ibmpkcs:jar:8.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] my application...................................... SUCCESS [ 9.465 s]
[INFO] Web Application Package ............................ SUCCESS [ 0.104 s]
[INFO] Enterprise Application Package ..................... SUCCESS [ 0.044 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.721 s
[INFO] Finished at: 2017-09-18T13:33:51+05:30
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
Update
And now i think the problem due to javassist file . I am loading a specific class using javassist in my code .org.spring.aop.framework.ProxyCreatorSupport is a class that will be loaded by the class loader . But i am getting some IllegalStateException , cannot compile exceptions when i deploy .EAR file to WebSphere .
Using ClassPool.getDefault(), I am looking up information from the system class path . Added the class loader that is handed over by the transformation method as an argument. I have appended class loader to Javassist's search path .
package org.spring.aop.framework;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
import javassist.LoaderClassPath;
import org.springframework.web.context.support.XmlWebApplicationContext;
public class JavassistApplicationContext extends XmlWebApplicationContext {
static {
ClassPool classPool = ClassPool.getDefault();
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
classPool.appendClassPath(new LoaderClassPath(classLoader));
CtClass cc = classPool.get("org.spring.aop.framework.ProxyCreatorSupport");
CtConstructor c = cc.getConstructors()[0];
c.insertAfter("$0.aopProxyFactory = new org.spring.aop.framework.JavassistAopProxyFactory();");
cc.toClass();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
It was working fine with java 1.6 WebSphere 8 . After update to java 8 WebSphere 9 , i am getting these kind of exceptions .I think Javassist toClass()
causing exceptions in websphere . Also CtClass cc = classPool.get("org.spring.aop.framework.ProxyCreatorSupport");
making some linkage issues . Any suggestion now ?