我有一个简单的Spring MVC应用程序,它从LDAP服务器查找一些用户详细信息,并使用JSP打印出一个简单的HTML页面。该应用程序在Tomcat 6上运行良好。它使用Spring LDAP 1.3.1和LDAPTemplate来执行LDAP查找。Websphere中的NoClassDefFoundError - JAR文件存在
但是,当我将此应用程序WAR部署到Websphere 7时,该应用程序无法运行 - Websphere会返回500内部服务器错误。综观WebSphere的日志文件,我看到
[14/12/10 14:50:09:169 GMT] 00000022 DispatcherSer E org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.ldap.core.support.LdapContextSource] for bean with name 'contextSource' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.beans.factory.InitializingBean
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:885)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
我的WEB-INF \ lib目录下有所有的JAR文件,包括org.springframework.beans-3.0.5.RELEASE.jar
,其中包含InitializingBean
。因此,我不确定为什么Websphere将该课程报告为缺失。
我的WEB-INF \ lib中的内容:
aopalliance.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.log4j-1.2.15.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-pool-1.5.4.jar
jstl-api-1.2.jar
jstl-impl-1.2.jar
ldapbp-1.0.jar
org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.oxm-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
org.springframework.web.servlet-3.0.5.RELEASE.jar
spring-ldap-1.3.1.RELEASE-all.jar
下面是其WebSphere不太顺利载入(用户名/密码是有效的,并与Tomcat的作品)的contextSource
bean的定义:
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldaps://moo.example.com:1300/" />
<property name="userDn" value="CN=foo,OU=baz,DC=bar,DC=blat,DC=org" />
<property name="password" value="*******" />
</bean>
如果有人能指出为什么这不在Websphere上工作,我会很高兴。我不太确定Websphere中的类加载规则,并希望得到有关此方面的任何建议。
谢谢Manglu。在启用类加载的情况下浏览日志,我发现从另一个位置加载了不同版本的Spring LDAP jar,因为管理员在JNDI中存储了一个Spring LDAP上下文源。设置我的应用程序的类加载器使用“最后一个父母”解决了这个问题。 – sigint 2010-12-20 12:27:40