-->
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: Problem configuring JBoss Cache as 2nd Level Cache
PostPosted: Thu Aug 20, 2009 11:46 am 
Newbie

Joined: Thu Aug 20, 2009 11:25 am
Posts: 6
My set up is as follows:

Glassfish Server 2.1
Hibernate Core: 3.3.2.GA
Hibernate Entity Manager: 3.4.0.GA
Hibernate JBoss Cache2: 3.3.2.GA
JBoss Cache Core: 3.1.0.GA

My persistence.xml is as follows:

Code:
<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="EntityManager" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/mydb</jta-data-source>

        <class>business.domain.MyClass</class>
        <properties>
            <property name="hibernate.dialect"
                      value="org.hibernate.dialect.OracleDialect"/>
            <property name="hibernate.connection.url"
                      value="jdbc:oracle:thin:@127.0.0.1:1521:XE"/>
            <property name="hibernate.connection.driver_class"
                      value="oracle.jdbc.driver.OracleDriver"/>
            <property name="hibernate.connection.username"
                      value="mydb"/>
            <property name="hibernate.connection.password"
                      value="mydb"/>
            <property name="hibernate.transaction.manager_lookup_class"
                      value="org.hibernate.transaction.SunONETransactionManager "/>
            <property name="hibernate.transaction.factory_class"
                      value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.current_session_context_class"
                      value="jta"/>
            <property name="hibernate.cache.use_second_level_cache"
                      value="true"/>
            <property name="hibernate.cache.use_query_cache"
                      value="true"/>
            <property name="hibernate.cache.region.jbc2.query.localonly"
                      value="true"/>
            <property name="hibernate.cache.region.factory_class"
                      value="org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory"/>
        </properties>
    </persistence-unit>
</persistence>


My DAO session bean is annotated with

Code:
@Stateless
@TransactionAttribute(TransactionAttributeType.MANDATORY)


My DAO session bean has the following code which I am trying to call:

Code:
    public T findByPrimaryKey(PK pk) throws DataAccessException {
        T entity = entityManager.find(this.type, pk);
       
        if (entity == null) {
            throw new DataAccessException(
                    "Could not find entity identified by primary key");
        }
        return entity;
    }


I get the following exception being raised in the JTATransactionFactory class.

Code:
    Caused by: javax.naming.NameNotFoundException: Lookup of java:comp/UserTransaction not allowed for Container managed Transaction beans
   at com.sun.ejb.containers.BaseContainer.checkUserTransactionLookup(BaseContainer.java:691)
   at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:190)
   at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:407)
   at javax.naming.InitialContext.lookup(InitialContext.java:392)
   at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:163)


As far as I can see I have configured everything as should be.

Is there anywhere glaringly obvious where I have went wrong?

Thanks

Chris


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.