调用他可以写个servlet调。可以调jndi name
解决方案 »
- 在struts的action中request.setAttribute("dayReportList", dayReportList);这个对像,在另一个页面取不这个值
- Spring 高手进,讨论下 JdbcTemplate 的用法
- 求教,自己写了一个structs2的helloworld,可总是出问题。
- 两个java web项目传参问题
- JAVA爱好者及高手:QQ群:691713,现在还差数人,加满为止!
- 急问,在JBoss下如何配置实体CMR
- 求助:关于Struts中html:file标签的英文显示问题。
- 各位一定要帮我:Resin服务器的问题!
- jdom处理xml问题,为什么总是“UTF-8”?
- Jbuilder4开发的EJB如何在Jboss中deploy?
- 客户端远程访问EJB
- weblogic 登陆问题!!!!!!
j2se + j2ee 比较轻量级的那种,我在客户机和服务器上都安装了同样的运行环境.
ht.put(ctx.PROVIDER_URL, "t3://ip:port"); //不要问我ip:port是什么哦:)
ht.put(ctx.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
initctx = new InitialContext(ht);不想抢分了,这个问题也回答了不知道多少遍了...怎么就没人保存一下在贴上 :)
package com.learnweblogic.examples;import java.util.Properties;import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;public abstract class BaseClient { private Context ctx; private String url = "t3://localhost:7001"; protected Object narrow(Object o, Class c) {
return PortableRemoteObject.narrow(o, c);
} protected Context getInitialContext()
throws NamingException
{
if (ctx == null) { try { Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, url);
ctx = new InitialContext(p); } catch (NamingException ne) {
System.err.println("** Unable to connect to the server at:"
+url);
ne.printStackTrace();
throw ne;
} } return ctx;
} public BaseClient(String [] argv) { if (argv.length > 0) url = argv[0];
}
}
package com.learnweblogic.examples;import com.learnweblogic.examples.BaseClient;import javax.naming.Context;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;public final class HelloWorldClient extends BaseClient { private Context ctx; HelloWorldClient(String [] argv)
throws NamingException
{
super(argv); ctx = getInitialContext(); } public void runClient()
throws Exception
{
HelloWorldHome home = null; try {
Object h = ctx.lookup("HelloWorldEJB"); home = (HelloWorldHome)
PortableRemoteObject.narrow(h, HelloWorldHome.class);
} catch (NamingException ne) {
System.err.println("Unable to lookup the HelloWorld EJB.");
System.err.println("Please make sure that the bean has been deployed"+
", and the client's classpath has been set correctly."); throw ne;
} try {
HelloWorld hw = home.create(); System.out.println("Say Hello to EJB."); String ejbSays = hw.helloWorld(); System.out.println("The EJB said: "+ejbSays);
} catch (Exception e) {
System.err.println("Received an unexpected exception " + e
+ " while using the HelloWorldEJB."); throw e;
}
} public static void main(String[] argv)
throws Exception
{
HelloWorldClient hwc = new HelloWorldClient(argv); hwc.runClient(); }
}
1.保证服务器端的ejb成功的发布,需要注意的是准备调用的jndi的名要确认一下。
2.客户端的程序,按照 模范老公说的初始化initctx,然后根据确认了的jndi名
就可以调ejb了。
ht.put(ctx.PROVIDER_URL, "t3://ip:port"); //不要问我ip:port是什么哦:)
ht.put(ctx.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
initctx = new InitialContext(ht);................这个具体如何写就更好了..................(送100分)