• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Accessing local entity bean using Session bean

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am usign a session bean to access my entity bean

But I am getting
javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/ForumBean

I am using the deploytool for deploying there is no option to set a JNDI name for Local Entity bean . Is it required to set a JNDI name for the local entity bean ?

My look up code is

Context initial = new InitialContext ();
(ForumHome) initial.lookup ("java:comp/env/ejb/ForumBean
");

My xml files are

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 EJB 2.1//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<name>ForumJar</name>
<ejb>
<ejb-name>ForumBean</ejb-name>
</ejb>
<ejb>
<ejb-name>AccessForumBean</ejb-name>
<jndi-name>AccessForumBean</jndi-name>
</ejb>
<cmp-resource>
<jndi-name>MSG_DB</jndi-name>
</cmp-resource>
</enterprise-beans>
</sun-ejb-jar>
------------------------------------------------------------------------------- ----------------------------
<?xml version='1.0' encoding='UTF-8'?>
<ejb-jar
xmlns="http://java.sun.com/xml/ns/j2ee"
version="2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
>
<display-name>ForumJar</display-name>
<enterprise-beans>
<entity>
<ejb-name>ForumBean</ejb-name>
<local-home>com.forum.ejb.ForumHome</local-home>
<local>com.forum.ejb.Forum</local>
<ejb-class>com.forum.ejb.ForumBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>t_forum</abstract-schema-name>
<cmp-field>
<description>no description</description>
<field-name>forumId</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>forumDesc</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>updationDate</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>userId</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>forumTitle</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>creationDate</field-name>
</cmp-field>
<primkey-field>forumId</primkey-field>
<security-identity>
<use-caller-identity>
</use-caller-identity>
</security-identity>
<query>
<query-method>
<method-name>findForums</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql>SELECT OBJECT(p) FROM t_forum p</ejb-ql>
</query>
<query>
<query-method>
<method-name>ejbSelectMaxFId</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql>SELECT MAX(x.forumId) FROM t_forum x</ejb-ql>
</query>
</entity>
<session>
<ejb-name>AccessForumBean</ejb-name>
<home>com.forum.ejb.AccessForumHome</home>
<remote>com.forum.ejb.AccessForum</remote>
<ejb-class>com.forum.ejb.AccessForumBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<ejb-local-ref>
<ejb-ref-name>ForumBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.forum.ejb.ForumHome</local-home>
<local>com.forum.ejb.Forum</local>
<ejb-link>ejb-jar-ic1.jar#ForumBean</ejb-link>
</ejb-local-ref>
<security-identity>
<use-caller-identity>
</use-caller-identity>
</security-identity>
</session>
</enterprise-beans>
<assembly-descriptor>
<method-permission>
<unchecked>
</unchecked>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>java.lang.Object</method-param>
</method-params>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
<method-param>int</method-param>
</method-params>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>updateForum</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.sql.Date</method-param>
</method-params>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.Integer</method-param>
</method-params>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>isIdentical</method-name>
<method-params>
<method-param>javax.ejb.EJBLocalObject</method-param>
</method-params>
</method>
</method-permission>
<method-permission>
<unchecked>
</unchecked>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>forumId</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>forumDesc</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>creationDate</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>findForums</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>forumTitle</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>updationDate</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>userId</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getPrimaryKey</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>remove</method-name>
</method>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>getEJBLocalHome</method-name>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>forumTitle</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>updateForum</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.sql.Date</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>forumDesc</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>forumId</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>remove</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>creationDate</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>updationDate</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ForumBean</ejb-name>
<method-intf>Local</method-intf>
<method-name>userId</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

from your code in sun-ejb-jar.xml JNDI name for ForumBean was missing

<sun-ejb-jar>
<enterprise-beans>
<name>ForumJar</name>
<ejb>
<ejb-name>ForumBean</ejb-name>
<jndi-name>ForumBean</jndi-name> <!-- MISSING -->
</ejb>
<ejb>
<ejb-name>AccessForumBean</ejb-name>
<jndi-name>AccessForumBean</jndi-name>
</ejb>
<cmp-resource>
<jndi-name>MSG_DB</jndi-name>
</cmp-resource>
</enterprise-beans>
</sun-ejb-jar>

might this will be the solution let me know if it is work
 
Suneesh Raman
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have given the jndi name and deployed . This is the sun-ejb-jar file after deployment . Still I am getting the error

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:542)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:647)
at java.lang.Thread.run(Thread.java:536)
Caused by: java.rmi.RemoteException: ; nested exception is:
javax.naming.NameNotFoundException: ForumBean not found
Caused by: javax.naming.NameNotFoundException: ForumBean not found



My code is

public Forum createForum (String forumTitle, String forumDesc, int userId) throws CreateForumException,CreateException,RemoteException,NamingException
{
ForumHome home = getForumHome ();
return home.create (forumTitle,forumDesc,userId);
}

private ForumHome getForumHome ()throws NamingException
{

Context initial = new InitialContext ();
return (ForumHome) initial.lookup ("ForumBean");


}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 EJB 2.1//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-0.dtd">
<sun-ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee">
<enterprise-beans>
<unique-id>0</unique-id>
<ejb>
<ejb-name>AccessForumBean</ejb-name>
<jndi-name>AccessForumBean</jndi-name>
<pass-by-reference>false</pass-by-reference>
<is-read-only-bean>false</is-read-only-bean>
<refresh-period-in-seconds>-1</refresh-period-in-seconds>
<cmt-timeout-in-seconds>0</cmt-timeout-in-seconds>
<gen-classes/>
</ejb>
<ejb>
<ejb-name>ForumBean</ejb-name>
<jndi-name>ForumBean</jndi-name>
<pass-by-reference>false</pass-by-reference>
<cmp/>
<is-read-only-bean>false</is-read-only-bean>
<refresh-period-in-seconds>-1</refresh-period-in-seconds>
<cmt-timeout-in-seconds>0</cmt-timeout-in-seconds>
<gen-classes/>
</ejb>
<cmp-resource>
<jndi-name>MSG_DB</jndi-name>
</cmp-resource>
</enterprise-beans>
</sun-ejb-jar>


Thanks
Suneesh
 
reply
    Bookmark Topic Watch Topic
  • New Topic