Are ItemEntity and CategoryEntity in the same jar file?
If they are not in the same jar file, remove the ejb-link in the ejb-ref
section.

Hope this helps.

Nguyen Thanh Phong                           Tel: 84-8-837 25 06/837 25 07
Saigon Software Development Company (SDC)    Fax: 84-8-837 25 11
10 Co Giang Street, Dist I, HCMC             Email:
[EMAIL PROTECTED]
Vietnam


----- Original Message -----
From: Marquez, Oscar <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 26, 2001 7:52 AM
Subject: [JBoss-user] Why can't EJB1 call EJB2?


> Hi
>
> I sure that I'm doing something wrong but I don't know what.
>
> I have define a EJB1 ItemEntity that referenced a EJB2
> CategoryEntity
>
> THE EJB-JAR.XML for the ItemEntity looks like this. I didn't copy
> all, it's too big
> <ejb-jar>
>   <description>no description</description>
>   <display-name>data</display-name>
>   <enterprise-beans>
>     <entity>
>       <description>no description</description>
>       <display-name>ItemEntity</display-name>
>       <ejb-name>ItemEntity</ejb-name>
>       <home>com.javactive.commerce.data.IjaItemEntityHome</home>
>       <remote>com.javactive.commerce.data.IjaItemEntity</remote>
>       <ejb-class>com.javactive.commerce.data.CjaItemEntityEJB</ejb-class>
>       <persistence-type>Container</persistence-type>
>       <prim-key-class>java.lang.Long</prim-key-class>
>       <reentrant>False</reentrant>
>       <cmp-field>
>         <description>no description</description>
>         <field-name>_id</field-name>
>       </cmp-field>
>       <cmp-field>
> .
> .
> .
>       </cmp-field>
>       <primkey-field>_id</primkey-field>
>       <ejb-ref>
>         <ejb-ref-name>ejb/CategoryEntity</ejb-ref-name>
>         <ejb-ref-type>Entity</ejb-ref-type>
>         <home>com.javactive.commerce.data.IjaCategoryEntityHome</home>
>         <remote>com.javactive.commerce.data.IjaCategoryEntity</remote>
>         <ejb-link>CategoryEntity</ejb-link>
>       </ejb-ref>
> .
> .
> .
>
> THE JBOOS.XML
> <jboss>
>   <secure>false</secure>
>   <container-configurations />
>   <resource-managers />
>   <enterprise-beans>
>     <entity>
>       <ejb-name>CategoryEntity</ejb-name>
>       <jndi-name>shop/CategoryEntity</jndi-name>
>       <configuration-name></configuration-name>
>     </entity>
>     <entity>
>       <ejb-name>ItemEntity</ejb-name>
>       <jndi-name>shop/ItemEntity</jndi-name>
>       <configuration-name></configuration-name>
>     </entity>
>   </enterprise-beans>
> </jboss>
>
> THE EJB for ItemEntity to llok for the CategoryEntity goes like
> this. Here I try to look for the Category in multiple ways.
>
> /**
> * Helper function to get the home interface of a specified Bean.
> This is used by
> * most of the methods in this class.
> */
> private Object getCategoryHome(String path)
> {
> try
> {
> InitialContext context = new InitialContext();
> Object home = context.lookup(path);
> return
> PortableRemoteObject.narrow(home,IjaCategoryEntityHome.class);
> }
> catch (Exception e)
> {}
> return null;
> }
> /**
> * This method looks up a 1 to 1 Bean link.
> * @return CategoryInterface The selected object.
> */
> public IjaCategoryEntity selectCategory()
> throws RemoteException
> {
>
> // Check to see if we've already loaded the link.
> if(_category != null)
> return _category;
> try
> {
> // Change this call if the bean or related bean are
> // different from ItemApp or CategoryApp
> // Use primary/foreign key to lookup relationship
> Context context = new InitialContext();
> IjaCategoryEntityHome categoryHome = null;
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("ejb/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("shop/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("java:comp/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("java:comp/ejb/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("java:comp/shop/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("java:comp/env/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("java:comp/env/ejb/CategoryEntity");
> if (null==categoryHome)
> categoryHome = (IjaCategoryEntityHome)
> getCategoryHome("java:comp/env/shop/CategoryEntity");
>
> _category =
> categoryHome.findByPrimaryKey(getCategoryId());
> return _category;
> }
> catch (Exception e)
> {
> e.printStackTrace();
> throw new RemoteException(e.getMessage());
> }
> }
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to