You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Violeta Georgieva <vi...@apache.org> on 2015/12/01 20:31:28 UTC

Resource and UseAppClassLoader question

Hello,

I'm testing with TomEE 1.7.3
I'm describing the resource using the following system properties:

mypostgres=new://Resource?type=DataSource
mypostgres.JdbcDriver=org.postgresql.Driver
mypostgres.JdbcUrl=url
mypostgres.UserName=user
mypostgres.Password=password
mypostgres.JtaManaged=true
mypostgres.Lazy=true
mypostgres.UseAppClassLoader=true
mypostgres.InitializeAfterDeployment=false

I supply the driver with my web application (WEB-INF/lib).

Regardless that I specify that I want initialization of the resource to
happen on the first lookup with the application class loader, my application
fails with the exceptions below.

When I debugged I saw that 
The first time - OpenEJBNamingContextListener.bindResource - case 1) below
the loader is StandardClassLoader and UseAppClassLoader=true.
At this point, UseAppClassLoader property is removed. The lookup is not
working because of the loader.
org.apache.openejb.assembler.classic.Assembler.newLazyResource(ResourceInfo)
row 2536

The second time - PersistenceBuilder.createEntityManagerFactory - case 2)
below
the loader is the webapp classloader but UseAppClassLoader=false because it
was removed on the previous step and the lookup is not working anymore.

>From my point of view the property should not be removed in order to enable
this scenario.


Thanks,
Violeta


1)
SEVERE: Unable to lookup Global Tomcat resource mypostgres
javax.naming.NamingException: Unable to resolve class org.postgresql.Driver
	at
org.apache.openejb.core.ivm.naming.LazyObjectReference.getObject(LazyObjectReference.java:39)
	at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:175)
	at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:123)
	at
org.apache.tomee.common.AbstractObjectFactory.lookup(AbstractObjectFactory.java:102)
	at
org.apache.tomee.common.AbstractObjectFactory.getObjectInstance(AbstractObjectFactory.java:51)
	at
org.apache.tomee.common.ResourceFactory.getObjectInstance(ResourceFactory.java:49)
	at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:141)
	at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
	at
org.apache.tomee.catalina.OpenEJBNamingContextListener.bindResource(OpenEJBNamingContextListener.java:266)
	at
org.apache.tomee.catalina.OpenEJBNamingContextListener.addResource(OpenEJBNamingContextListener.java:256)
	at
org.apache.tomee.catalina.OpenEJBNamingContextListener.processInitialNamingResources(OpenEJBNamingContextListener.java:223)
	at
org.apache.tomee.catalina.OpenEJBNamingContextListener.start(OpenEJBNamingContextListener.java:92)
	at
org.apache.tomee.catalina.OpenEJBNamingContextListener.lifecycleEvent(OpenEJBNamingContextListener.java:74)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
	at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:347)
	at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)

2)
org.apache.openejb.OpenEJBException: Could not lookup <jta-data-source>
'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
resolve class org.postgresql.Driver: Could not lookup <jta-data-source>
'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
resolve class org.postgresql.Driver
	at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:843)
	at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
	at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
	at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
	at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5419)
	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:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
	at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1930)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.openejb.OpenEJBException:
org.apache.openejb.OpenEJBException: Could not lookup <jta-data-source>
'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
resolve class org.postgresql.Driver: Could not lookup <jta-data-source>
'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
resolve class org.postgresql.Driver
	at
org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:988)
	at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:741)
	... 18 more
Caused by: org.apache.openejb.OpenEJBException: Could not lookup
<jta-data-source> 'openejb/Resource/mypostgres' for unit
'persistence-with-ejb': Unable to resolve class org.postgresql.Driver
	at
org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:93)
	at
org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:982)
	... 19 more
Caused by: javax.naming.NamingException: Unable to resolve class
org.postgresql.Driver
	at
org.apache.openejb.core.ivm.naming.LazyObjectReference.getObject(LazyObjectReference.java:39)
	at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:175)
	at
org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:87)
	... 20 more




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

Posted by Violeta Georgieva <vi...@apache.org>.
It's working.

Thanks,
Violeta


