在Linux下的was服务器上部署web应用遇到问题:
运行环境
Linux+websphere8.0
项目框架
spring MVC+MyBatis**
问题描述及解决方案
此次部署web项目主要遇到了5个问题,以下为查看SystemOut.log与SystemErr.log中的部分信息截取。
问题1: class path contains multiple binding
分析:class路径下含有多个约束,因为was上自带了slf4j.jar包,与项目自己的jar包冲突。
解法:在Linux下执行 find / -name slf4j*
删除或者移动所有的websphere自带slf4j.jar
问题2: Error creating bean with name ‘shiroFilter’ defined in class path resource [applicationContext-shiro.xml]:
Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [applicationContext-shiro.xml]:
分析:将项目部署到was上时,需要修改配置文件web.xml的文件头。
解法:
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
问题3: java.lang.NullPointerException: in is null
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:75) ~[na:1.6.0]
at java.util.jar.JarInputStream.<init>(JarInputStream.java:68) ~[na:1.6.0]
at java.util.jar.JarInputStream.<init>(JarInputStream.java:54) ~[na:1.6.0]
at org.hibernate.jpa.boot.archive.internal.JarInputStreamBasedArchiveDescriptor.visitArchive(JarInputStreamBasedArchiveDescri
ptor.java:73) ~[hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:72) ~[hibernate-entitymanager-4.3.7.Fina
l.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:725) ~[hibernate
-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:221) ~[hiberna
te-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:188) ~[hiberna
te-entitymanager-4.3.7.Final.jar:4.3.7.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider$1.<init>(SpringHibernateJpaPersistenceProvider.ja
va:49) [spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHiberna
teJpaPersistenceProvider.java:49) [spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityMa
nagerFactoryBean.java:343) [spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
[spring-orm-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBean
Factory.java:1625) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFac
tory.java:1562) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFacto
ry.java:539) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory
.java:476) [spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) [spring-beans-4.1.
3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) [spring-beans-4.1.3.
RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-4.1.3.RE
LEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) [spring-contex
t-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.
java:747) [spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) [spring-contex
t-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web
-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.3.RELEASE.
jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.3
.RELEASE.jar:4.1.3.RELEASE]
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1649) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:410) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:748) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:633) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:422) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:714) [com.ibm.ws.webcontainer.jar:na]
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1134) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1369) [com.ibm.w
s.runtime.jar:na]
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:638) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:967) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:730) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2129) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388) [com.ibm.ws.runtime.jar:na]
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116) [com.ibm.ws.runtime.jar:na
]
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:994) [com.ibm.ws.runtime
.jar:na]
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349) [com.ibm.ws.runtime.jar:n
a]
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648) [com.ibm.ws.runtime.jar:na]
分析:这个问题之前一直在找,但是不知道根源在哪,曾怀疑过是jar包冲突的原因,因为was自带有hibernate与spring的jar包,但是删掉之后,
依然不起作用。之后在网上偶然看到共享库的创建(此处为关键),然后就成功了。
解法:在环境–>共享库–>新建,新建共享库,记得勾选“请对此共享库使用隔离的类装入器”,创建完成后,与项目关联起来即可(注意:有时关联之后,还是不行,其实是没有关联上,多关联几次就好)。
创建共享库的步骤:
1)环境-->共享库-->新建
![这里写图片描述](http://img.blog.csdn.net/20160719214931209)
2)填写信息,其中类路径为项目jar包路径
![这里写图片描述](http://img.blog.csdn.net/20160719215103226)
3)添加完共享库后,进入“应用程序”,选择“WebSphere企业应用程序”,点击项目war包
![这里写图片描述](http://img.blog.csdn.net/20160719215239789)
4)点击“共享库引用”
![这里写图片描述](http://img.blog.csdn.net/20160719215310910)
5)在出现的页面中先勾选自己的项目war包,再点击“引用共享库”,进行共享库的引用操作
![这里写图片描述](http://img.blog.csdn.net/20160719215536118)
6)在弹出的页面中将项目与添加的共享库关联起来,最后关联完后,会显示如下页面
![这里写图片描述](http://img.blog.csdn.net/20160719215700961)
问题4: org.springframework.beans.factory.BeanDefinitionStoreException:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource[applicationContext.xml];
nested exception is javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found
解法:删除项目库中的xml-api.jar即可。
问题5:was服务器上web应用的部分jsp页面显示不出来
分析:一般的页面代码,在tomcat下成功执行后,可以直接在was服务器上显示出来,但我为了解决IE的hover效果,在jsp页面中引用了一种插件,该插件在tomcat下可以正常运行,但是在was上有问题,删掉这部分代码即可成功再was服务器上显示原有的信息。
解法:删掉CSS相关代码,如下图:
致谢
感谢您的耐心阅读!如有语句不通顺或者不准确的地方,还请指正!谢谢!(^__^)