[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Persistence Manager Exception

galo.navarro do-not-reply at jboss.com
Mon Aug 21 12:20:10 EDT 2006


JBoss 4.0.4 GA, EJB3 RC8 

Testing EJB3, Stateless & Statefull examples work, my hypersonic database is configured and working, default datasource configured.


  | java: Namespace
  | 
  |   +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
  |   +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  | 

I'm trying to get an Entity EJB to write something to that datasource but I get the following error:

17:08:46,983 WARN  [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=entity.ejb3
java.lang.RuntimeException: Field private javax.persistence.EntityManager org.jboss.tutorial.entity.bean.ShoppingCartBean.manager @PersistenceUnit in error: EMPTY STRING unitName but there is no deployments in scope

This is my entity bean:

Order.java

@Entity
  | @Table(name = "PURCHASE_ORDER")
  | public class Order implements java.io.Serializable {
  |  
  | 	private static final long serialVersionUID = 1L;
  | 	private int id;
  |    private double total;
  |    private Collection<LineItem> lineItems;
  | 
  | 
  | 	public Order() {
  | 		super();
  | 	}
  | 	
  | 	@Id @GeneratedValue(strategy=GenerationType.AUTO)
  |    public int getId()
  |    {
  |       return id;
  |    }
  | 

I use it from a stateless bean that doesn't do much


  | package slsb;
  | 
  | import javax.ejb.Stateless;
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  | import entity.*;
  | 
  | import model.Item;
  | 
  | @Stateless
  | public class SimpleStatelessBean implements SimpleStatelessBeanRemote, SimpleStatelessBeanLocal {
  | 
  | 	@PersistenceContext()
  | 	private EntityManager em;
  | 	
  | 	public Item getItem(Long id) {
  | 		Order o = new Order();
  | 		o.setId(10);
  | 		o.setLineItems(null);
  | 		o.setTotal(100);
  | 		em.persist(o);		
  | 		Item item = new Item();
  | 		item.setId(id);
  | 		item.setName("A Java mug");
  | 		return item;
  | 	}
  | }
  | 

I thought it might be due to a missing persistence.xml file but the error is still the same, this is my persistence.xml, but anyway I didn't think you actually needed this (i've seen examples from the Jboss labs working without them, is it really needed?)

<persistence>
  |  <persistence-unit name="BeanExamples">
  |  <jta-data-source>java:/DefaultDS</jta-data-source>
  |  <properties>
  |  <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
  |  </properties>
  |  </persistence-unit>
  | </persistence>

Any suggestions? Thanks

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966481#3966481

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966481



More information about the jboss-user mailing list