-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Injecting Hibernate Session in EJB on JBOSS 5.1
PostPosted: Fri Oct 02, 2009 5:19 pm 
Newbie

Joined: Fri Oct 02, 2009 4:54 pm
Posts: 1
I have some Hibernate data access code that I want to use in a new Jboss EJB3 based app. I run a simple test following instructions that I can find, but it failed to deploy my bean. Appreciate any help!

When JBOSS started, I got
Code:
DEPLOYMENTS MISSING DEPENDENCIES:
  Deployment "jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3" is missing the following dependencies:
    Dependency "<UNKNOWN jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3>" (should be in state "Described",
but is actually in state "** UNRESOLVED Demands 'persistence.unit:unitName=wcc.ear/#wccDatabase' **")
  Deployment "jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3_endpoint" is missing the following dependenci
es:
    Dependency "jboss.j2ee:ear=wcc.ear,jar=wcc.jar,name=TestEJB,service=EJB3" (should be in state "Configured", but is a
ctually in state "PreInstall")
  Deployment "persistence.unit:unitName=wcc.ear/#wccDatabase" is missing the following dependencies:
    Dependency "jboss.jca:name=wccDatabase,service=DataSourceBinding" (should be in state "Create", but is actually in s
tate "** NOT FOUND Depends on 'jboss.jca:name=wccDatabase,service=DataSourceBinding' **")

If I comment out @PersistenceContext, EJB is deployed fine.

My persistence.xml is like this
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
   version="1.0">
   <persistence-unit name="wccDatabase">
      <jta-data-source>java:/wccDatabase</jta-data-source>
      <properties>
          <property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml"/>
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      </properties>
   </persistence-unit>
</persistence>


EJB sources like this,
Code:
@Local
public interface ITestEJB {
    public List<User> getUsers();
}

Code:
@Stateless
public class TestEJB implements ITestEJB, Serializable {
   private static final long serialVersionUID = -842292318926507620L;
   
   @PersistenceContext(unitName="wccDatabase")
   private Session session;
   
   @Override
   public List<User> getUsers() {
      Criteria criteria = session.createCriteria(User.class);
      return criteria.list();
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.