You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by rcundick <ro...@gmail.com> on 2013/01/08 23:27:06 UTC

Custom Realm

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.

Re: Custom Realm

Posted by Romain Manni-Bucau <rm...@gmail.com>.
would be great if you can test the snapshot tomorrow, i added some check in
the placeholder but basically it means you have a null value for an
attribute in your resources


really check on the snapshot if it still appears, if yes can you reproduce
it in a small project you could share?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/10 rcundick <ro...@gmail.com>

> Thanks for getting back to me. I downloaded 1.5.1 yesterday and now it
> doesn't finish deploying my war file. I get the error below and can't make
> head nor tails of what it means. The same war deployed fine in 1.5.0. If I
> compare the console output for the two versions, it's failing when it tries
> to deploy the ejb (named SBGNomExRequestProcessor). So something changed in
> 1.5.1 to cause a deployment problem.
>
> INFO: -------------------------
> TomcatWebAppBuilder.init /gnomex
> Jan 10, 2013 11:20:22 AM
> org.apache.catalina.startup.SetContextPropertiesRule begin
> WARNING: [SetContextPropertiesRule]{Context} Setting property 'debug' to
> '0'
> did not find a matching property.
> Jan 10, 2013 11:20:23 AM org.apache.openejb.config.ConfigurationFactory
> configureApplication
> INFO: Configuring enterprise application:
> C:\apache-tomee-plus\webapps\gnomex
> Jan 10, 2013 11:20:23 AM org.apache.openejb.config.InitEjbDeployments
> deploy
> INFO: Auto-deploying ejb SBGNomExRequestProcessor:
> EjbDeployment(deployment-id=SBGNomExRequestProcessor)
> Jan 10, 2013 11:20:23 AM org.apache.tomee.catalina.TomcatWebAppBuilder
> startInternal
> SEVERE: Unable to deploy collapsed ear in war
> StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]
> java.lang.NullPointerException
>         at java.util.Hashtable.put(Hashtable.java:394)
>         at
>
> org.apache.openejb.util.PropertyPlaceHolderHelper.holds(PropertyPlaceHolderHelper.java:57)
>         at
>
> org.apache.openejb.config.AutoConfig.processApplicationResources(AutoConfig.java:887)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
>         at
>
> org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:338)
>         at
>
> org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:827)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:974)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         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)
> Jan 10, 2013 11:20:23 AM org.apache.catalina.core.ContainerBase removeChild
> SEVERE: ContainerBase.removeChild: destroy:
> org.apache.catalina.LifecycleException: An invalid Lifecycle transition was
> attempted ([before_destroy]) for component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]]
> in state [STARTING_PREP]
>         at
>
> org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:409)
>         at
> org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:299)
>         at
> org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1167)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1148)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:986)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         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)
> Jan 10, 2013 11:20:23 AM org.apache.catalina.core.ContainerBase
> addChildInternal
> SEVERE: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException: Failed to start component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]]
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         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)
> Caused by: org.apache.tomee.catalina.TomEERuntimeException:
> java.lang.NullPointerException
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:989)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         ... 11 more
> Caused by: java.lang.NullPointerException
>         at java.util.Hashtable.put(Hashtable.java:394)
>         at
>
> org.apache.openejb.util.PropertyPlaceHolderHelper.holds(PropertyPlaceHolderHelper.java:57)
>         at
>
> org.apache.openejb.config.AutoConfig.processApplicationResources(AutoConfig.java:887)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
>         at
>
> org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:338)
>         at
>
> org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:827)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:974)
>         ... 17 more
> Jan 10, 2013 11:20:23 AM org.apache.catalina.startup.HostConfig deployWAR
> SEVERE: Error deploying web application archive
> C:\apache-tomee-plus\webapps\gnomex.war
> java.lang.IllegalStateException: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException: Failed to start component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]]
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         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)
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Custom-Realm-tp4660183p4660227.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: Custom Realm

Posted by rcundick <ro...@gmail.com>.
Thanks for getting back to me. I downloaded 1.5.1 yesterday and now it
doesn't finish deploying my war file. I get the error below and can't make
head nor tails of what it means. The same war deployed fine in 1.5.0. If I
compare the console output for the two versions, it's failing when it tries
to deploy the ejb (named SBGNomExRequestProcessor). So something changed in
1.5.1 to cause a deployment problem.

INFO: -------------------------
TomcatWebAppBuilder.init /gnomex
Jan 10, 2013 11:20:22 AM
org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'debug' to '0'
did not find a matching property.
Jan 10, 2013 11:20:23 AM org.apache.openejb.config.ConfigurationFactory
configureApplication
INFO: Configuring enterprise application:
C:\apache-tomee-plus\webapps\gnomex
Jan 10, 2013 11:20:23 AM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb SBGNomExRequestProcessor:
EjbDeployment(deployment-id=SBGNomExRequestProcessor)
Jan 10, 2013 11:20:23 AM org.apache.tomee.catalina.TomcatWebAppBuilder
startInternal
SEVERE: Unable to deploy collapsed ear in war
StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]
java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:394)
	at
org.apache.openejb.util.PropertyPlaceHolderHelper.holds(PropertyPlaceHolderHelper.java:57)
	at
org.apache.openejb.config.AutoConfig.processApplicationResources(AutoConfig.java:887)
	at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
	at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:338)
	at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:827)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:974)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
	at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
	at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	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)
Jan 10, 2013 11:20:23 AM org.apache.catalina.core.ContainerBase removeChild
SEVERE: ContainerBase.removeChild: destroy: 
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was
attempted ([before_destroy]) for component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]]
in state [STARTING_PREP]
	at
org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:409)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:299)
	at
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1167)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1148)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:986)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
	at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
	at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	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)
Jan 10, 2013 11:20:23 AM org.apache.catalina.core.ContainerBase
addChildInternal
SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
	at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
	at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	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)
Caused by: org.apache.tomee.catalina.TomEERuntimeException:
java.lang.NullPointerException
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:989)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
	at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 11 more
Caused by: java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:394)
	at
org.apache.openejb.util.PropertyPlaceHolderHelper.holds(PropertyPlaceHolderHelper.java:57)
	at
org.apache.openejb.config.AutoConfig.processApplicationResources(AutoConfig.java:887)
	at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
	at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:338)
	at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:827)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:974)
	... 17 more
Jan 10, 2013 11:20:23 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive
C:\apache-tomee-plus\webapps\gnomex.war
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/gnomex]]
	at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
	at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	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)




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

Re: Custom Realm

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

you have several issues

first about yours you should give it a try on the 1.5.1 or the snapshot

then about lazyrealm you should be able to use it, what's the issue here?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/8 rcundick <ro...@gmail.com>

> 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.
>