Romain Manni-Bucau wrote
> yes, have to admit I don't recall out of my mind but if not we need to fix
> it.
> 
> 
> Romain Manni-Bucau
> @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
> &lt;http://rmannibucau.wordpress.com&gt; | Github
> &lt;https://github.com/rmannibucau&gt; |
> LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
> &lt;http://www.tomitribe.com&gt;
> 
> 2015-12-01 23:01 GMT+01:00 Violeta Georgieva &lt;

> violetagg@

> &gt;:
> 
>> You gave me an idea:
>> Can I declare 
> <Resource id="..." properties-provider="MyPropertiesProvider"
>>
>  /> in resources.xml and still supply configuration with the properties
>> provider?
>>
>>
>> Romain Manni-Bucau wrote
>> > Ok, did you try using placeholders in resources.xml (${my.driver} and
>> > my.driver=... in conf/system.properties)? This sounds the easiest.
>> >
>> >
>> > Romain Manni-Bucau
>> > @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
>> > &lt;http://rmannibucau.wordpress.com&gt; | Github
>> > &lt;https://github.com/rmannibucau&gt; |
>> > LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
>> > &lt;http://www.tomitribe.com&gt;
>> >
>> > 2015-12-01 22:36 GMT+01:00 Violeta Georgieva &lt;
>>
>> > violetagg@
>>
>> > &gt;:
>> >
>> >> Mhm that's what I'm trying to achieve in order to supply the
>> >> configuration
>> >> automatically for TomEE Buildpack.
>> >> https://github.com/cloudfoundry-community/tomee-buildpack/issues/5
>> >>
>> >>
>> >> Romain Manni-Bucau wrote
>> >> > To be honest I wouldnt use this but resources.xml cause this bind a
>> >> global
>> >> > resource to an application which is never very sane - but can be
>> needed
>> >> in
>> >> > some clouds. properties-provider should allows you to extract the
>> >> config
>> >> > if
>> >> > it is the goal.
>> >> >
>> >> >
>> >> > Romain Manni-Bucau
>> >> > @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
>> >> > &lt;http://rmannibucau.wordpress.com&gt; | Github
>> >> > &lt;https://github.com/rmannibucau&gt; |
>> >> > LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; |
>> Tomitriber
>> >> > &lt;http://www.tomitribe.com&gt;
>> >> >
>> >> > 2015-12-01 22:18 GMT+01:00 Violeta Georgieva &lt;
>> >>
>> >> > violetagg@
>> >>
>> >> > &gt;:
>> >> >
>> >> >> One additional question: Is there a better way to achieve this? -
>> >> >> Resource
>> >> >> specifies via system properties and a driver provided by the web
>> app
>> >> >> binaries.
>> >> >>
>> >> >>
>> >> >> Violeta Georgieva wrote
>> >> >> > Hi,
>> >> >> >
>> >> >> > So what is your proposal?
>> >> >> > Romain Manni-Bucau wrote
>> >> >> >> - I skipped on master (7.x) lazy resource merge in tomcat jndi
>> tree
>> >> to
>> >> >> >> avoid the first exception to be seen and tomcat to try to
>> process
>> >> them
>> >> >> at
>> >> >> >> startup. This then makes the remove() working as expected - the
>> >> remove
>> >> >> is
>> >> >> >> intended to avoid to consider this virtual property as a real
>> one
>> >> in
>> >> >> the
>> >> >> >> "object factory".
>> >> >> > In 1.7.3 this resource merge in tomcat jndi is not skipped and
>> the
>> >> >> > property is removed.
>> >> >> > How I can overcome this?
>> >> >> >
>> >> >> > Thanks,
>> >> >> > Violeta
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
>> >> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677080.html
>> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>> >>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677083.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677087.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes, have to admit I don't recall out of my mind but if not we need to fix
it.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-01 23:01 GMT+01:00 Violeta Georgieva <vi...@apache.org>:

