JBoss Community

mixing EJB2.1 with EJB3, datasource is down

created by Kobi Ianko in EJB3 - View the full discussion

Hi All,

I've got an EJB2.1 project on JBOSS AS 5.1.

I'd like to add new ejb3 (session and entity bean) to the project.

 

I've created a simple session bean that persist a new entity (row) to the DB, and packed it in a JAR file (with persistence.xml in meta-inf directory).

this works fne.

 

now, I want it to be a part of my EJB2.1 project so I've done:

1. packed the new jar in the project ear file

2. updated the aplication.xml with the new ejb-module

 

when I run the server, I can access the session bean from the client but the entity manager is NULL,

and when I run in the browser "http://localhost:8080/admin-console" I can see the my datasource is marked as "DOWN"

 

 

my persistence.xml:

 

<?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="BoardDB">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <jta-data-source>java:/Kobi2DS</jta-data-source>
  <properties>
     <property name="hibernate.hbm2ddl.auto"
              value="update"/> <!-- create-drop/update -->
    <property name="hibernate.dialect"
              value="org.hibernate.dialect.SybaseDialect"/> 
  </properties>
  </persistence-unit> 
</persistence>

 

my session bean:

 

@Stateless
public class BoardManagerBean implements BoardManagerRemote {

 

   @PersistenceContext(unitName = "BoardDB")
    EntityManager entityManager;
   
   
    @Override
    public Board getBoardByID(int boardID) {
        return entityManager.find(Board.class, boardID);
       
       
    }

 


    @Override
    public void echo(String str) {
        LogUtils.info(this.getClass(), str);
        Board board = new Board();
        board.setId(1);
        board.setName("koko");
        board.setSubject("sdcasasc");
        entityManager.persist(board);
       
    }

Reply to this message by going to Community

Start a new discussion in EJB3 at Community