使用自定义SSLSocketFactory时ClassNotFoundException

编程入门 行业动态 更新时间:2024-10-27 14:20:03
本文介绍了使用自定义SSLSocketFactory时ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个自定义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

本文发布于:2023-11-05 21:25:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561901.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   SSLSocketFactory   ClassNotFoundException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!