• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB initial context error

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

I am very frustrated and tired, I thought I am doing everything right, I really don’t know what wrong, please have a look if it make sense to you :-

I have error below

Unable to get an Entity Manager Instance
javax.naming.NameNotFoundException: No object bound to name java:comp/env/CategoryLookup
at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:856)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:407)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at cig.persistence.eao.CategoryEAOImpl.getEntityManager(CategoryEAOImpl.java:27)
at cig.persistence.eao.CategoryEAOImpl.<init>(CategoryEAOImpl.java:20)
at cig.persistence.manager.EAOFactory.getCategoryEAOIF(EAOFactory.java:30)
at cig.bizlogic.CategoryModelImpl.getAllCategorys(CategoryModelImpl.java:72)

I have created a EAO(persistence) just an extra layer to divide the EJB (biz logic).
I am using nextbean

EJBbizMethod --> EAOManager  EAOImpl

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

In EnterpriseApplication-ejb:
----------------------------------------
public class EAOImpl implements EAOIF{
private EntityManager getEntityManager() {
try {
InitialContext ctx = new InitialContext();
return (EntityManager) ctx.lookup("java:comp/env/CategoryLookup");
} catch (Exception e) {
System.out.println("Unable to get an Entity Manager Instance");
e.printStackTrace();
return null;
}
}

Persistence.xml
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="StockMarket-ejbPU" transaction-type="JTA">
<jta-data-source> StockMarket </jta-data-source>
<jar-file>EntityUtil.jar</jar-file>
<properties/>
</persistence-unit>
</persistence>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
In EnterpriseApplication-war:

Web.xml
------------
<ejb-ref>
<ejb-ref-name>CategoryLookup</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>bizlogicif. EJBbizMethod </remote>
<ejb-link> EJBbizMethodImpl</ejb-link>
</ejb-ref>

Some Call to EJBbizMethod
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
reply
    Bookmark Topic Watch Topic
  • New Topic