java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ththcc/article/details/79976345
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
    at javax.naming.InitialContext.init(InitialContext.java:244)
    at javax.naming.InitialContext.<init>(InitialContext.java:216)
    at org.hibernate.engine.jndi.internal.JndiServiceImpl.buildInitialContext(JndiServiceImpl.java:109)
    ... 25 more
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
    ... 29 more


解决:导入weblogic.jar
阅读更多

请问关于weblogic.jndi.WLInitialContextFactory的问题

04-21

我建了一个工程jdbc_directrn建立了一个应用程序jdbc_directrn然后建立一个类:jdbc_direct.javarn其代码:rnpackage jdbcexample;rnimport java.sql.*;rnimport javax.naming.*;rnimport javax.sql.*;rnimport java.util.*;rnimport javax.rmi.*;rnrnpublic class Example1 rnrn public static void main(String[] args) rn DataSource ds = null;rn Context ctx = null;rn Connection myConn = null;rn try rn rn /* 获得WebLogic ServerJNDI初始上下文信息rn */rn ctx = getInitialContext();rn /* 建立数据源对象rn */rn ds = (javax.sql.DataSource)rn ctx.lookup("cyoracleDataSource");rn rn catch (Exception E) rn rn System.out.println("Init Error: " + E);rn rn Statement myStatement=null;rn ResultSet myResultSet=null;rn try rn rn //建立连接rn myConn = ds.getConnection();rn // 建立语句对象rn myStatement = myConn.createStatement();rn //建立结果集对象rn myResultSet = myStatement.executeQuery(rn "SELECT * from SCOTT.EMP"rn );rn //遍历结果集对象,访问每一条记录,输出full_name字段rn while(myResultSet.next())rn rn System.out.println("the employee full name is " + myResultSet.getString("ENAME"));rn rn //关闭结果集rn myResultSet.close();rn rn catch (SQLException e) rn rn System.out.println("Error code = " + e.getErrorCode());rn System.out.println("Error message = " + e.getMessage());rn rn finally rn rn try rn rn // close the Statement object using the close() methodrn if (myStatement != null) rn rn myStatement.close();rn rn // close the Connection object using the close() methodrn if (myConn != null) rn rn myConn.close();rn rn rn catch (SQLException e) rn rn System.out.println("Error code = " + e.getErrorCode());rn System.out.println("Error message = " + e.getMessage());rn rn rnrn rn private static Context getInitialContext() throws Exception rn String url = "t3://localhost:7001";rn String user = "cuiyi";rn String password = "12345678";rn Properties properties = null;rn try rn properties = new Properties();rn properties.put(Context.INITIAL_CONTEXT_FACTORY,rn "weblogic.jndi.WLInitialContextFactory");rn properties.put(Context.PROVIDER_URL, url);rn if (user != null) rn properties.put(Context.SECURITY_PRINCIPAL, user);rn properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);rn rn return new InitialContext(properties);rn rn catch(Exception e) rn throw e;rn rn rnrnrnrn我用的是oracle9i数据库 jb+weblogic来开发 数据源JDBC连接池配制没问题rn可是为什么总是在编译的时间提示:rnE:\JBuilder9\jdk1.4\bin\javaw -classpath "C:\J2EE应用开发(JB+weblogic)\weblogic\源代码\第4章\jdbcexample\classes;E:\JBuilder9\jdk1.4\demo\jfc\Java2D\Java2Demo.jar;E:\JBuilder9\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;E:\JBuilder9\jdk1.4\jre\lib\charsets.jar;E:\JBuilder9\jdk1.4\jre\lib\jaws.jar;E:\JBuilder9\jdk1.4\jre\lib\jce.jar;E:\JBuilder9\jdk1.4\jre\lib\jsse.jar;E:\JBuilder9\jdk1.4\jre\lib\rt.jar;E:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\dnsns.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\ldapsec.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\localedata.jar;E:\JBuilder9\jdk1.4\jre\lib\ext\sunjce_provider.jar;E:\JBuilder9\jdk1.4\jre\lib\im\indicim.jar;E:\JBuilder9\jdk1.4\lib\dt.jar;E:\JBuilder9\jdk1.4\lib\htmlconverter.jar;E:\JBuilder9\jdk1.4\lib\tools.jar" jdbcexample.Example1 rnrnrnjava.lang.NullPointerExceptionrnrn at jdbcexample.Example1.main(Example1.java:30)rnrnrnException in thread "main" Init Error: javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]rnrn找不到weblogic.jndi.WLInitialContextFactory呢?rn我把weblogic81下的server下的lib下的weblogic.jar 拷贝到了c:\jdk\lib下并加载到环境变量里了,请问还需要做什么来补救?rnrn

没有更多推荐了,返回首页