我在这里遵循了答案之一:
How to access JNDI data source defined in weblogic 10.3.6
Hashtable<String, String> h = new Hashtable<String, String>(7);
h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");//add ur url
h.put(Context.SECURITY_PRINCIPAL, "weblogic");//add username
h.put(Context.SECURITY_CREDENTIALS, "abc#12345");//add password
InitialContext ctx = new InitialContext(h);
DataSource dataSource = ((DataSource) ctx.lookup("jndiDS"));
运行它时出现此错误:
java.lang.NoSuchMethodError:org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder。(Ljava / lang / ClassLoader; [Ljava / lang / String;)V
并尝试再次运行它会给出不同的错误:
java.lang.NoClassDefFoundError:无法初始化类weblogic.corba.j2ee.naming.ORBHelper
这里可能是什么问题?我已经将wlclient.jar添加到了Maven依赖项中