弟兄,随便找本书都会告诉你如何调用ejb的啊。
给个例子吧。<%@ page contentType="text/html; charset=gb2312"
import="weblogictest.*"
import="java.io.*"
import="java.util.*"import="javax.ejb.*"
import="java.rmi.*"
import="javax.rmi.PortableRemoteObject"
import="javax.naming.*"
import="com.wellsoon.NetSecurity.RBAC.*"
import="com.wellsoon.NetSecurity.login.*"
%>
<%
boolean success = true;
try {
Context ctx = new InitialContext(System.getProperties());
ejbGroupTableRemoteHome home = (ejbGroupTableRemoteHome) PortableRemoteObject.
narrow(ctx.lookup("ejbGroupTableRemote"), ejbGroupTableRemoteHome.class);
ejbGroupTableRemote ejbGroup = home.createWithoutParentID(
request.getParameter("groupName"),request.getParameter("groupDesc"));
}
catch (Exception e) {
//response.getWriter().println("³öÏÖ´íÎó");
success=false;
e.printStackTrace();
}%>
<html>
<head>
<title>
deleteGroup
</title>
</head>
<body bgcolor="#ffffff">
<%if(success) {
response.sendRedirect("groupManagement.jsp");
}else {%>
<h2>Ìí¼Óʧ°Ü£¡</h2>
<%}%>
</body>
</html>
给个例子吧。<%@ page contentType="text/html; charset=gb2312"
import="weblogictest.*"
import="java.io.*"
import="java.util.*"import="javax.ejb.*"
import="java.rmi.*"
import="javax.rmi.PortableRemoteObject"
import="javax.naming.*"
import="com.wellsoon.NetSecurity.RBAC.*"
import="com.wellsoon.NetSecurity.login.*"
%>
<%
boolean success = true;
try {
Context ctx = new InitialContext(System.getProperties());
ejbGroupTableRemoteHome home = (ejbGroupTableRemoteHome) PortableRemoteObject.
narrow(ctx.lookup("ejbGroupTableRemote"), ejbGroupTableRemoteHome.class);
ejbGroupTableRemote ejbGroup = home.createWithoutParentID(
request.getParameter("groupName"),request.getParameter("groupDesc"));
}
catch (Exception e) {
//response.getWriter().println("³öÏÖ´íÎó");
success=false;
e.printStackTrace();
}%>
<html>
<head>
<title>
deleteGroup
</title>
</head>
<body bgcolor="#ffffff">
<%if(success) {
response.sendRedirect("groupManagement.jsp");
}else {%>
<h2>Ìí¼Óʧ°Ü£¡</h2>
<%}%>
</body>
</html>
解决方案 »
- 企业开发JAVAEE项目用什么集成开发环境?
- 请教高手:在action中如何取得<s:checkboxlist>其选中的值?
- 请问类似于QQ空间的“最近访客”功能,及访问次数怎么实现呢?
- SSH插入数据时因为有相同数据而抛出异常!
- 网站前后台问题
- struts2.16 ajax有没什么标签返回的是一个数据结果集
- /ect/profile和在/root/.bash_profile配置系统环境变量的区别是什么
- 很久的问题。。。
- 本人有一套ejb产品(想与大家资源共享)
- 调查一下:大家在用什么工具开发Ejb?开发多久了?目前待遇多少?
- 请问在webLogic中,出现“指定网络名不可用”一般是在出现什么错误时发生?
- 大家帮我看看JBuilder7中jsp调用ejb时报的错误是什么意思(解决后马上给分)
import="weblogictest.*"是什么?是你发布ejb时打的包吗?还有classpath该怎么设置?要把发布的ejb的jar包加到classpath中去吗?是不是把weblogic.jar包加到classpath去就行了?
把打好的jar包放到WEB-INF/lib下。就可以了,不需要改classpath。
如果发布的?如果按规矩发布,用JNDI就可以调用了。
我在j2ee服务器中jsp调用ejb已经成功啦(这里面可以设置jndi),现在转到weblogic中出现的问题多多,我现在都不知道怎样在weblogic中配置jndi啦,难道又要手动编写xml文件?那weblogic还没有j2ee服务器方便呢。
如果部署成功了,那么你写在部署描述符里面的jndi name就会
自动添加到weblogic的jndi Tree中去的。你可以在console中
看到的。实际对ejb的调用只需要查找到jndi name,得到RemoteHome对象,
就可以访问了啊。不明白你的问题到底是指什么?
的ejb,就会知道里面的过程了。
我就是用Jbuilder7开发的,weblogic8控制台上已经有我发布的ejb啦。现在关键是怎么用jsp调用它。 InitialContext ic = new InitialContext();
********** 这里我该怎么设置jndi呢?***************************
Object objRef = ic.lookup("java:comp/env/ejb/TheConverter");
************那个TheConverter在哪里设置?(我没有打成ear包)****
ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(
objRef, ConverterHome.class);
converter = home.create();还有我在weblogic控制台中没有看到jndi Tree,请问在哪里?
jndi name就可以了。jndi name是你自己写在部署文件中的,
应该是在weblogic-ejb-jar.xml中。
比如:
<jndi-name>ejb20CMPRemote</jndi-name>
<local-jndi-name>ejb20CMP</local-jndi-name>
你只需要lookup("ejb20CMPRemote")就可以了。至于jndi tree,你可以在weblogic的控制台页面的左边applet部分,
单击鼠标右键,在弹出的菜单中选择jndi tree,就会弹出一个
浏览器窗口,显示weblogic系统此时的jndi tree了。那里面有
你的ejb 的jndi name的全路径。
鼠标右键。
你自己找找看就知道了。