H2 as JDBCrealm provider doesn't work?

40 views
Skip to first unread message

Crusoe

unread,
Apr 3, 2009, 3:12:48 AM4/3/09
to H2 Database
I can connect to the H2 Url in SQuirrel SQL just fine. Yet when using
it in a JDBCRealm, it doesn't work.

<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.h2.Driver"
debug="99"
connectionURL="jdbc:h2:file:/home/daniel/h2-db/
ms_Trailblaze;TRACE_LEVEL_FILE=4"

userTable="users"
userNameCol="user_name"
userCredCol="user_pass"
roleTable="user_roles"
roleNameCol="role_name"
connectionName="tomcat_realm_user"
connectionPassword="Z00mibl3s"
digest="SHA"/>

And the exceptions I get are:

Apr 2, 2009 11:05:58 PM org.apache.catalina.realm.JDBCRealm start
SEVERE: Exception opening database connection
java.sql.SQLException: org.h2.Driver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:
691)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:
769)
at org.apache.catalina.core.StandardContext.start
(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.addChildInternal
(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild
(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild
(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor
(HostConfig.java:627)
at org.apache.catalina.startup.HostConfig.deployApps
(HostConfig.java:511)
at org.apache.catalina.startup.HostConfig.check
(HostConfig.java:1231)
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:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke
(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke
(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke
(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check
(ManagerServlet.java:1471)
at org.apache.catalina.manager.ManagerServlet.deploy
(ManagerServlet.java:824)
at org.apache.catalina.manager.ManagerServlet.doGet
(ManagerServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)


Also, tracing doesn't seem to work well either. I am having a heck of
time of finding the logger name in the docs so my log4j.xml can pick
it up.

Thomas Mueller

unread,
Apr 3, 2009, 8:21:53 AM4/3/09
to h2-da...@googlegroups.com
Hi,

> SEVERE: Exception opening database connection
> java.sql.SQLException: org.h2.Driver
>        at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:
> 691)

This looks like an exception of the JDBCRealm, not from H2.

Where did you put the h2*.jar file? Maybe it's not in the classpath of
the server.

> I am having a heck of
> time of finding the logger name in the docs so my log4j.xml can pick
> it up.

Try not to use slf4j / log4j until it works (maybe one of those jar
files is not in the classpath?). Instead, using a database URL of the
form jdbc:h2:~/test;TRACE_LEVEL_FILE=3

Afterwards the .trace.db files (if you use the server mode, then there
are two such files: one for the client, and one for the server).

Regards,
Thomas

Crusoe

unread,
Apr 3, 2009, 1:18:48 PM4/3/09
to H2 Database
It is in the path. It is in my webapp, and I stuck in the
catalina_home/lib as well.

Here is the url, and yes the server has been started

jdbc:h2:tcp://localhost/~/h2-db/ms_Trailblaze;TRACE_LEVEL_FILE=3

Anyways, other drivers can seem to work in this system, what makes H2
unique?

On Apr 3, 5:21 am, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

Crusoe

unread,
Apr 3, 2009, 4:48:44 PM4/3/09
to H2 Database
Ok, it seems JDBCRealm is broken, at least when set in a webapp's
context.xml. I suspect a classloader issue.

If you use a DatasourceRealm, and define a JNDI datasource, then it
all works fine.

Thomas Mueller

unread,
Apr 4, 2009, 6:31:48 AM4/4/09
to h2-da...@googlegroups.com
Hi,

> Here is the url, and yes the server has been started
>
> jdbc:h2:tcp://localhost/~/h2-db/ms_Trailblaze;TRACE_LEVEL_FILE=3
>
> Anyways, other drivers can seem to work in this system, what makes H2
> unique?

I don't know, but I like to find out.

I made a mistake in my previous mail, the last sentence should be:

"Afterwards, ::could you post:: the .trace.db files (if you use the

Reply all
Reply to author
Forward
0 new messages