Hi Romain,Thank you! I am able to get the datasource using java:openejb/Resource/ds/jdbc/<name> and get connections from it. I will modify the code to use resources.xml and remove the flag to get the JNDI lookup working. I really appreciate your help.
-Thank you -SP On Saturday 24 December 2016 08:16 PM, Romain Manni-Bucau wrote:
2016-12-24 15:45 GMT+01:00 Sanjay Prasad <[email protected]>:Hi Romain, How do i lookup a datasource instance using JNDI if I deploy it using resources.xml ? I am unable to get it using java:/comp/env/jdbc/<name>. Can you please let me know the right way of doing this?There is a merge in tomcat JNDI context so should be accessible but default way is using openejb:Resource or java:openejb/Resource instead of java:comp/env as subcontext (prefix)-Thanks in advance -SP On Saturday 24 December 2016 08:01 PM, Romain Manni-Bucau wrote:tomcat can create the instance before openejb/tomee starts which will create another instance. it is often ok but rarely not (the issue) Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github < https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2016-12-24 15:23 GMT+01:00 Sanjay Prasad <[email protected]>: Hi Romain,Thanks for the quick response. I am not clear on the "singleton can have 2 instances" statement and the issue TOMEE-1888 does not have much info. Can you please explain what I am going to run into if I run the system with the tomee.tomcat.datasource.wrap flag set to true ? -Thanks in advance -SP On Saturday 24 December 2016 07:36 PM, Romain Manni-Bucau wrote: Hithis is due to https://issues.apache.org/jira/browse/TOMEE-1888 if we wrap by default, singleton (scope of context.xml) can have 2 instances so default is aligned on tomcat to respect it updated doc at http://tomee.apache.org/admin/configuration/server.html Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Blog <http://rmannibucau.wordpress.com> | Github < https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2016-12-24 14:56 GMT+01:00 Sanjay Prasad <[email protected]>: Hi guys,I shifted a few applications from tomee-plume 1.7.4 to 7.0.2 and the context.xml (in webapp's META-INF) resources stopped working as it used to. The persistence mappings were found to be not JTA managed and tomee was allocating hsql entries for them and causing issues. I tried moving the resources to resources.xml and then naming lookups under java:/comp/env/jdbc stopped working. I can get it all to work by specifying the same resources in context.xml and resources.xml at the same time and that does not look right. Looking at the code, I figured that the JTA managed flag was reported as missing because the resource properties, when loaded from context.xml, was getting loaded as a "reference". From context.xml ------------------------ {jndiName=jdbc/K11WriteDb, appName=localhost/k11, factory=null, reference=ResourceRef[className=javax.sql.DataSource,factory ClassLocation=null,factoryClassName=org.apache.naming. factory.ResourceFactory,{type=scope,content=Shareable},{ type=auth,content=Container},{type=singleton,content=true},{ type=password,content=test},{type=maxIdle,content=10},{ type=validationQuery,content=select 1},{type=JtaManaged,content=tr ue},{type=driverClassName,content=org.postgresql.Driver},{ type=maxWait,content=10000},{type=url,content=jdbc:postgres ql://localhost:5432/k11?targetServerType=master},{type =maxActive,content=100},{type=username,content=k11}], OriginalId=jdbc/K11WriteDb} From resources.xml -------------------------- {JtaManaged=true, JdbcDriver=org.postgresql.Driver, JdbcUrl=jdbc:postgresql://localhost:5432/k11?targetServerType=master, UserName=k11, Password=test, PasswordCipher=PlainText, OpenEJBResourceClasspath=false, maxIdle=10, validationQuery=select 1, maxWait=10000, maxActive=100} I saw this flag, tomee.tomcat.datasource.wrap, in TomcatWebAppBuilder.java that could force the loading of context.xml resources in the resources.xml format (force datasource wrapping). Setting this flag to true in system.properties file seems to make things work as before (in tomee 1.7.4) without making any changes to my wars. As I see no documentation regarding this flag, I am not sure if I am supposed to use this and whether using this will have other side effects. Can someone please confirm that it is ok to use this flag ? -Regards -SP "Disclaimer: This message is being sent from Kalki Communication Technologies Pvt Ltd (KALKITECH). and may contain information which is confidential or privileged. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorized use of the content of this message can expose the responsible party to civil and/or criminal penalties, and may constitute a more serious offense. Further the company does not accept liability for any errors, omissions, viruses or computer problems experienced as a result of this transmission. If you have received this message in error, notice is hereby given that no representation, contract or other binding obligation shall be created by this e-mail." "Disclaimer: This message is being sent from Kalki CommunicationTechnologies Pvt Ltd (KALKITECH). and may contain information which is confidential or privileged. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorized use of the content of this message can expose the responsible party to civil and/or criminal penalties, and may constitute a more serious offense. Further the company does not accept liability for any errors, omissions, viruses or computer problems experienced as a result of this transmission. If you have received this message in error, notice is hereby given that no representation, contract or other binding obligation shall be created by this e-mail.""Disclaimer: This message is being sent from Kalki Communication Technologies Pvt Ltd (KALKITECH). and may contain information which is confidential or privileged. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorized use of the content of this message can expose the responsible party to civil and/or criminal penalties, and may constitute a more serious offense. Further the company does not accept liability for any errors, omissions, viruses or computer problems experienced as a result of this transmission. If you have received this message in error, notice is hereby given that no representation, contract or other binding obligation shall be created by this e-mail."
"Disclaimer: This message is being sent from Kalki Communication TechnologiesPvt Ltd (KALKITECH). and may contain information which is confidential or
privileged. If you are not the intended recipient, please advise the senderimmediately by reply e-mail and delete this message and any attachments
without retaining a copy. Any unauthorized use of the content of this messagecan expose the responsible party to civil and/or criminal penalties,
and may constitute a more serious offense. Further the company does not acceptliability for any errors, omissions, viruses or computer problems
experienced as a result of this transmission. If you have received thismessage in error, notice is hereby given that no representation, contract or other binding obligation shall be created by this e-mail."
