Hello, 

I am new to TomEE and am trying to implement a custom realm to handle
authentication. The custom realm class extends
org.apache.catalina.realm.RealmBase. 

In the past, using regular Tomcat I have configured it by including a
separate jar containing the custom realm in the lib folder and declaring the
custom realm class and its associated jdbc connection in the server.xml and
context.xml files as follows:

server.xml (within the <host> tag):

<Context docBase="C:\Tomcat\webapps\myapp" path="/myapp" reloadable="true">
  <Resource name="jdbc/appdatasource" auth="Container"
type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="xxxx" password="yyyy"
driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/myapp"/>
  <Realm className="org.foo.mycustomrealm"/>
</Context>

context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="\myapp" path="/myapp" reloadable="true">
  <Resource name="jdbc/appdatasource" auth="Container"
type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="xxxx" password="yyyy"
driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/myapp"/>
  <Realm className="org.foo.mycustomrealm"/>
</Context>

When I try the same configuration setup in TomEE (the only difference being
the docbase: C:\apache-tomee-plus-1.5.0\webapps\myapp) I get the following
error:

------
Jan 8, 2013 3:04:29 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException:
org.apache.openejb.loader.Files$FileRuntimeException: Cannot mkdirs:
C:\apache-tomee-plus-1.5.0\webapps\C:\apache-tomee-plus-1.5.0\webapps\gnomex.unpacked
        at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
        at java.util.concurrent.FutureTask.get(FutureTask.java:83)
        at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
        at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
        at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
------

This seems to result from having the <Context> entry in the server.xml file.
If I comment out <Context> and leave the <Resource> and <Realm> entries up a
level inside the <host> tag then TomEE starts up fine but it doesn't seem to
invoke the custom realm at all.

I found the info on using the LazyRealm class and wondered if that would
apply here but it doesn't seem to help. Can anyone help?

Thanks,
Robb Cundick




--
View this message in context: 
http://openejb.979440.n4.nabble.com/Custom-Realm-tp4660183.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Reply via email to