当前位置: 技术问答>java相关
简单程序报错不简单!
来源: 互联网 发布时间:2015-10-31
本文导语: import java.util.Properties; public class InitCtx { public static void main(String [] args) { try { Properties env=new Properties(); env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory"); env.put(javax.naming.Contex...
import java.util.Properties;
public class InitCtx {
public static void main(String [] args) {
try {
Properties env=new Properties();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(javax.naming.Context.PROVIDER_URL,"file:c:\");
javax.naming.Context ctx=new javax.naming.InitialContext(env);
System.out.println("Success!");
}
catch (javax.naming.NamingException e) {
e.printStackTrace();
}
}
}
报错:
E:Javatemp>java InitCtx
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.f
scontext.RefFSContextFactory. Root exception is java.lang.ClassNotFoundExceptio
n: com.sun.jndi.fscontext.RefFSContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:201)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:189)
at java.lang.ClassLoader.loadClass(ClassLoader.java:309)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:265)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:325)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:212)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:45)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.(InitialContext.java:198)
at InitCtx.main(InitCtx.java:10)〕
帮我看看!
public class InitCtx {
public static void main(String [] args) {
try {
Properties env=new Properties();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(javax.naming.Context.PROVIDER_URL,"file:c:\");
javax.naming.Context ctx=new javax.naming.InitialContext(env);
System.out.println("Success!");
}
catch (javax.naming.NamingException e) {
e.printStackTrace();
}
}
}
报错:
E:Javatemp>java InitCtx
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.f
scontext.RefFSContextFactory. Root exception is java.lang.ClassNotFoundExceptio
n: com.sun.jndi.fscontext.RefFSContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:201)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:189)
at java.lang.ClassLoader.loadClass(ClassLoader.java:309)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:265)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:325)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:212)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:45)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.(InitialContext.java:198)
at InitCtx.main(InitCtx.java:10)〕
帮我看看!
|
Context.INITIAL_CONTEXT_FACTORY是情景工厂的名称
com.sun.jndi.fscontext.RefFSContextFactory是实现情景工厂的类名
name是你在JNDI XML里面配置的jndi名称
com.sun.jndi.fscontext.RefFSContextFactory是实现情景工厂的类名
name是你在JNDI XML里面配置的jndi名称
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。