Websphere中的NoClassDefFoundError - 存在JAR [英] NoClassDefFoundError in Websphere -- JARs are present

查看:322
本文介绍了Websphere中的NoClassDefFoundError - 存在JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Spring MVC应用程序,它从LDAP服务器中查找一些用户详细信息,并使用JSP打印出一个简单的HTML页面。该应用程序在Tomcat 6上运行正常。它使用Spring LDAP 1.3.1和LDAPTemplate进行LDAP查找。

I have a simple Spring MVC application that looks up some user details from an LDAP server and prints out a simple HTML page using a JSP. The application works fine on Tomcat 6. It uses Spring LDAP 1.3.1 and LDAPTemplate to do the LDAP lookups.

但是,当我将此应用程序WAR部署到Websphere 7时,应用程序无法运行 - Websphere返回500内部服务器错误。查看Websphere的日志文件,我看到

However, when I deploy this application WAR to Websphere 7, the app doesn't run -- Websphere returns a 500 Internal server error. Looking at Websphere's log file, I see

[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报告该类缺失。

My web-inf\lib directory has all the JAR files, including org.springframework.beans-3.0.5.RELEASE.jar, which contains InitializingBean. I'm therefore not sure why Websphere is reporting the class as missing.

我的web-inf\lib的内容:

Contents of my 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

这里是 contextSource bean,Websphere加载时遇到问题(用户名/密码有效且适用于Tomcat):

And here's the definition of the contextSource bean which Websphere is having trouble loading (the username/password is valid and works with Tomcat):

<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中的类加载规则不太了解,并对此提出任何建议。

I'd be very glad if someone could point out why this isn't working on Websphere. I'm not too sure about class-loading rules in Websphere and would appreciate any advice on this.

推荐答案

打开类加载跟踪。这将告诉您加载了哪些类以及从哪个Jar。正如Sajan所提到的那样,类路径中存在重复的jar并且你期望的类加载器没有加载这个类(并且父类加载器可能已经加载了一个类)。

Turn on Class Loading trace. This would tell you what classes are loaded and from which Jar. As Sajan mentioned chances are that there are duplicate jars in the classpath and the classloader that you expect has not loaded this class (and a parent class loader has likely loaded a class).

NoClassDefFoundError(NCDFE)确实意味着找不到它正在寻找的类。静态初始化中的错误会明确地变成java.lang.ExceptionInInitializerError(EIIE)

NoClassDefFoundError (NCDFE) does mean it could not locate the class that it is looking for. Errors in static initialization would explicitly turn out as a "java.lang.ExceptionInInitializerError" (EIIE) "

NCDFE和EIIE都是从Linkage错误扩展而来的。

Both NCDFE and EIIE extend from Linkage error.

通常,通过打开服务器的类加载可以轻松解决所有这些错误。还可以使用管理控制台中提供的类加载器查看器来帮助您进行故障排除活动。

In general all these errors can easily be troubleshooted by turning on the class loading for the Server. Also use the Class Loader Viewer available in the admin console to aid in your troubleshooting activities.

HTH
Manglu

HTH Manglu

这篇关于Websphere中的NoClassDefFoundError - 存在JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