This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
however, I'm using another setup from hibernate for my application:
This is also necessary in web.xml for the line in hibernate.cfg.xml:
I think I'm using two separate datasources, aren't I?Is that bad? Because I can't tell wether I'm using one PooledDataSource or two at the moment... Everything looks fine, except I think I will run into connection problems or the datasource registered in JNDI because it's not properly set with c3p0... also need to confirm this is a proper setup for this scenario.
What I want, is to register the hibernate datasource in JNDI to use it with Shiro, in common with the rest of my application. How do I do that? Is there any chance the configuration I'm using treats both datasources with the same c3p0 configuration, or maybe it sees the two datasources as one? Hopeful thinking...
Logs indicate there's two separate data sourcepools registering:
One at start, immediately after "INFO: Initializing Shiro environment", probably the tomcat configured one:
and the other later(s!?) when application calls on it, probably the hibernate one:
but afterwards there's a lot of pools initializing:
This is from the datasource configured in tomcat
this seems related to the initial settings of c3p0 in hibernate.cfg.xml
then on a short distance this appears:
... probably a separate thread and connection/settings for caching statements? hmm...
then another initialization
and afterwards, when there's idle checks, only one triggers according to settings:
meaning the other one will run into problems after the 8 hours set by mysql wait_timeout of 28800 seconds (in fact that's exactly what happened if I think about it, because authorization/authentication failed ...can't tell if the application crapped out too because everything was behind Shiro, anyway, enabling c3p0 for the hibernate connection will not enable it for Shiro datasource too...)
EDIT2: EDIT doesn't work, there's some bug going on that was patched supposedly but can't get it to work.
Anyway, that's for a JDBC pooled datasource. For a com.mchange.v2.c3p0.ComboPooledDataSource there's
still, it would be nice if I could register the hibernate datasource in JNDI...
Joined: Nov 29, 2009
There's hibernate.jndi property to be set but I haven't the time to get into that now... dunno if that's the answer.
For some reason the other people that asked the same question didn't make use of this option.