com.sun.jndi.ldap.LdapCtxFactory:在servlet中找不到类 [英] com.sun.jndi.ldap.LdapCtxFactory : class not found in servlet

查看:715
本文介绍了com.sun.jndi.ldap.LdapCtxFactory:在servlet中找不到类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好/下午

我在LDAP连接器中遇到问题,当我在单元测试中使用它时没有问题,但是在应用程序服务器环境中调用它时,似乎存在类路径问题,但是该类是通过Java 1.6.17传递的(我使用的版本).

I have a problem with LDAP connector, when I use it in my unit test no problem, but when it was called in a application server environment, it seems to have classpath issue, but this class is delivred with java 1.6.17 (version I use).

我使用spring-ldap来启动连接.

I use spring-ldap to initiate my connection.

public static LdapContextSource getLdapContextSource(final String url, final String base) throws Exception {
    LdapContextSource ldapContextSource = new LdapContextSource();

    ldapContextSource.setUrl(url);
    ldapContextSource.setBase(base);
    ldapContextSource.setPooled(true);
    //ldapContextSource.setContextFactory(LdapCtxFactory.class);

    ldapContextSource.afterPropertiesSet();

    return ldapContextSource;
}

这是日志:

2010-08-10 09:46:38,183 : StandardWrapperValve.invoke : Servlet.service() for servlet default threw exception
java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapCtxFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at org.ow2.easybeans.loader.EasyBeansClassLoader.findClass(EasyBeansClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    at org.ow2.easybeans.loader.EasyBeansClassLoader.loadClass(EasyBeansClassLoader.java:238)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.springframework.ldap.core.support.AbstractContextSource.class$(AbstractContextSource.java:67)
    at org.springframework.ldap.core.support.AbstractContextSource.<clinit>(AbstractContextSource.java:67)
    at org.zenithar.security.connectors.impl.ldap.LdapContextFactory.getLdapContextSource(LdapContextFactory.java:16)

谢谢大家. 问候.

推荐答案

我找到了解决方案^^

I found the solution ^^

这是Jonas 5的问题,它是在OSGI平台上运行的应用服务器. 我的应用程序是一个普通的核心jar(包含带有DAO的spring上下文),共3次战争.看来,用于托管公共内核的JVM与用于3次大战的JVM不同.

It was a problem with Jonas 5 wich is an app server running on OSGI platform. My application is a common core jar (containing spring context with DAO) shared by 3 wars. It seems that the JVM used to host the common core is not the same as used for the 3 wars.

我将其添加到felix-config.properties

I add to my felix-config.properties

org.osgi.framework.bootdelegation=....
    sun.util.calendar; \
    com.sun.jndi.ldap; \
    version="1.5.0"

还有

org.osgi.framework.bootdelegation=com.sun.corba, \
....
com.sun.jndi.ldap.*

这样我就可以在我的Common Core中加载com.sun.jndi.ldap.LdapCtxFactory.

So that I can load com.sun.jndi.ldap.LdapCtxFactory in my Common Core.

感谢您的帮助.

这篇关于com.sun.jndi.ldap.LdapCtxFactory:在servlet中找不到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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