[flexcoders] FDS: Using Hibernate second-level cache possible?

2006-12-06 Thread Niko Schmuck
Hi together,

As a newbie I would like to get your advices on how to use the Hibernate
caching for Flex Data Management Services. Is this possible at all or a
contra-diction to the HibernateAssembler?

For my java applications I currently use second-level caching to speed up
data access with Hibernate (3.2), which I would also like to use for my
Flex app:

For this I use in the Hibernate mapping definition (inside the class
element):

  cache usage=read-write/

Unfortunately if I turn EhCache on (via the hibernate configuration) ...

  property
name=cache.provider_classorg.hibernate.cache.EhCacheProvider/property

... the tomcat logs show an ugly stack-trace:

  CacheException: Attempt to restart an already started EhCacheProvider.

See below for the exception in its full-length beauty. The only way to
overcome this, to avoid caching at all by setting:

  property
name=cache.provider_classorg.hibernate.cache.NoCacheProvider/property

(Also using the recommended SingletonEhCacheProvider does not help)

Any help much appreciated.

Thanks,
Niko





2006-12-05 08:57:08,737 [main] ERROR
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/useradmin]
 - Servlet /useradmin threw load() exception
java.lang.ExceptionInInitializerError
at
flex.data.assemblers.HibernateManager.createSessionFactory(HibernateManager.java:66)
at
flex.data.assemblers.HibernateManager.init(HibernateManager.java:44)
at
flex.data.assemblers.HibernateAssembler.initialize(HibernateAssembler.java:137)
at
flex.messaging.factories.JavaFactory$JavaFactoryInstance.createInstance(JavaFactory.java:254)
at
flex.messaging.factories.JavaFactory.createFactoryInstance(JavaFactory.java:93)
at
flex.messaging.FactoryDestination.getFactoryInstance(FactoryDestination.java:76)
at flex.data.adapters.JavaAdapter.server(JavaAdapter.java:158) at
flex.data.adapters.JavaAdapter.setSettings(JavaAdapter.java:119)
at flex.messaging.Destination.createAdapter(Destination.java:279)
at
flex.messaging.Destination.initDestination(Destination.java:103)
at
flex.messaging.FactoryDestination.initDestination(FactoryDestination.java:58)
at flex.data.DataService.createDestination(DataService.java:90) at
flex.messaging.services.AbstractService.createDestinations(AbstractService.java:82)
at
flex.messaging.config.MessagingConfiguration.createServices(MessagingConfiguration.java:187)
at
flex.messaging.config.MessagingConfiguration.configureBroker(MessagingConfiguration.java:84)
at
flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:105)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: org.hibernate.cache.CacheException: Attempt to restart an
already started EhCacheProvider. Use sessionFactory.close()  between
repeated calls to buildSessionFactory. Consider using
net.sf.ehcache.hibernate.SingletonEhCacheProvider.
at

RE: [flexcoders] FDS: Using Hibernate second-level cache possible?

2006-12-06 Thread Jeff Vroom
I think the important part of the error is here:

 

... 41 more
Caused by: net.sf.ehcache.CacheException: Cannot parseConfiguration
CacheManager. Attempt to create a new instance of CacheManager using the
diskStorePath /tmp/cache which is already used by an existing
CacheManager. The source of the configuration was classpath.
at net.sf.ehcache.CacheManager.configure(CacheManager.java:248) at
net.sf.ehcache.CacheManager.init(CacheManager.java:193) at
net.sf.ehcache.CacheManager.init(CacheManager.java:180) at
org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:124)

 

It seems like there are two session factories being started up which are
configured to use the same cache.  This could be because you have two
web apps on the same machine each using hibernate.  I don't think that
flex would be trying to create two SessionFactories unless you were
using more than one hibernate configuration file.  Flex should share one
session factory from all destinations which use the same hibernate
configuration file.   There must be some way to set the path name of the
cache... maybe you just need to specify a different path name for this
cache for the FDMS version of hibernate?

 

Jeff

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Niko Schmuck
Sent: Wednesday, December 06, 2006 8:18 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] FDS: Using Hibernate second-level cache possible?

 

Hi together,

As a newbie I would like to get your advices on how to use the Hibernate
caching for Flex Data Management Services. Is this possible at all or a
contra-diction to the HibernateAssembler?

For my java applications I currently use second-level caching to speed
up
data access with Hibernate (3.2), which I would also like to use for my
Flex app:

For this I use in the Hibernate mapping definition (inside the class
element):

cache usage=read-write/

Unfortunately if I turn EhCache on (via the hibernate configuration) ...

property
name=cache.provider_classorg.hibernate.cache.EhCacheProvider/propert
y

... the tomcat logs show an ugly stack-trace:

CacheException: Attempt to restart an already started EhCacheProvider.

See below for the exception in its full-length beauty. The only way to
overcome this, to avoid caching at all by setting:

property
name=cache.provider_classorg.hibernate.cache.NoCacheProvider/propert
y

(Also using the recommended SingletonEhCacheProvider does not help)

Any help much appreciated.

Thanks,
Niko

2006-12-05 08:57:08,737 [main] ERROR
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/useradmi
n]
- Servlet /useradmin threw load() exception
java.lang.ExceptionInInitializerError
at
flex.data.assemblers.HibernateManager.createSessionFactory(HibernateMana
ger.java:66)
at
flex.data.assemblers.HibernateManager.init(HibernateManager.java:44)
at
flex.data.assemblers.HibernateAssembler.initialize(HibernateAssembler.ja
va:137)
at
flex.messaging.factories.JavaFactory$JavaFactoryInstance.createInstance(
JavaFactory.java:254)
at
flex.messaging.factories.JavaFactory.createFactoryInstance(JavaFactory.j
ava:93)
at
flex.messaging.FactoryDestination.getFactoryInstance(FactoryDestination.
java:76)
at flex.data.adapters.JavaAdapter.server(JavaAdapter.java:158) at
flex.data.adapters.JavaAdapter.setSettings(JavaAdapter.java:119)
at flex.messaging.Destination.createAdapter(Destination.java:279)
at
flex.messaging.Destination.initDestination(Destination.java:103)
at
flex.messaging.FactoryDestination.initDestination(FactoryDestination.jav
a:58)
at flex.data.DataService.createDestination(DataService.java:90) at
flex.messaging.services.AbstractService.createDestinations(AbstractServi
ce.java:82)
at
flex.messaging.config.MessagingConfiguration.createServices(MessagingCon
figuration.java:187)
at
flex.messaging.config.MessagingConfiguration.configureBroker(MessagingCo
nfiguration.java:84)
at
flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:105)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav
a:1105)
at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.j
ava:3951)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4225
)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja
va:759)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:
608)
at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java
:535)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:31
0