geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Katia Aresti Gonzalez" <kaare...@hotmail.com>
Subject Fail deploying a simple EJB (JavaBean)
Date Sat, 02 Apr 2005 01:33:00 GMT
<html><div style='background-color:'><DIV class=RTE>
<P>Hi!!</P>
<P>Im trying to deploy a simple EJB, and the applications deploys ok. The conection
with the database works ok, but when I try the EJB test, Geronimo throws the javax.naming.NamingNotFoundException,
doesnt fiend de EJB...</P>
<P>Date EJB. This is the code. If anybody can help???</P>
<P>Thank you!</P>
<P>Katia (Its the example of javaworld)</P>
<P><CODE>package test.ejb;<BR><BR>public class DateBean implements
javax.ejb.SessionBean {<BR>&nbsp;&nbsp;&nbsp;&nbsp;public void ejbCreate()
{ }<BR>&nbsp;&nbsp;&nbsp;&nbsp;public void ejbRemove() { }<BR>&nbsp;&nbsp;&nbsp;&nbsp;public
void ejbActivate() { }<BR>&nbsp;&nbsp;&nbsp;&nbsp;public void ejbPassivate()
{ }<BR>&nbsp;&nbsp;&nbsp;&nbsp;public void setSessionContext(javax.ejb.SessionContext
ctx) { }<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;public String getDate()
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return
new java.util.Date().toString();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></CODE></P>
<P>
<P><CODE>
<P><CODE>package test.ejb;<BR><BR>public interface DateHome extends
javax.ejb.EJBHome { <BR>&nbsp;&nbsp;&nbsp;&nbsp;DateRemote create()
throws java.rmi.RemoteException,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;javax.ejb.CreateException;<BR>}<BR></CODE>
<P></CODE>
<P><CODE>
<P><CODE>package test.ejb;<BR><BR>public interface DateRemote extends
javax.ejb.EJBObject {<BR>&nbsp;&nbsp;public String getDate() throws java.rmi.RemoteException;<BR>}<BR></CODE>
<P></CODE>
<P>&nbsp;
<P>EJB descriptor file:
<P><CODE></P><CODE>&lt;?xml version="1.0"?&gt;<BR><BR>&lt;!DOCTYPE
ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.<BR>0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"&gt;
<BR><BR>&lt;ejb-jar&gt;<BR>&lt;description&gt;Geronimo EJB
Test&lt;/description&gt;<BR><BR>&lt;enterprise-beans&gt;<BR>&nbsp;&nbsp;&lt;session
id="GeronimoTestEJB"&gt;<BR>&nbsp;&nbsp; &lt;ejb-name&gt;DateEJB&lt;/ejb-name&gt;<BR>&nbsp;&nbsp;
&lt;home&gt;test.ejb.DateHome&lt;/home&gt;<BR>&nbsp;&nbsp; &lt;remote&gt;test.ejb.DateRemote&lt;/remote&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;ejb-class&gt;test.ejb.DateBean&lt;/ejb-class&gt;<BR>&nbsp;&nbsp;
&lt;session-type&gt;Stateless&lt;/session-type&gt;<BR>&nbsp;&nbsp;
&lt;transaction-type&gt;Container&lt;/transaction-type&gt;<BR>&nbsp;&nbsp;&lt;/session&gt;<BR>&lt;/enterprise-beans&gt;<BR><BR>&lt;/ejb-jar&gt;<BR></CODE>
<P></CODE>
<P>Note the EJB name is <CODE>DateEJB</CODE>. In the next file, <CODE>$GERONIMO_DEVEL/etc/openejb-jar.xml</CODE>,
we map this name to a JNDI name:
<P><CODE>
<P><CODE>&lt;?xml version="1.0"?&gt;<BR><BR>&lt;openejb-jar
xmlns="http://www.openejb.org/xml/ns/openejb-jar" <BR>configId="GeronimoTestEJB" <BR>parentId="org/apache/geronimo/Server"&gt;<BR><BR>&lt;enterprise-beans&gt;
<BR>&nbsp;&nbsp;&lt;session&gt;<BR>&nbsp;&nbsp; &lt;ejb-name&gt;DateEJB&lt;/ejb-name&gt;<BR>&nbsp;&nbsp;
&lt;jndi-name&gt;DateEJB&lt;/jndi-name&gt;<BR>&nbsp;&nbsp;&lt;/session&gt;
<BR>&lt;/enterprise-beans&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&lt;/openejb-jar&gt;
<BR></CODE>
<P></CODE>
<P><CODE>$GERONIMO_DEVEL/etc/application.xml</CODE>:
<P><CODE>
<P><CODE>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<BR><BR>&lt;!DOCTYPE
application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"&gt;<BR>&nbsp;&nbsp;<BR>&lt;application
id="GeronimoTestApp"&gt;<BR>&nbsp;&nbsp;&lt;display-name&gt;GeronimoTestApp&lt;/display-name&gt;<BR>&nbsp;&nbsp;&lt;description&gt;A
test of a simple EJB&lt;/description&gt;<BR>&nbsp;&nbsp;&lt;module&gt;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;ejb&gt;gtest-ejbs.jar&lt;/ejb&gt;
<BR>&nbsp;&nbsp;&lt;/module&gt; <BR>&nbsp;&nbsp;&lt;module&gt;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;web&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;web-uri&gt;gtest.war&lt;/web-uri&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;context-root&gt;GeronimoTestWebApp&lt;/context-root&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/web&gt;<BR>&nbsp;&nbsp;&lt;/module&gt;<BR>&lt;/application&gt;<BR></CODE>
<P></CODE></P>
<P><FONT face="Courier New">$GERONIMO_DEVEL/web/ejbtest.jsp</FONT>: </P>
<P><CODE>
<P><CODE>&lt;%@ page language="java" import="javax.naming.*,<BR>javax.ejb.CreateException,<BR>javax.ejb.RemoveException,<BR>java.rmi.RemoteException,<BR>javax.naming.NamingException,<BR>test.ejb.*<BR>"%&gt;<BR><BR>&lt;html&gt;<BR>&lt;head&gt;<BR>&nbsp;&nbsp;&lt;title&gt;EJB
Test&lt;/title&gt;<BR>&nbsp;&nbsp;&lt;style type="text/css"&gt;
<BR><BR>&nbsp;&nbsp; &lt;!--<BR>&nbsp;&nbsp;&nbsp;&nbsp;a
{ text-decoration: none }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body
{ font-family: verdana, helvetica, sans serif; font-size: 10pt; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;td
{ font-family: verdana, helvetica, sans serif; font-size: 10pt; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;p
{ font-family: verdana, helvetica, sans serif; font-size: 10pt; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;h3
{ font-family: verdana, helvetica, sans serif; font-size: 12pt; font-weig<BR>ht: bold;
color: #547180; } <BR>&nbsp;&nbsp; --&gt; 
<BR>&nbsp;&nbsp;&lt;/style&gt; <BR>&lt;/head&gt; <BR>&nbsp;&nbsp;
<BR>&lt;body&gt;<BR>&nbsp;&nbsp;&lt;br/&gt;&nbsp;<BR>&nbsp;&nbsp;&lt;br/&gt;&nbsp;<BR><BR>&nbsp;&nbsp;&lt;center&gt;&lt;h3&gt;Geronimo
Test Application - EJB test&lt;/h3&gt;&lt;br/&gt;<BR><BR>&lt;%<BR>&nbsp;&nbsp;
String output = "";<BR><BR>&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<STRONG>javax.naming.InitialContext
ctx = new javax.naming.InitialContext();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Object
obj = ctx.lookup("java:comp/env/DateEJB");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DateHome
home =<BR></STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(DateHome)javax.rmi.PortableRemoteObject.narrow(obj,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DateHome.class);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DateRemote
dr = 
home.create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output
= dr.getDate();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dr.remove();<BR>&nbsp;&nbsp;
} catch (NamingException e){<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.err.println("Naming
exception occurred during initialization"+ e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
e.printStackTrace();<BR>&nbsp;&nbsp; }<BR><BR>%&gt;<BR><BR>&nbsp;&nbsp;
&lt;p&gt;The EJB said: &lt;%= output %&gt;&lt;/p&gt;<BR><BR>&lt;/body&gt;<BR>&lt;/html&gt;</CODE></P>
<P><CODE>help!! ;-)</CODE></P>
<P><CODE><BR>&nbsp;</P></CODE>
<P></CODE></P>
<P>&nbsp;</P></DIV></div><br clear=all><hr>Coches
nuevos, coches de ocasiĆ³n, coches de Km 0 <a href="http://g.msn.com/8HMBESES/2746??PS=47575"
target="_top">Si piensas en cambiar de coche, MSN Motor.</a> </html>

Mime
View raw message