> You gave me an idea:
> Can I declare <Resource id="..." properties-provider="MyPropertiesProvider"
> /> in resources.xml and still supply configuration with the properties
> provider?
>
>
> Romain Manni-Bucau wrote
> > Ok, did you try using placeholders in resources.xml (${my.driver} and
> > my.driver=... in conf/system.properties)? This sounds the easiest.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
> > &lt;http://rmannibucau.wordpress.com&gt; | Github
> > &lt;https://github.com/rmannibucau&gt; |
> > LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
> > &lt;http://www.tomitribe.com&gt;
> >
> > 2015-12-01 22:36 GMT+01:00 Violeta Georgieva &lt;
>
> > violetagg@
>
> > &gt;:
> >
> >> Mhm that's what I'm trying to achieve in order to supply the
> >> configuration
> >> automatically for TomEE Buildpack.
> >> https://github.com/cloudfoundry-community/tomee-buildpack/issues/5
> >>
> >>
> >> Romain Manni-Bucau wrote
> >> > To be honest I wouldnt use this but resources.xml cause this bind a
> >> global
> >> > resource to an application which is never very sane - but can be
> needed
> >> in
> >> > some clouds. properties-provider should allows you to extract the
> >> config
> >> > if
> >> > it is the goal.
> >> >
> >> >
> >> > Romain Manni-Bucau
> >> > @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
> >> > &lt;http://rmannibucau.wordpress.com&gt; | Github
> >> > &lt;https://github.com/rmannibucau&gt; |
> >> > LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
> >> > &lt;http://www.tomitribe.com&gt;
> >> >
> >> > 2015-12-01 22:18 GMT+01:00 Violeta Georgieva &lt;
> >>
> >> > violetagg@
> >>
> >> > &gt;:
> >> >
> >> >> One additional question: Is there a better way to achieve this? -
> >> >> Resource
> >> >> specifies via system properties and a driver provided by the web app
> >> >> binaries.
> >> >>
> >> >>
> >> >> Violeta Georgieva wrote
> >> >> > Hi,
> >> >> >
> >> >> > So what is your proposal?
> >> >> > Romain Manni-Bucau wrote
> >> >> >> - I skipped on master (7.x) lazy resource merge in tomcat jndi
> tree
> >> to
> >> >> >> avoid the first exception to be seen and tomcat to try to process
> >> them
> >> >> at
> >> >> >> startup. This then makes the remove() working as expected - the
> >> remove
> >> >> is
> >> >> >> intended to avoid to consider this virtual property as a real one
> >> in
> >> >> the
> >> >> >> "object factory".
> >> >> > In 1.7.3 this resource merge in tomcat jndi is not skipped and the
> >> >> > property is removed.
> >> >> > How I can overcome this?
> >> >> >
> >> >> > Thanks,
> >> >> > Violeta
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
> >> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >> >>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677080.html
> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >>
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677083.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Resource and UseAppClassLoader question

Posted by Violeta Georgieva <vi...@apache.org>.
You gave me an idea:
Can I declare <Resource id="..." properties-provider="MyPropertiesProvider"
/> in resources.xml and still supply configuration with the properties
provider?


Romain Manni-Bucau wrote
> Ok, did you try using placeholders in resources.xml (${my.driver} and
> my.driver=... in conf/system.properties)? This sounds the easiest.
> 
> 
> Romain Manni-Bucau
> @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
> &lt;http://rmannibucau.wordpress.com&gt; | Github
> &lt;https://github.com/rmannibucau&gt; |
> LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
> &lt;http://www.tomitribe.com&gt;
> 
> 2015-12-01 22:36 GMT+01:00 Violeta Georgieva &lt;

> violetagg@

