weblogic92应用jar冲突初解决

weblogic版本:WebLogic Server 9.2

authorifeelcold1999#gmail.com

主要参考资料:http://apache-cxf.group.iteye.com/group/wiki/1315-apache-cxf-in-weblogic-9-2-on-the-problem-of-positioning-and-expediency

Background:应用原来是部署在websphere上的,并且有专门的运维人员负责,新项目组要求部署到weblogic,并且没有运维,只能我自己搞了

1st

将应用打成war包,上传至服务器,在weblogicconsoleinstall完成,选择start后,console提示

weblogic92应用jar冲突初解决_第1张图片

异常堆栈就不贴了,有需要可以联系我

主要的是这句

Caused by: java.lang.NoSuchMethodError: getTokenStartColumn

         at org.codehaus.groovy.antlr.parser.GroovyLexer.makeToken(GroovyLexer.java:81)

这个makeToken方法会调用tok.setColumn(inputState.getTokenStartColumn());

inputState.getTokenStartColumn()是应用中antlr-2.7.6.jar的内容,考虑是weblogic自己的antlr相关类和antlr-2.7.6.jar中的内容不一样,反编译inputState对应的类antlr.LexerSharedInputStateweblogic.jar中同名的类,发现antlr-2.7.6.jar中的类的部分方法在weblogic.jar中的类里确实没有。

2nd

看到这里,首先想到的是在配置文件中设置prefer-web-inf-classes,使应用的jar加载早于weblogic自己的jar加载

weblogic.xml中添加如下内容

<container-descriptor>
		<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

Update然后启动应用,提示错误

weblogic92应用jar冲突初解决_第2张图片

这个的错误堆栈贴一下

$$2012-06-27 16:05:36|[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'|org.springframework.web.context.ContextLoader|ERROR|org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:215)|Context initialization failed##
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [zip:/app/wls92/bea/user_projects/domains/CxdxDomain/servers/Server7030/tmp/_WL_user/ebw/byb2o9/war/WEB-INF/lib/_wl_cls_gen.jar!/beans/ajax-views.xml]; nested exception is java.lang.LinkageError: Class javax/xml/namespace/QName violates loader constraints
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
	at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:376)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
	at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:82)
	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1616)
	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2761)
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:889)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:333)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
	at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
	at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
	at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:26)
	at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
	at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
	at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
	at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:566)
	at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:136)
	at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:104)
	at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:139)
	at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320)
	at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:815)
	at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1222)
	at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:433)
	at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:161)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67)
	at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: java.lang.LinkageError: Class javax/xml/namespace/QName violates loader constraints
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:355)
	at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:294)
	at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:262)
	at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
	at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:40)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.configurePipeline(Unknown Source)
	at org.apache.xerces.parsers.XIncludeAwareParserConfiguration.configurePipeline(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)

看参考资料的分析,因为prefer-web-inf-classes的配置,应用中所有jar的加载时间要早于weblogicjar的加载时间,导致weblogic中部分类的依赖本来指向容器的结果指向了应用中的类,然后由于兼容问题而报错了,这个原因看起来比较高端,详细原因请看参考资料

3rd

最终解决方法是去掉prefer-web-inf-classes ,改为在weblogic的启动脚本中的classpath中添加导致第一个异常的antlr-2.7.6.jar,即只提前加载应用中这一个jar,再次启动,应用可以起来了

CLASSPATH="/home/wls92/foo/bar/antlr-2.7.6.jar:/home/wls92/foo/bar/xxx.jar: /home/wls92/foo/bar/yyy.jar:


最后,按照惯例,福利一枚奉上

weblogic92应用jar冲突初解决_第3张图片

你可能感兴趣的:(weblogic,jar冲突)