我们正在使用 ant 执行 sql 任务 - 在我们在 Oracle 连接字符串中使用 LDAPS 之前,它一直运行良好。使用下面提到的 Oracle LDAPS 连接字符串,它会引发异常 -ClassNotFoundException: oracle.net.jndi.CustomSSLSocketFactory. We tried ojdbc6.jar and ojdbc14.jar - but of no use. (ant build with -v shows it is referring to ojdbc6.jar or ojdbc14.jar)
使用相同的连接字符串,我们可以通过“Oracle SQL Developer”进行连接。我们更改了 basePath 以包含 sqldeveloper\jdbc\lib 路径,但仍然得到相同的 classnotfoundexception。请指教。
谢谢库马尔
环境规格
1. Oracle: 10.2.0.4
2. Java JDK: 1.6 (Oracle GlassFish)
3. ojdbc6.jar (Oracle Database 11g Release 2 (11.2.0.3) JDBC Drivers)
4. ojdbc14.jar (Oracle Database 10g Release 2 (10.2.0.4) JDBC Drivers )
5. OS: Windows 7 64 bit
LDAPS 连接字符串
jdbc:oracle:thin:@ldaps://${lDAP-server}:${ldap-port}/${Schema},cn=OracleContext,dc=xxx,dc=com"
SQL 蚂蚁任务
< sql driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@ldaps://${lDAP-server}:${ldap-port}/${Schema},cn=OracleContext,dc=xxxx,dc=com" userid="${this.service.db.user}" password="${this.service.db.password}" classpathref="base.classpath">
SELECT * FROM SOMETHING;
</sql>
完整的异常跟踪:
BUILD FAILED
The following error occurred while executing
this line:
java.sql.SQLRecoverableException: IO Error:
JNDI Package failure **javax.naming.CommunicationException**: servername:port (changed) [Root exception is **java.lang.ClassNotFoundException: oracle.net.jndi.CustomSSLSocketFactory**]
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at org.apache.tools.ant.taskdefs.JDBCTask.getConnection(JDBCTask.java:370)
at org.apache.tools.ant.taskdefs.SQLExec.getConnection(SQLExec.java:942)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:614)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:811)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: oracle.net.ns.NetException: JNDI Package failure javax.naming.CommunicationException: server:port (changed) [Root exception is java.lang.ClassNotFoundException: oracle.net.jndi.CustomSSLSocketFactory]
at oracle.net.jndi.JndiAttrs.<init>(JndiAttrs.java:161)
at oracle.net.resolver.AddrResolution.<init>(AddrResolution.java:193)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:219)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
... 64 more