> &gt;:
> 
>> Mhm that's what I'm trying to achieve in order to supply the
>> configuration
>> automatically for TomEE Buildpack.
>> https://github.com/cloudfoundry-community/tomee-buildpack/issues/5
>>
>>
>> Romain Manni-Bucau wrote
>> > To be honest I wouldnt use this but resources.xml cause this bind a
>> global
>> > resource to an application which is never very sane - but can be needed
>> in
>> > some clouds. properties-provider should allows you to extract the
>> config
>> > if
>> > it is the goal.
>> >
>> >
>> > Romain Manni-Bucau
>> > @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
>> > &lt;http://rmannibucau.wordpress.com&gt; | Github
>> > &lt;https://github.com/rmannibucau&gt; |
>> > LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
>> > &lt;http://www.tomitribe.com&gt;
>> >
>> > 2015-12-01 22:18 GMT+01:00 Violeta Georgieva &lt;
>>
>> > violetagg@
>>
>> > &gt;:
>> >
>> >> One additional question: Is there a better way to achieve this? -
>> >> Resource
>> >> specifies via system properties and a driver provided by the web app
>> >> binaries.
>> >>
>> >>
>> >> Violeta Georgieva wrote
>> >> > Hi,
>> >> >
>> >> > So what is your proposal?
>> >> > Romain Manni-Bucau wrote
>> >> >> - I skipped on master (7.x) lazy resource merge in tomcat jndi tree
>> to
>> >> >> avoid the first exception to be seen and tomcat to try to process
>> them
>> >> at
>> >> >> startup. This then makes the remove() working as expected - the
>> remove
>> >> is
>> >> >> intended to avoid to consider this virtual property as a real one
>> in
>> >> the
>> >> >> "object factory".
>> >> > In 1.7.3 this resource merge in tomcat jndi is not skipped and the
>> >> > property is removed.
>> >> > How I can overcome this?
>> >> >
>> >> > Thanks,
>> >> > Violeta
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
>> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>> >>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677080.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677083.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ok, did you try using placeholders in resources.xml (${my.driver} and
my.driver=... in conf/system.properties)? This sounds the easiest.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-01 22:36 GMT+01:00 Violeta Georgieva <vi...@apache.org>:

> Mhm that's what I'm trying to achieve in order to supply the configuration
> automatically for TomEE Buildpack.
> https://github.com/cloudfoundry-community/tomee-buildpack/issues/5
>
>
> Romain Manni-Bucau wrote
> > To be honest I wouldnt use this but resources.xml cause this bind a
> global
> > resource to an application which is never very sane - but can be needed
> in
> > some clouds. properties-provider should allows you to extract the config
> > if
> > it is the goal.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
> > &lt;http://rmannibucau.wordpress.com&gt; | Github
> > &lt;https://github.com/rmannibucau&gt; |
> > LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
> > &lt;http://www.tomitribe.com&gt;
> >
> > 2015-12-01 22:18 GMT+01:00 Violeta Georgieva &lt;
>
> > violetagg@
>
> > &gt;:
> >
> >> One additional question: Is there a better way to achieve this? -
> >> Resource
> >> specifies via system properties and a driver provided by the web app
> >> binaries.
> >>
> >>
> >> Violeta Georgieva wrote
> >> > Hi,
> >> >
> >> > So what is your proposal?
> >> > Romain Manni-Bucau wrote
> >> >> - I skipped on master (7.x) lazy resource merge in tomcat jndi tree
> to
> >> >> avoid the first exception to be seen and tomcat to try to process
> them
> >> at
> >> >> startup. This then makes the remove() working as expected - the
> remove
> >> is
> >> >> intended to avoid to consider this virtual property as a real one in
> >> the
> >> >> "object factory".
> >> > In 1.7.3 this resource merge in tomcat jndi is not skipped and the
> >> > property is removed.
> >> > How I can overcome this?
> >> >
> >> > Thanks,
> >> > Violeta
> >>
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >>
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677080.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Resource and UseAppClassLoader question

Posted by Violeta Georgieva <vi...@apache.org>.
Mhm that's what I'm trying to achieve in order to supply the configuration
automatically for TomEE Buildpack.
https://github.com/cloudfoundry-community/tomee-buildpack/issues/5


Romain Manni-Bucau wrote
> To be honest I wouldnt use this but resources.xml cause this bind a global
> resource to an application which is never very sane - but can be needed in
> some clouds. properties-provider should allows you to extract the config
> if
> it is the goal.
> 
> 
> Romain Manni-Bucau
> @rmannibucau &lt;https://twitter.com/rmannibucau&gt; |  Blog
> &lt;http://rmannibucau.wordpress.com&gt; | Github
> &lt;https://github.com/rmannibucau&gt; |
> LinkedIn &lt;https://www.linkedin.com/in/rmannibucau&gt; | Tomitriber
> &lt;http://www.tomitribe.com&gt;
> 
> 2015-12-01 22:18 GMT+01:00 Violeta Georgieva &lt;

> violetagg@

