[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: TransactionException: could not register synchronization

holmes.j do-not-reply at jboss.com
Mon Sep 18 18:40:12 EDT 2006


In the hope that somebody can help ...

I have a EJB 2.1 Stateless Session Bean with this header ...
/**
  |  * @ejb.bean name="GeoFeatureServer"
  |  *           jndi-name="com.free2be.framework.gis.feature.GeoFeatureServerHome"
  |  *           type="Stateless" view-type="remote"
  |  * @ejb.transaction type="Required"
  |  */
, that does this ...
	/**
  | 	 * @ejb.interface-method
  | 	 */
  | 	public GeoFeature findGeoFeature(GeoFeaturePk geoFeaturePk) throws NoSuchElementException {
  | 		GeoFeature value = (GeoFeature) cache.getByKey(geoFeaturePk);
  | 		if (value == null) {
  | 			getLogger().debug(geoFeaturePk + " not cached...loading");
  | 			GeoFeature featureValue = getGeoFeatureDao().findById(geoFeaturePk, false);
  | 			value = new GeoFeature(featureValue);
  | 			cache.addToCache(value);
  | 		}
  | 		return value;
  | 	}

and my Dao looks like this ...

  | 	@SuppressWarnings("unchecked")
  | 	public V findById(long id, boolean lock) {
  | 		V entity;
  | 		try {
  | 			Session session = getSession();
  | //			Transaction tx = session.beginTransaction();
  | 			if (lock)
  | 				entity = (V) session.load(getPersistentClass(), id, LockMode.UPGRADE);
  | 			else
  | 				entity = (V) session.load(getPersistentClass(), id);
  | 		} catch (HibernateException e) {
  | 			throw new NoSuchElementException(e.getMessage());
  | 		}
  | 		
  | 		return entity;
  | 	}
  | 

If I take out the session.beginTransaction, I get the "load is not valid without active transaction."  If I leave it in, it works like it should.

Any ideas as to what/how I'm supposed to configure to get the Application Server to do what it's supposed to do?

-Jason

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972447#3972447

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972447



More information about the jboss-user mailing list