First of the names of the beans should match in your
ejb-jar.xml (HandlerBean) and jbosscmp-jdbc.xml (you have TestBean)

Second of all I am not sure if you can deploy your app in
a single war. My suspision is that you would nedd to break
it up on war [put your web stuff in here] and ejb.jar [put
your ejbs in here] then merge them together into ear.

Basically the structure should look something like the following:

your-ejb.jar
  test/
     YourEjb.class
  META-INF/
     jbosscmp-jdbc.xml
     jboss.xml
     ejb-jar.xml

your-app.war
  index.jsp
  WEB-INF/
     web.xml
     jbossweb.xml
     lib/
        ejb-client.jar

app.ear
  your-app.war
  your-ejb.jar
  MEAT-INF/
     application.xml

and you only copy app.ear into deploy directory

you basically have anywhere from 3 to 6 xml descriptors
to figure out :-)

  ejb-jar.xml [required]
  web.xml     [required]
  application.xml [required]

  jbosscmp-jdbc.xml [optional]
  jboss.xml         [optional]
  jbossweb.xml      [optional]

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of costin
> Sent: Wednesday, February 26, 2003 7:33 AM
> To: [EMAIL PROTECTED]
> Subject: [JBoss-user] help with bounding entity bean
>
>
>   Hi!
>
>   I know that there are responses on the list for this kind of
>   problem but there is no archive...yet.
>
>   I am new to JBoss after moving from Resin EE and I am trying to get
>   the hand of it - especially in the deployment area.
>
>   I have read a lot of tutorials based on ant (includind the official
>   doc) but I can`t make the entity bean bound.
>
>   I have been banging my head agains the wall for the last day and it`s
>   starting to hurt really bad so any help will be greatly appreciated.
>
>
>   Okay, before giving the details here is the behaviour:
>
>   the war is deployed okay and I can see the index.html page. The bean
>   classes are very simple - I have listed them at the end of the
>   message. The problem is that when I am accessing the jsp I cannot
>   get the entity bean reference:
>
> <snip from the log - the extra logging is from the jsp>
>
> 14:11:10,217 INFO  [jbossweb] Started
> WebApplicationContext[/bs,file:/usr/local/jboss-3.0.6/server/defau
> lt/deploy/bs.war/]
> 14:11:10,394 INFO  [jbossweb] successfully deployed
> file:/usr/local/jboss-3.0.6/server/default/deploy/bs.war/ to /bs
> 14:11:10,394 INFO  [MainDeployer] Deployed package:
> file:/usr/local/jboss-3.0.6/server/default/deploy/bs.war/
> 14:11:31,375 INFO  [jbossweb] Registered
> jboss.web:Jetty=0,HttpContext=0,context=/
> 14:11:31,389 INFO  [jbossweb] Registered
> jboss.web:Jetty=0,HttpContext=0,context=/,RootNotFoundHandler=0
> 14:11:31,390 INFO  [jbossweb] Started HttpContext[/]
> 14:11:44,567 INFO  [jbossweb] Got context
> 14:11:44,644 WARN  [jbossweb] WARNING: Naming Exception 1046261504621
> javax.naming.NameNotFoundException: HandlerBean not bound
>         at org.apache.jsp.test$jsp.jspInit(test$jsp.java:52)
>         at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:90)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.load(JspSer
> vlet.java:142)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNeces
> sary(JspServlet.java:178)
>         at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Jsp
> Servlet.java:188)
>         at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
>         at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
>         at
> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplic
> ationHandler.java:280)
>         at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:553)
>         at org.mortbay.http.HttpContext.handle(HttpContext.java:1717)
>         at
> org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicat
> ionContext.java:549)
>         at org.mortbay.http.HttpContext.handle(HttpContext.java:1667)
>         at org.mortbay.http.HttpServer.service(HttpServer.java:862)
>         at org.jboss.jetty.Jetty.service(Jetty.java:497)
>         at
> org.mortbay.http.HttpConnection.service(HttpConnection.java:759)
>         at
> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:923)
>         at org.mortbay.http.HttpConnection.handle(HttpConnection.java:776)
>         at
> org.mortbay.http.SocketListener.handleConnection(SocketListener.java:202)
>         at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
>         at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
>
> 14:11:44,645 INFO  [jbossweb] Naming Exception 1046261504621:
> javax.naming.NameNotFoundException: HandlerBean not bound
>
> </snip>
>
>   Here`s is my configuration:
>
>   jboss-3.0.6 on RH 7.3
>
> $ java -version
> java version "1.4.1_01"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
> Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
>
>   I have configured jboss with mysql using the samples xml and here
>   goes the application.
>
>   I have a very light entity bean that is being called by a jsp. The
>   directory structure is:
>
> $ tree bs
>
> bs
> |-- META-INF
> |   |-- ejb-jar.xml
> |   `-- jbosscmp-jdbc.xml
> |-- WEB-INF
> |   `-- web.xml
> |-- index.html
> |-- test
> |   |-- Handler.class
> |   |-- HandlerBean.class
> |   `-- HandlerHome.class
> `-- test.jsp
>
> 3 directories, 8 files
>
>   I have symlinked the directory to
>   $JBOSS_HOME/server/default/deploy/bs.war
>
>   The sources are as follow:
>
> ####  test.jsp
>
> <%@ page import="javax.ejb.*,javax.naming.*,test.*, java.util.*" %>
> <html>
> <%!
>         HandlerHome home;
>
>         public void jspInit()
>         {
>                 try
>                 {
>
>                  // Get a naming context
>                  InitialContext initial = new InitialContext();
>
>                  getServletContext().log("Got context");
>
>                      home = (HandlerHome) initial.lookup("HandlerBean");
>                  getServletContext().log("Got reference");
>                 }
>                 catch (NamingException e)
>                 {
>                         getServletContext().log("Naming Exception
> "+System.currentTimeMillis(),
>
> e.fillInStackTrace());
>                 }
>         }
> %>
>
> <%
> %>
> </html>
>
> ##########################
>
> As you can see this jsp only get`s the context and then a reference to
> the entity bean.
>
> The deployment files is listed here:
>
> ########### ejb-jar.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE ejb-jar  PUBLIC
>         "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
>                 "http://java.sun.com/dtd/ejb-jar_2_0.dtd";>
> <ejb-jar>
>   <enterprise-beans>
>    <entity>
>
>     <ejb-name>HandlerBean</ejb-name>
>
>     <local-home>test.HandlerHome</local-home>
>     <local>test.Handler</local>
>     <ejb-class>test.HandlerBean</ejb-class>
>
>     <persistence-type>Container</persistence-type>
>     <cmp-version>2.x</cmp-version>
>     <reentrant>True</reentrant>
>
>     <prim-key-class>java.lang.String</prim-key-class>
>     <primkey-field>entry</primkey-field>
>
>     <abstract-schema-name>ejbtest</abstract-schema-name>
>
>     <cmp-field>
>                 <field-name>entry</field-name>
>     </cmp-field>
>     <cmp-field>
>                 <field-name>name</field-name>
>     </cmp-field>
>
>   </entity>
>
> </enterprise-beans>
>
> </ejb-jar>
> #####################################
> ##################### jboss-cmp
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE jbosscmp-jdbc PUBLIC
>    "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
>    "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd";>
>
> <jbosscmp-jdbc>
>
>    <enterprise-beans>
>
>       <entity>
>          <ejb-name>TestBean</ejb-name>
>          <table-name>TestBean</table-name>
>
>          <cmp-field>
>             <field-name>entry</field-name>
>             <column-name>entry</column-name>
>          </cmp-field>
>          <cmp-field>
>             <field-name>name</field-name>
>             <column-name>name</column-name>
>          </cmp-field>
>
>       </entity>
>
>    </enterprise-beans>
>
> </jbosscmp-jdbc>
> #################
>
>
> the classes:
>
> ################# Handler.java
> package test;
>
> import javax.ejb.EJBLocalObject;
>
> public interface Handler extends EJBLocalObject
> {
>          public String getName();
>      void setName(String name);
>
>      public String getEntry();
>      void setEntry(String id);
> }
> ##############
>
> ################# HandlerBean.java
> package test;
>
> import javax.ejb.*;
>
> public abstract class HandlerBean implements EntityBean {
>
>   public abstract String getName();
>   public abstract void setName(String name);
>
>   public abstract String getEntry();
>   public abstract void setEntry(String id);
>
>
>   public String ejbCreate(String id, String name)
>     throws CreateException
>   {
>         setEntry(id);
>     setName(name);
>
>     return null;
>   }
>
>   public void ejbPostCreate(String name, String id)
>   {
>   }
>
> }
> ###########################
> ##################### HandlerHome.java
> package test;
>
> import javax.ejb.EJBLocalHome;
> import javax.ejb.CreateException;
> import javax.ejb.FinderException;
>
> public interface HandlerHome extends EJBLocalHome
> {
>         public Handler create(String id, String name)
>                 throws CreateException;
>
>         public Handler findByPrimaryKey(String entry)
>                 throws FinderException;
>
> }
> ##############################
>
>
> P.S. Sorry about this huge email.
>
>
> --
> Thanks,
>  costin
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Scholarships for Techies!
> Can't afford IT training? All 2003 ictp students receive scholarships.
> Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
> www.ictp.com/training/sourceforge.asp
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>



-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to