> &gt;:
> 
>> One additional question: Is there a better way to achieve this? -
>> Resource
>> specifies via system properties and a driver provided by the web app
>> binaries.
>>
>>
>> Violeta Georgieva wrote
>> > Hi,
>> >
>> > So what is your proposal?
>> > Romain Manni-Bucau wrote
>> >> - I skipped on master (7.x) lazy resource merge in tomcat jndi tree to
>> >> avoid the first exception to be seen and tomcat to try to process them
>> at
>> >> startup. This then makes the remove() working as expected - the remove
>> is
>> >> intended to avoid to consider this virtual property as a real one in
>> the
>> >> "object factory".
>> > In 1.7.3 this resource merge in tomcat jndi is not skipped and the
>> > property is removed.
>> > How I can overcome this?
>> >
>> > Thanks,
>> > Violeta
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677080.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

Posted by Romain Manni-Bucau <rm...@gmail.com>.
To be honest I wouldnt use this but resources.xml cause this bind a global
resource to an application which is never very sane - but can be needed in
some clouds. properties-provider should allows you to extract the config if
it is the goal.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-01 22:18 GMT+01:00 Violeta Georgieva <vi...@apache.org>:

> One additional question: Is there a better way to achieve this? - Resource
> specifies via system properties and a driver provided by the web app
> binaries.
>
>
> Violeta Georgieva wrote
> > Hi,
> >
> > So what is your proposal?
> > Romain Manni-Bucau wrote
> >> - I skipped on master (7.x) lazy resource merge in tomcat jndi tree to
> >> avoid the first exception to be seen and tomcat to try to process them
> at
> >> startup. This then makes the remove() working as expected - the remove
> is
> >> intended to avoid to consider this virtual property as a real one in the
> >> "object factory".
> > In 1.7.3 this resource merge in tomcat jndi is not skipped and the
> > property is removed.
> > How I can overcome this?
> >
> > Thanks,
> > Violeta
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Resource and UseAppClassLoader question

Posted by Violeta Georgieva <vi...@apache.org>.
One additional question: Is there a better way to achieve this? - Resource
specifies via system properties and a driver provided by the web app
binaries.


Violeta Georgieva wrote
> Hi,
> 
> So what is your proposal?
> Romain Manni-Bucau wrote
>> - I skipped on master (7.x) lazy resource merge in tomcat jndi tree to
>> avoid the first exception to be seen and tomcat to try to process them at
>> startup. This then makes the remove() working as expected - the remove is
>> intended to avoid to consider this virtual property as a real one in the
>> "object factory".
> In 1.7.3 this resource merge in tomcat jndi is not skipped and the
> property is removed.
> How I can overcome this?
> 
> Thanks,
> Violeta





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677078.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

Posted by Violeta Georgieva <vi...@apache.org>.
Hi,

So what is your proposal?

Romain Manni-Bucau wrote
> - I skipped on master (7.x) lazy resource merge in tomcat jndi tree to
> avoid the first exception to be seen and tomcat to try to process them at
> startup. This then makes the remove() working as expected - the remove is
> intended to avoid to consider this virtual property as a real one in the
> "object factory".

In 1.7.3 this resource merge in tomcat jndi is not skipped and the property
is removed.
How I can overcome this?

Thanks,
Violeta



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677077.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

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

this property doesnt makes the scope of the resource prototype so we should
still have a single instance. That said the JPA usage is a bit harder:

- you need to explicitely define the jta AND non jta datasource (otherwise
we create the nonJta on the fly and it fails cause it is not lazy)
- I skipped on master (7.x) lazy resource merge in tomcat jndi tree to
avoid the first exception to be seen and tomcat to try to process them at
startup. This then makes the remove() working as expected - the remove is
intended to avoid to consider this virtual property as a real one in the
"object factory".





Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-01 20:31 GMT+01:00 Violeta Georgieva <vi...@apache.org>:

