使用Java 8在WebSphere 9.0上运行应用程序时出现Java异常,链接错误

时间:2017-08-28 16:10:03

标签: java maven java-8 websphere

我已使用WebSphere 9.0设置了java 8个实例。上传.EAR文件并运行我的应用程序后,我可以获得大量IllegalStateException,CannotCompileException,LinkageError。但它与JDK 1.6一起运行良好。我错过了POM文件中的任何内容,还是应该升级任何内容?

这是我得到的错误日志:

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)


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    

和依赖POM文件:

 <dependencies>
            <dependency>
                <groupId>net.percederberg.grammatica</groupId>
                <artifactId>grammatica</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>net.percederberg.mibble</groupId>
                <artifactId>mibble</artifactId>
                <version>2.8</version>
            </dependency>
            <dependency>
                <groupId>net.percederberg.mibble</groupId>
                <artifactId>mibble-mibs</artifactId>
                <version>2.8</version>
            </dependency>

            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.3.1</version>
            </dependency>

            <dependency>
                <groupId>net.sf.jradius</groupId>
                <artifactId>jradius-client</artifactId>
                <version>20040211</version>
            </dependency>

            <!-- spring modules in alphabetic order -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-asm</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</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>
            <!-- spring (former acegi) security -->
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</artifactId>
                <version>${spring-security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-ldap</artifactId>
                <version>${spring-security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-taglibs</artifactId>
                <version>${spring-security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>${spring-security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>${spring-security.version}</version>
            </dependency>
            <!-- spring-ws -->
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-ws-core</artifactId>
                <version>${spring-ws.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-ws-security</artifactId>
                <version>${spring-ws.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.sun.xml.wsit</groupId>
                        <artifactId>xws-security</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun.xml.wsit</groupId>
                        <artifactId>wsit-rt</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- commons in alphabetic order -->
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.5</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>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.2.5</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>1.8.0</version>
            </dependency>
            <dependency>
                <groupId>commons-discovery</groupId>
                <artifactId>commons-discovery</artifactId>
                <version>0.4</version>
            </dependency>

            <!-- DAO hibernate related -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${hibernate.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.transaction</groupId>
                        <artifactId>jta</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-ehcache</artifactId>
                <version>3.3.2.GA</version>
                <exclusions>
                    <exclusion>
                        <groupId>net.sf.ehcache</groupId>
                        <artifactId>ehcache</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-annotations</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
                <version>1.0.0.Final</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.19.0-GA</version>
            </dependency>
            <dependency>
                <groupId>antlr</groupId>
                <artifactId>antlr</artifactId>
                <version>2.7.7</version>
            </dependency>
            <dependency>
                <groupId>stax</groupId>
                <artifactId>stax-api</artifactId>
                <version>1.0.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.ws.xmlschema</groupId>
                <artifactId>xmlschema-core</artifactId>
                <version>2.0.3</version>
            </dependency>
            <dependency>
                <groupId>javax.annotation</groupId>
                <artifactId>jsr250-api</artifactId>
                <version>1.0</version>
            </dependency>
            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>2.3.16</version>
            </dependency>
            <dependency>
                <groupId>org.jmock</groupId>
                <artifactId>jmock-junit4</artifactId>
                <version>2.5.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>1.8.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymock</artifactId>
                <version>3.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
            <groupId>dom4j</groupId>
                <artifactId>dom4j</artifactId>
                <version>1.6.1</version>
            </dependency>
            <dependency>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
                <version>1.4.1</version>
            </dependency>
            <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.snmp4j</groupId>
                <artifactId>snmp4j</artifactId>
                <version>2.0.3</version>
            </dependency>
            <dependency>
                <groupId>org.snmp4j</groupId>
                <artifactId>snmp4j-agent</artifactId>
                <version>2.0.5</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.octo.captcha</groupId>
                <artifactId>jcaptcha</artifactId>
                <version>1.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.ws.security</groupId>
                <artifactId>wss4j</artifactId>
                <version>1.6.5</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.opensaml</groupId>
                        <artifactId>opensaml</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.codehaus.woodstox</groupId>
                <artifactId>wstx-asl</artifactId>
                <version>3.2.8</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.messaging.saaj</groupId>
                <artifactId>saaj-impl</artifactId>
                <version>1.3.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.ws.commons.axiom</groupId>
                <artifactId>axiom-impl</artifactId>
                <version>1.2.8</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.geronimo.specs</groupId>
                        <artifactId>geronimo-activation_1.1_spec</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.geronimo.specs</groupId>
                        <artifactId>geronimo-javamail_1.4_spec</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.geronimo.specs</groupId>
                        <artifactId>geronimo-stax-api_1.0_spec</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.1</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>2.1.12</version>
            </dependency>
            <dependency>
                <groupId>xalan</groupId>
                <artifactId>xalan</artifactId>
                <version>2.7.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                <version>2.0.2</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
                <version>2.8.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.2-FINAL</version>
            </dependency>
            <dependency>
                <groupId>jfree</groupId>
                <artifactId>jcommon</artifactId>
                <version>1.0.15</version>
            </dependency>
            <dependency>
                <groupId>jfree</groupId>
                <artifactId>jfreechart</artifactId>
                <version>1.0.13</version>
            </dependency>
            <dependency>
                <groupId>org.samba.jcifs</groupId>
                <artifactId>jcifs</artifactId>
                <version>1.2.6</version>
            </dependency>

            <!-- RSA Dependencies -->
            <dependency>
                <groupId>ognl</groupId>
                <artifactId>ognl</artifactId>
                <version>3.1.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis</groupId>
                <artifactId>axis</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis</groupId>
                <artifactId>axis-jaxrpc</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>org.apache.axis</groupId>
                <artifactId>axis-saaj</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>wsdl4j</groupId>
                <artifactId>wsdl4j</artifactId>
                <version>1.6.1</version>
            </dependency>
            <dependency>
                <groupId>aopalliance</groupId>
                <artifactId>aopalliance</artifactId>
                <version>1.0</version>
            </dependency>
        </dependencies>



  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                       <!-- <version>2.3.2</version>-->
                <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>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12</version>
                <configuration>
                    <skipTests>${maven.test.skip}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>javadoc</goal>
                            <goal>test-javadoc</goal>
                        </goals>
                        <phase>site</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

我已将sourcetarget版本添加到1.8的pom文件中的java 1.8。我不知道为什么会出现这些错误。它与jdk 1.6一起工作正常。如何解决这个错误?这是由于任何依赖性? 有什么建议吗?

2 个答案:

答案 0 :(得分:2)

当不同的类加载器加载了同一个类时,会发生错误。可能,您的应用中的一个或多个罐子已经存在于Web应用服务器中。通常,Web应用程序服务器使用多个类领导者,您可能会看到此类错误。要了解实际发生的情况,请在类加载时启用调试。这是一个关于同一https://vcfvct.files.wordpress.com/2015/06/do-you-really-get-classloaders.pdf

的非常好的教程

答案 1 :(得分:1)

您正在JVM 9上运行 at java.lang.J9VMInternals.ensureError(J9VMInternals.java:141)