This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

access entity bean in session bean by local interface  RSS feed

 
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
my session bean is "Viewer",my entity bean is "Authors",both of them are within the same jar file named "Viewer.jar".i create a test client by using jb6,in this client i access the session bean by using remote interface,it works well,but when i try to access the entity bean in the session bean by the local interface,the jb6 throw a "NameNotFoundException".following is the details:
my deployment descriptor:

<?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>
<session>
<display-name>Viewer</display-name>
<ejb-name>Viewer</ejb-name>
<home>test.ViewerHome</home>
<remote>test.Viewer</remote>
<ejb-class>test.ViewerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<entity>
<display-name>Authors</display-name>
<ejb-name>Authors</ejb-name>
<local-home>test.AuthorsHome</local-home>
<local>test.Authors</local>
<ejb-class>test.AuthorsBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Authors</abstract-schema-name>
<cmp-field>
<field-name>auId</field-name>
</cmp-field>
<cmp-field>
<field-name>auLname</field-name>
</cmp-field>
<cmp-field>
<field-name>auFname</field-name>
</cmp-field>
<cmp-field>
<field-name>phone</field-name>
</cmp-field>
<cmp-field>
<field-name>address</field-name>
</cmp-field>
<cmp-field>
<field-name>city</field-name>
</cmp-field>
<cmp-field>
<field-name>state</field-name>
</cmp-field>
<cmp-field>
<field-name>zip</field-name>
</cmp-field>
<cmp-field>
<field-name>contract</field-name>
</cmp-field>
<primkey-field>auId</primkey-field>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Viewer</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>Authors</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>



in my session bean,i specify:

...............
..............
Context ctx=new InitialContext();
Object ref=ctx.lookup("Authors");
................
..............



i think that i should add the "ejb-local-ref" tag to the deployment descriptor,as follow:

<?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>
<session>
<display-name>Viewer</display-name>
<ejb-name>Viewer</ejb-name>
<home>test.ViewerHome</home>
<remote>test.Viewer</remote>
<ejb-class>test.ViewerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref>
<description />
<ejb-ref-name>Authors</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>test.AuthorsHome</local-home>
<local>test.Authors</local>
<ejb-link>Authors</ejb-link>
</ejb-local-ref>
</session>
<entity>
<display-name>Authors</display-name>
<ejb-name>Authors</ejb-name>
<local-home>test.AuthorsHome</local-home>
<local>test.Authors</local>
<ejb-class>test.AuthorsBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Authors</abstract-schema-name>
<cmp-field>
<field-name>auId</field-name>
</cmp-field>
<cmp-field>
<field-name>auLname</field-name>
</cmp-field>
<cmp-field>
<field-name>auFname</field-name>
</cmp-field>
<cmp-field>
<field-name>phone</field-name>
</cmp-field>
<cmp-field>
<field-name>address</field-name>
</cmp-field>
<cmp-field>
<field-name>city</field-name>
</cmp-field>
<cmp-field>
<field-name>state</field-name>
</cmp-field>
<cmp-field>
<field-name>zip</field-name>
</cmp-field>
<cmp-field>
<field-name>contract</field-name>
</cmp-field>
<primkey-field>auId</primkey-field>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Viewer</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>Authors</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>


but it throw another exception as:

"Viewer.ejbgrpx": Jar verify failed: java.lang.ClassCastException: com.borland.jbuilder.enterprise.ejb.bes.c



why?
who can help me?thank you!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!