我创建了一个自定义SSLSocketFactory类并将其设置如下
I have created a custom SSLSocketFactory class and set it as below
ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl"); ldapEnv.put(FACTORY_SOCKET, socketFactoryClass); LdapContext ldapContext = new InitialLdapContext(ldapEnv, null);从Eclipse Dev Environment运行并从命令提示符运行它作为Jar文件时,它工作正常。但是当我将其包装在服务包装器中并将其作为Windows服务启动时,它不起作用。我得到以下异常,
It works fine when running from Eclipse Dev Environment, and running it as Jar file from command prompt. But it doesn't work when I wrap it inside a service wrapper and launch it as Windows Service. I get the following exception,
javax.naming.CommunicationException: 192.168.100.22:636 [Root exception is java.lang.ClassNotFoundException: com/testing/diraccess/service/ActiveDirectory$TestSSLFactory] at com.sun.jndi.ldap.Connection.<init>(Unknown Source) at com.sun.jndi.ldap.LdapClient.<init>(Unknown Source) at com.sun.jndi.ldap.LdapClient.getInstance(Unknown Source) at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source) at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source) at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.init(Unknown Source) at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source) Caused by: java.lang.ClassNotFoundException: com/testing/diraccess/service/ActiveDirectory$TestSSLFactory at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at com.sun.jndi.ldap.VersionHelper12.loadClass(Unknown Source) at com.sun.jndi.ldap.Connection.createSocket(Unknown Source) ... 35 more任何帮助???
推荐答案这是一个很久以来我发布了这个问题。由于这篇文章没有任何答案,似乎也得到了一些观点,我想我可以分享我最后解决的问题(我已经在几年前的问题的评论部分发布了这个)。
It's been a very long time since I posted this question. Since this post doesn't have any answers and also seems to be getting some views, I thought I could share what I did then to resolve it finally (I had already posted this in comments section of the question years ago).
我能够通过使用 -Xbootclasspath / a:选项将该jar文件包含在引导加载程序类路径中来解决此问题。但我还是不喜欢这个解决方案。
I was able to resolve this issue by including that jar file in boot loader class path using -Xbootclasspath/a: option. But I didn't like this solution anyway.
更多推荐
使用自定义SSLSocketFactory时ClassNotFoundException
发布评论