Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  


» Java开发网 » Application Server  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:请问在JBoss下面部署的EJB如何在Resin下面使用呢? [Re:lvjing79]

发贴: 8
积分: 0
于 2005-03-27 20:55 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list


From Dave Dribin:

To have a Resin web application use jBoss, do the following:

Copy "ejb.jar", "jboss-client.jar", and "jnp-client.jar" from $JBOSS_HOME/client into WEB-INF/lib.
Copy the EJB jar file that you put in $JBOSS_HOME/deploy into WEB-INF/lib.
Put the following <web-app> into resin.conf:
<web-app id='/web-app-path' app-dir='/real/path/of/web-app'>
<init-param java.naming.provider.url="localhost:1099"/>

Of course change the JNDI URL if you're running jBoss on a different machine.

Make sure you map all of your EJBs to the "ejb/" JNDI context. For example, I have this in my jboss.xml:

.... other beans ....


This way you can lookup all the Home interfaces in the "java:comp/env/ejb/" context.

I've attached a simple JSP that shows how to access the User EJB.

And don't forget that if you re-deploy your beans to jBoss, you should copy over the jar file into WEB-INF and restart Resin.

Hope that helps!


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>EJB Test</title>

<body bgcolor="#FFFFFF">
<%@ page import='javax.naming.*' %>
<%@ page import='ejbeans.*' %>
<%@ page import='javax.rmi.*' %>
<h1 align=center>EJB Test</h1>

// Get a naming context
InitialContext jndiContext;
Object ref;

// Get a reference to a UserHome Bean
jndiContext = new InitialContext();
ref = jndiContext.lookup("java:comp/env/ejb/UserHome");

int userPK;

UserHome userHome;
User user;

userHome = (UserHome)
PortableRemoteObject.narrow (ref, UserHome.class);

userPK = Integer.parseInt(request.getParameter("pk"));
user = userHome.findByPrimaryKey(new UserPK(userPK));

<table border="3" width="100%">
<th> ID </th>
<th> First Name </th>
<th> Last Name </th>

<th> <%= user.getId() %> </th>
<th> <%= user.getFirstName() %> </th>

<th> <%= user.getLastName() %> </th>




人气 标题 作者 字数 发贴时间
10994 请问在JBoss下面部署的EJB如何在Resin下面使用呢? lvjing79 81 2005-03-09 12:35
9181 Re:请问在JBoss下面部署的EJB如何在Resin下面使用呢? citybeat 2725 2005-03-27 20:55

flat modethreaded modego to previous topicgo to next topicgo to back
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱    客服QQ 714923