> Hello,
>
> I'm testing with TomEE 1.7.3
> I'm describing the resource using the following system properties:
>
> mypostgres=new://Resource?type=DataSource
> mypostgres.JdbcDriver=org.postgresql.Driver
> mypostgres.JdbcUrl=url
> mypostgres.UserName=user
> mypostgres.Password=password
> mypostgres.JtaManaged=true
> mypostgres.Lazy=true
> mypostgres.UseAppClassLoader=true
> mypostgres.InitializeAfterDeployment=false
>
> I supply the driver with my web application (WEB-INF/lib).
>
> Regardless that I specify that I want initialization of the resource to
> happen on the first lookup with the application class loader, my
> application
> fails with the exceptions below.
>
> When I debugged I saw that
> The first time - OpenEJBNamingContextListener.bindResource - case 1) below
> the loader is StandardClassLoader and UseAppClassLoader=true.
> At this point, UseAppClassLoader property is removed. The lookup is not
> working because of the loader.
>
> org.apache.openejb.assembler.classic.Assembler.newLazyResource(ResourceInfo)
> row 2536
>
> The second time - PersistenceBuilder.createEntityManagerFactory - case 2)
> below
> the loader is the webapp classloader but UseAppClassLoader=false because it
> was removed on the previous step and the lookup is not working anymore.
>
> From my point of view the property should not be removed in order to enable
> this scenario.
>
>
> Thanks,
> Violeta
>
>
> 1)
> SEVERE: Unable to lookup Global Tomcat resource mypostgres
> javax.naming.NamingException: Unable to resolve class org.postgresql.Driver
>         at
>
> org.apache.openejb.core.ivm.naming.LazyObjectReference.getObject(LazyObjectReference.java:39)
>         at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:175)
>         at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:123)
>         at
>
> org.apache.tomee.common.AbstractObjectFactory.lookup(AbstractObjectFactory.java:102)
>         at
>
> org.apache.tomee.common.AbstractObjectFactory.getObjectInstance(AbstractObjectFactory.java:51)
>         at
>
> org.apache.tomee.common.ResourceFactory.getObjectInstance(ResourceFactory.java:49)
>         at
>
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:141)
>         at
> javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
>         at
>
> org.apache.tomee.catalina.OpenEJBNamingContextListener.bindResource(OpenEJBNamingContextListener.java:266)
>         at
>
> org.apache.tomee.catalina.OpenEJBNamingContextListener.addResource(OpenEJBNamingContextListener.java:256)
>         at
>
> org.apache.tomee.catalina.OpenEJBNamingContextListener.processInitialNamingResources(OpenEJBNamingContextListener.java:223)
>         at
>
> org.apache.tomee.catalina.OpenEJBNamingContextListener.start(OpenEJBNamingContextListener.java:92)
>         at
>
> org.apache.tomee.catalina.OpenEJBNamingContextListener.lifecycleEvent(OpenEJBNamingContextListener.java:74)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
>         at
> org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:347)
>         at
>
> org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:606)
>         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
>
> 2)
> org.apache.openejb.OpenEJBException: Could not lookup <jta-data-source>
> 'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
> resolve class org.postgresql.Driver: Could not lookup <jta-data-source>
> 'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
> resolve class org.postgresql.Driver
>         at
>
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:843)
>         at
>
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:677)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:1261)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:1100)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:130)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5419)
>         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:652)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1930)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>         at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>         at java.lang.Thread.run(Thread.java:745)
> Caused by: org.apache.openejb.OpenEJBException:
> org.apache.openejb.OpenEJBException: Could not lookup <jta-data-source>
> 'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
> resolve class org.postgresql.Driver: Could not lookup <jta-data-source>
> 'openejb/Resource/mypostgres' for unit 'persistence-with-ejb': Unable to
> resolve class org.postgresql.Driver
>         at
>
> org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:988)
>         at
>
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:741)
>         ... 18 more
> Caused by: org.apache.openejb.OpenEJBException: Could not lookup
> <jta-data-source> 'openejb/Resource/mypostgres' for unit
> 'persistence-with-ejb': Unable to resolve class org.postgresql.Driver
>         at
>
> org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:93)
>         at
>
> org.apache.openejb.assembler.classic.Assembler.loadPersistenceUnits(Assembler.java:982)
>         ... 19 more
> Caused by: javax.naming.NamingException: Unable to resolve class
> org.postgresql.Driver
>         at
>
> org.apache.openejb.core.ivm.naming.LazyObjectReference.getObject(LazyObjectReference.java:39)
>         at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:175)
>         at
>
> org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:87)
>         ... 20 more
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Resource and UseAppClassLoader question

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Andy just dropped it.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-03 16:00 GMT+01:00 Howard W. Smith, Jr. <sm...@gmail.com>:

