Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Unable to register JNDI Name

Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am deploying 2 stateless session bean's under 1 jar.

Under EJB Module's, i am able to see both Stateless Session Bean's.

However when i see under JNDI tree, only 1 bean has it's mappedName. I am not able to make out why the other bean doesn't has mappedName getting registered under JNDI tree. this class i am able to see it's JNDI name in GlassFish)

package Pack;

import java.util.List;

import javax.ejb.Stateful;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;
import javax.persistence.SqlResultSetMapping;
import javax.persistence.EntityResult;

import Factory.CarEAO;
import Factory.EAOFactory;
import Factory.JPAEAOFactory;
* Session Bean implementation class CarCreatorBean
@Stateless(name="StatelessSessionBean", mappedName="ejb/SimpleJNDIName")
@SqlResultSetMapping(name = "CarResults",
entities = @EntityResult(entityClass = Pack.Car.class))

public class CarCreatorBean implements CarCreator {

* Default constructor.
public CarCreatorBean() {
// TODO Auto-generated constructor stub

@PersistenceContext(unitName ="actionBazaar")
private EntityManager entityManager;

public void addCarComponents(String horn, String steering, String wheel){
Car car = new Car("horn", "steering", "wheel");
System.out.println("Inside addCarComponents" + entityManager);
public void addMergeCarComponents(String horn, String steering, String wheel){
Car car = new Car("horn", "steering", "wheel");
public void undoCarComponents(String horn, String steering, String wheel){
Car car = new Car("horn", "steering", "wheel");
public void deleteCarComponents(Long id){
entityManager.remove(entityManager.find(Car.class, id));
public Car retrieveItem(Long id){
Car car = entityManager.find(Car.class, id);
return car;
public List sqlQuery(){
// System.out.println("Inside the sqlQuery method");
// Query query = entityManager.createQuery("select c from Car c");

Query query = entityManager.createNamedQuery("findCar");
query.setParameter("steering", "steering");
return query.getResultList();

public List sqlQuery1(){
Query query = entityManager.createNamedQuery("findCar1");
query.setParameter(1, "horn");
// set the maximum no. of objects to be retrieved.
// set the initial position for the first result being retrieved.
return query.getResultList();

public List nativeResult(){
Query query = entityManager.createNativeQuery("select * from Car");
return query.getResultList();

public void carFactory(String steering, String horn, String wheel){
CarEAO carEAO = EAOFactory.jpa.getCarEAO();
carEAO.addCar(steering, horn, wheel);

----------------------------------------- this class unable to see it's mappedName in JNDI tree, why?)

package Factory;

import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.sql.DataSource;

import Pack.Car;

@Stateless(name="StatelessSessionBean1", mappedName="ejb/SimpleJNDIName1")
public class CarEAOImpl implements CarEAO{

public CarEAOImpl(){

//@PersistenceContext(unitName ="actionBazaar")
// private EntityManager entityManager;

private EntityManagerFactory emf;

//private EntityManager getEntityManager() throws NamingException{
// return entityManager;
public void addCar(String steering, String horn, String wheel) {
//EntityManager em;

//entityManager = getEntityManager();
EntityManager entityManager = emf.createEntityManager();
System.out.println("getEntityManager() =" + entityManager);
Car c = new Car(steering, horn, wheel);


In the renaissance, how big were the dinosaurs? Did you have tiny ads?
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic