如何在tomcat中运行应用程序时重新发生链接错误?

时间:2017-02-23 14:46:56

标签: tomcat

当我正在使用MaintainJ来跟踪我们的应用程序以自动创建UML图表。我将MaintainJ.war和我们的application.war部署到Web应用程序并开始使用MaibntainJ应用程序,在某些时候我必须使用set JAVA_OPTS在tomcat中为MaintainJ设置JVM属性,但是当我启动tomcat并坚持使用在tomact中设置jvm属性。

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
15:35:27.952 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [v_1_0/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/aspectj/runtime/internal/AroundClosure"
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [catalina.jar:8.0.32]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [catalina.jar:8.0.32]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:8.0.32]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) [catalina.jar:8.0.32]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) [catalina.jar:8.0.32]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) [catalina.jar:8.0.32]
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1091) [catalina.jar:8.0.32]
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1830) [catalina.jar:8.0.32]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_111]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_111]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_111]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_111]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_111]
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/aspectj/runtime/internal/AroundClosure"
        at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_111]
        at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_111]
        at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.8.0_111]
        at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.8.0_111]
        at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.8.0_111]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_111]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_111]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_111]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_111]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_111]
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[?:1.8.0_111]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_111]
        at com.maintainj.aspect.ExecutionDataAspect.ajc$around$com_maintainj_aspect_ExecutionDataAspect$1$7d7905cdproceed(ExecutionDataAspect.aj:70) ~[MaintainJAgent.jar:1.8.6]
        at com.maintainj.aspect.ExecutionDataAspect.ajc$around$com_maintainj_aspect_ExecutionDataAspect$1$7d7905cd(ExecutionDataAspect.aj:71) ~[MaintainJAgent.jar:1.8.6]
        at com.ibm.db2.jcc.am.Connection.prepareStatement(Connection.java:937) ~[db2jcc-4.18.60.jar:?]
        at org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:292) ~[tomcat-dbcp.jar:8.0.32]
        at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:356) ~[tomcat-dbcp.jar:8.0.32]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2306) ~[tomcat-dbcp.jar:8.0.32]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2289) ~[tomcat-dbcp.jar:8.0.32]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2038) ~[tomcat-dbcp.jar:8.0.32]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1532) ~[tomcat-dbcp.jar:8.0.32]
        at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847) ~[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874) ~[hibernate-entitymanager-5.0.9.Final.jar:5.0.9.Final]
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)~[spring-orm-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319) ~[spring-orm-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        ... 25 more
22-Feb-2017 15:35:28.046 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
22-Feb-2017 15:35:28.046 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/stouch-cms-services] startup failed due to previous errors
22-Feb-2017 15:35:28.077 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [stouch-cms-services] registered the JDBC driver [com.ibm.db2.jcc.DB2Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the J
DBC Driver has been forcibly unregistered.

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

如果您在与MaintainJ相同的容器中的其他应用程序中部署了 aspectjrt.jar aspectjweaver.jar ,就会发生此错误。 MaintainJ代理已经在类路径中更高的那些jar文件中添加了类。

使用MaintainJ部署应用程序时,请从其他应用程序中删除aspectjrt.jar和aspectjweaver.jar文件。

那就行了!