0

I have a non-spring project and I am using JNDI to pass the DB connection values. It is working fine while I am running from Tomcat as I am providing the values in server.xml file in the tomcat project but when I am not sure how to pass the JNDI values for integration test. I tried adding the resource values in Context.xml file but it is not working.

Can anyone help me with the same?

Rohith Joseph
  • 603
  • 1
  • 5
  • 17
  • you must indicate the jndi name in the persistence.xml file. Is a standard configuration file in JPA – JLazar0 Aug 05 '20 at 12:06
  • Yes. I have added the jndi name in the persistence.xml and it works fine when run from a tomcat server but the same is not working when called from an integration test. I need to know how we pass values to the jta for an integration test. – Rohith Joseph Aug 05 '20 at 12:15
  • Check this link to see if any solution works for you. https://stackoverflow.com/questions/385532/how-to-configure-jpa-for-testing-in-maven Check Vlad-HC's answer where you put the persistence.xml under the test directory, and if it works configure maven to move it from src / main to src / test and thus not have 2 copies – JLazar0 Aug 05 '20 at 12:50
  • Thanks @JLazar0 for your input but all the suggestions are with persistence.xml without a jta datasource but I need it with jta datasource – Rohith Joseph Aug 12 '20 at 11:17
  • Read 2.2.1 https://docs.jboss.org/hibernate/entitymanager/3.4/reference/en/html/configuration.html#:~:text=When%20a%20jta%2Ddatasource%20is,is%20used%2C%20RESOURCE_LOCAL%20is%20used.&text=The%20provider%20is%20a%20fully,work%20with%20several%20EJB3%20implementations. – JLazar0 Aug 12 '20 at 12:59

0 Answers0