• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to register JNDI Name  RSS feed

Amandeep Singh
Ranch Hand
Posts: 853
  • 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.

CarCreatorBean.java(for 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);


CarEAOImpl.java(for 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);


Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!