> On Dec 2, 2015 4:56 PM, "Romain Manni-Bucau" <rm...@gmail.com>
> wrote:
> >
> > it doesnt exit yet but staging repo is there
> >
>
> https://repository.apache.org/content/repositories/orgapachetomee-1071/org/apache/openejb/apache-tomee/1.7.3/
> >
> >
>
> *404 - Repository with ID="orgapachetomee-1071" not found*
>
> Repository with ID="orgapachetomee-1071" not found
>

Re: Resource and UseAppClassLoader question

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Dec 2, 2015 4:56 PM, "Romain Manni-Bucau" <rm...@gmail.com> wrote:
>
> it doesnt exit yet but staging repo is there
>
https://repository.apache.org/content/repositories/orgapachetomee-1071/org/apache/openejb/apache-tomee/1.7.3/
>
>

*404 - Repository with ID="orgapachetomee-1071" not found*

Repository with ID="orgapachetomee-1071" not found

Re: Resource and UseAppClassLoader question

Posted by Romain Manni-Bucau <rm...@gmail.com>.
it doesnt exit yet but staging repo is there
https://repository.apache.org/content/repositories/orgapachetomee-1071/org/apache/openejb/apache-tomee/1.7.3/


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-02 22:52 GMT+01:00 Howard W. Smith, Jr. <sm...@gmail.com>:

> On Dec 1, 2015 2:48 PM, "Violeta Georgieva" <vi...@apache.org> wrote:
> >
> >
> > I'm testing with TomEE 1.7.3
>
> Is TomEE 1.7.3 available via tomee downloads page or somewhere else?
>

Re: Resource and UseAppClassLoader question

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Dec 3, 2015 10:01 AM, "Howard W. Smith, Jr." <sm...@gmail.com>
wrote:
>
>
> On Dec 3, 2015 6:18 AM, "Violeta Georgieva" <vi...@apache.org> wrote:
> >
> > smithh032772 wrote
> > > On Dec 1, 2015 2:48 PM, "Violeta Georgieva" &lt;
> >
> > > violetagg@
> >
> > > &gt; wrote:
> > >>
> > >>
> > >> I'm testing with TomEE 1.7.3
> > >
> > > Is TomEE 1.7.3 available via tomee downloads page or somewhere else?
> >
> > I tested with the staged binaries from the mail that called for 1.7.3
voting
> >
> >
> >
>
> Will have to look for that email, thanks.

Found it.[1]

[1]
http://tomee-openejb.979440.n4.nabble.com/VOTE-staging-1071-tomee-1-7-3-td4676997.html

Re: Resource and UseAppClassLoader question

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Dec 3, 2015 6:18 AM, "Violeta Georgieva" <vi...@apache.org> wrote:
>
> smithh032772 wrote
> > On Dec 1, 2015 2:48 PM, "Violeta Georgieva" &lt;
>
> > violetagg@
>
> > &gt; wrote:
> >>
> >>
> >> I'm testing with TomEE 1.7.3
> >
> > Is TomEE 1.7.3 available via tomee downloads page or somewhere else?
>
> I tested with the staged binaries from the mail that called for 1.7.3
voting
>
>
>

Will have to look for that email, thanks.

Re: Resource and UseAppClassLoader question

Posted by Violeta Georgieva <vi...@apache.org>.
smithh032772 wrote
> On Dec 1, 2015 2:48 PM, "Violeta Georgieva" &lt;

> violetagg@

> &gt; wrote:
>>
>>
>> I'm testing with TomEE 1.7.3
> 
> Is TomEE 1.7.3 available via tomee downloads page or somewhere else?

I tested with the staged binaries from the mail that called for 1.7.3 voting



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Resource-and-UseAppClassLoader-question-tp4677073p4677107.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Resource and UseAppClassLoader question

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Dec 1, 2015 2:48 PM, "Violeta Georgieva" <vi...@apache.org> wrote:
>
>
> I'm testing with TomEE 1.7.3

Is TomEE 1.7.3 available via tomee downloads page or somewhere else?