当前位置: 技术问答>java相关
帮我看看这个客户端把----------------- 送你 200 分
来源: 互联网 发布时间:2015-07-21
本文导语: import orderMgmt.*; import java.util.Properties; import javax.naming.*; import javax.naming.Context; import javax.rmi.*; public class Client { public static void main( String args[] ) { try{ Properties prop = new...
import orderMgmt.*;
import java.util.Properties;
import javax.naming.*;
import javax.naming.Context;
import javax.rmi.*;
public class Client
{
public static void main( String args[] )
{
try{
Properties prop = new Properties();
prop.put( Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory" );
prop.put( Context.PROVIDER_URL, "t3://localhost:7001" );
Context ctx = new InitialContext( prop );
OrderManagementHome home = (OrderManagementHome)
PortableRemoteObject.narrow(
ctx.lookup( "java:comp/env/ejb/OrderManagement"),
OrderManagementHome.class );
OrderManagement order = (OrderManagement)home.create();
order.placeOrder( "lin", "hui", 5 );
order.remove();
}catch( Exception e ){
System.err.println( "" + e.getMessage() );
System.err.println( "" + e.toString() );ss
}
}
}
运行后提示:
Cannot instantiate class:
weblogic.jndi.WLInitialContextFactory
javax.naming.NoInitialContextException:
Cannot instantiate class:
weblogic.jndi.WLInitialContextFactory
[Root exception is java.lang.ClassNotFoundException:
weblogic.jndi.WLInitialContextFactory]
帮忙看看!!! 谢谢
import java.util.Properties;
import javax.naming.*;
import javax.naming.Context;
import javax.rmi.*;
public class Client
{
public static void main( String args[] )
{
try{
Properties prop = new Properties();
prop.put( Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory" );
prop.put( Context.PROVIDER_URL, "t3://localhost:7001" );
Context ctx = new InitialContext( prop );
OrderManagementHome home = (OrderManagementHome)
PortableRemoteObject.narrow(
ctx.lookup( "java:comp/env/ejb/OrderManagement"),
OrderManagementHome.class );
OrderManagement order = (OrderManagement)home.create();
order.placeOrder( "lin", "hui", 5 );
order.remove();
}catch( Exception e ){
System.err.println( "" + e.getMessage() );
System.err.println( "" + e.toString() );ss
}
}
}
运行后提示:
Cannot instantiate class:
weblogic.jndi.WLInitialContextFactory
javax.naming.NoInitialContextException:
Cannot instantiate class:
weblogic.jndi.WLInitialContextFactory
[Root exception is java.lang.ClassNotFoundException:
weblogic.jndi.WLInitialContextFactory]
帮忙看看!!! 谢谢
|
把weblogic.jar加到CLASSPATH应该可以了
WLInitialContextFactory是JNDI进行查找时需要提供的SPI
具体位置在:%WL_HOME%/lib/weblogic.jar
WLInitialContextFactory是JNDI进行查找时需要提供的SPI
具体位置在:%WL_HOME%/lib/weblogic.jar
|
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(h);
这样没错啊,你把weblogic.jar加进来了没有?
没加进来肯定不行的啊。
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(h);
这样没错啊,你把weblogic.jar加进来了没有?
没加进来肯定不行的啊。