Hi all,
I'm having an strange error when trying to search an object using Spring's hibernateDaoSupport in JBoss 4.0.5 (the same code works fine on Jboss 4.2). I've searched on every forum I know and haven't found nothing... I hope somebody can help.
This is the exception I'm obtaining:
Code:
2007-07-27 13:22:16,640 ERROR [net.dolex.persistence.dao.reconciliation.impl.SettlementEntityDaoSpringHibernateImpl] java.lang.VerifyError: org/hibernate/engine/SessionFactoryImplementor.getTransactionManager()Ljavax/transaction/TransactionManager;
2007-07-27 13:22:16,641 ERROR [STDERR] java.lang.reflect.InvocationTargetException
2007-07-27 13:22:16,641 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2007-07-27 13:22:16,641 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
2007-07-27 13:22:16,641 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2007-07-27 13:22:16,641 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:615)
2007-07-27 13:22:16,641 ERROR [STDERR] at net.dolex.service.reconciliation.impl.ReconciliationCommandExecutorImpl.executeCommand(Unknown Source)
2007-07-27 13:22:16,641 ERROR [STDERR] at net.dolex.service.messaging.listeners.reconciliation.ReconciliationListener.onMessage(Unknown Source)
2007-07-27 13:22:16,641 ERROR [STDERR] at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:854)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:793)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:763)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.jms.listener.DefaultMessageListenerContainer.doReceiveAndExecute(DefaultMessageListenerContainer.java:513)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.jms.listener.DefaultMessageListenerContainer.receiveAndExecute(DefaultMessageListenerContainer.java:460)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:824)
2007-07-27 13:22:16,642 ERROR [STDERR] at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:203)
2007-07-27 13:22:16,642 ERROR [STDERR] at java.lang.Thread.run(Thread.java:803)
2007-07-27 13:22:16,642 ERROR [STDERR] Caused by:
2007-07-27 13:22:16,642 ERROR [STDERR] net.dolex.service.reconciliation.ReconciliationException: net.dolex.persistence.dao.reconciliation.PersistenceException: java.lang.VerifyError: org/hibernate/engine/SessionFactoryImplementor.getTransactionManager()Ljavax/transaction/TransactionManager;
2007-07-27 13:22:16,643 ERROR [STDERR] at net.dolex.service.reconciliation.impl.GeneralReconciliationProcessor.reconcile(Unknown Source)
2007-07-27 13:22:16,643 ERROR [STDERR] ... 15 more
2007-07-27 13:22:16,643 ERROR [STDERR] Caused by:
2007-07-27 13:22:16,643 ERROR [STDERR] net.dolex.persistence.dao.reconciliation.PersistenceException: java.lang.VerifyError: org/hibernate/engine/SessionFactoryImplementor.getTransactionManager()Ljavax/transaction/TransactionManager;
2007-07-27 13:22:16,644 ERROR [STDERR] at net.dolex.persistence.dao.reconciliation.impl.SettlementEntityDaoSpringHibernateImpl.findById(Unknown Source)
2007-07-27 13:22:16,644 ERROR [STDERR] ... 16 more
2007-07-27 13:22:16,644 ERROR [STDERR] Caused by:
2007-07-27 13:22:16,644 ERROR [STDERR] java.lang.VerifyError: org/hibernate/engine/SessionFactoryImplementor.getTransactionManager()Ljavax/transaction/TransactionManager;
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.SessionFactoryUtils.getJtaTransactionManager(SessionFactoryUtils.java:166)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.SessionFactoryUtils.registerJtaSynchronization(SessionFactoryUtils.java:460)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:361)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:243)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.getSession(HibernateTemplate.java:415)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:351)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:492)
2007-07-27 13:22:16,645 ERROR [STDERR] at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:486)
2007-07-27 13:22:16,645 ERROR [STDERR] ... 17 more
2007-07-27 13:22:16,645 ERROR [net.dolex.service.messaging.listeners.reconciliation.ReconciliationListener] net.dolex.service.reconciliation.ExecutionException: java.lang.reflect.InvocationTargetException
The code for searching the object is the following
Code:
public SettlementEntity findById(long id) throws PersistenceException, ObjectNotFoundException {
log.debug("searching entity with id "+id);
try {
SettlementEntity s = (SettlementEntity) getHibernateTemplate().load(SettlementEntity.class, new Long(id));
log.debug("object found: "+s);
return s;
} catch (DataAccessException e) {
log.error(e);
throw new PersistenceException(e);
} catch (org.hibernate.ObjectNotFoundException e)
{
log.debug("object not found");
throw new ObjectNotFoundException(e);
}catch(Exception e)
{
log.debug("Object not found");
throw new PersistenceException(e);
}catch(Throwable e)
{
log.error(e);
throw new PersistenceException(e);
}
}
The configuration hbm file for SettlementEntity is:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="net.dolex.persistence.model.reconciliation">
<class name="SettlementEntity" table="SETTLEMENT_ENTITY">
<id name="id" column="SETTLEMENT_ENTITY_ID">
<generator class="sequence">
<param name="sequence">SETTLEMENT_ENTITY_SEQ</param>
</generator>
</id>
<property name="name" column="NAME" />
<property name="description" column="DESCRIPTION" />
</class>
</hibernate-mapping>
The EntityStatement class is
Code:
public class EntityStatement implements Serializable
{
private static final long serialVersionUID = 1L;
private long id;
private SettlementEntity settlementEntity;
private Date settlementDate;
private Set<EntityStatementDetail> details;
public EntityStatement() {
super();
details = new HashSet<EntityStatementDetail>();
}
public EntityStatement(SettlementEntity settlementEntity, Date settlementDate) {
super();
details = new HashSet<EntityStatementDetail>();
this.settlementEntity = settlementEntity;
this.settlementDate = settlementDate;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id=id;
}
public Date getSettlementDate() {
return settlementDate;
}
public void setSettlementDate(Date settlementDate) {
this.settlementDate = settlementDate;
}
public SettlementEntity getSettlementEntity() {
return settlementEntity;
}
public void setSettlementEntity(SettlementEntity settlementEntity) {
this.settlementEntity = settlementEntity;
}
public Set<EntityStatementDetail> getDetails() {
return details;
}
public void setDetails(Set<EntityStatementDetail> details) {
this.details = details;
}
public void addDetail(EntityStatementDetail detail)
{
details.add(detail);
detail.setEntityStatement(this);
}
@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + (int) (id ^ (id >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final EntityStatement other = (EntityStatement) obj;
if (id != other.id)
return false;
return true;
}
@Override
public String toString()
{
return new ToStringBuilder(this)
.append("id",this.id)
.append("settlement date",this.settlementDate)
.append("settlement entry",this.settlementEntity)
.toString();
}
and at last, my sessioFactory configuration is the following
Code:
<bean id="oracleDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:/oracle-ds</value>
</property>
</bean>
<!-- Datasource for accesing Dolex database -->
<bean id="sybaseDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:/sybase-ds</value>
</property>
</bean>
<!-- Hibernate Session Factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="oracleDataSource" />
</property>
<property name="mappingResources">
<list>
<value>
net/dolex/persistence/model/reconciliation/EntityStatement.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/EntityStatementDetail.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/ExtraEntityStatementDetail.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/ExtraTransactionBatchDetail.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/SettlementEntity.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/TransactionBatch.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/TransactionBatchDetail.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/TransactionBatchFee.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/ReconciliationAuditLog.hbm.xml
</value>
<value>
net/dolex/persistence/model/reconciliation/BatchAuditLog.hbm.xml
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="hibernateInterceptor" class="net.dolex.service.util.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<aop:config>
<aop:pointcut id="loadBatchPC"
expression="execution(* net.dolex.service.reconciliation.impl.*.loadBatch())"/>
<aop:pointcut id="createStmtPC"
expression="execution(* net.dolex.service.reconciliation.impl.*.createStatement())"/>
<aop:pointcut id="reconciliationPC"
expression="execution(* net.dolex.service.reconciliation.impl.*.reconcile())"/>
<aop:aspect id="loadBatcHibernateInterceptorAspect" ref="hibernateInterceptor">
<aop:before pointcut-ref="loadBatchPC" method="openSession"/>
<aop:after pointcut-ref="loadBatchPC" method="closeSession"/>
</aop:aspect>
<aop:aspect id="createStmtHibernateInterceptorAspect" ref="hibernateInterceptor">
<aop:before pointcut-ref="createStmtPC" method="openSession"/>
<aop:after pointcut-ref="createStmtPC" method="closeSession"/>
</aop:aspect>
<aop:aspect id="reconciliationHibernateInterceptorAspect" ref="hibernateInterceptor">
<aop:before pointcut-ref="reconciliationPC" method="openSession"/>
<aop:after pointcut-ref="reconciliationPC" method="closeSession"/>
</aop:aspect>
</aop:config>
I've tested without the Hibernate interceptor and the result is the same.
Thanks