1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[JBoss] Why java:comp/env jndi lookups work for transactionmanager, but not for a datasource?

Discussão em 'StackOverflow' iniciado por Stack, Agosto 27, 2025.

  1. Stack

    Stack Membro Participativo

    I use jboss 7.4. I tried:

    @Resources({
    @Resource(name = "VDB", type = DataSource.class, mappedName = "java:/jdbc/VDB"),
    @Resource(name = "TransactionManager", type = TransactionManager.class, mappedName = "java:/TransactionManager")
    })
    public class VManagerBean extends ... { // an ejb2 stateless session bean
    ...
    private TransactionManager getTransactionManager() {
    InitialContext ic;
    try {
    ic = new InitialContext();
    TransactionManager tm = (TransactionManager) ic.lookup("java:comp/env/TransactionManager");
    return tm;
    } catch (NamingException e) {
    throw new RuntimeException(e);
    }
    }
    private DataSource getDataSource() {
    InitialContext ic;
    try {
    ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("java:comp/env/VDB");
    return ds;
    } catch (NamingException e) {
    throw new RuntimeException(e);
    }
    }


    Now getTransaction() works fine, but getDataSource() not: even jboss stops running after getDataSource(). Why?

    Continue reading...

Compartilhe esta Página