Where to locate persistence.xml file in Tomcat? - java

I have my little project for persistence in Tomcat (with Hibernate and Postgres). It's not an EJB project.
I inserted the file "persistence.xml" in the "src" folder of the project: goes well there? I have to copy it in some folder of Tomcat? Should I put the Hibernate libraries inside the "lib" folder of Tomcat?
I have read on the site of Postgres that for Tomcat 4 and 5 should be modified the "server.xml" file, inserting a listing that they give, but they don't specify whether the procedure also applies to Tomcat 6. What do you think about?

Related

Where can I find META-INF folder in IntelliJ?

So I'm trying to connect MySQL and Java EE, and to use the DataSource of my database, I need to create a context.xml file. I did some researches and all they say is context.xml needs to be in META-INF folder, but in my IntelliJ, I don't see META-INF folder anywhere.
Do I need to create one or build my project with Maven? I'm confused. Also my IntelliJ version is IntelliJ 2020.1 Ultimate Edition.
Also my Tomcat server is: apache-tomcat-9.0.64, also my MySQL jar file is: mysql-connector-java-8.0.30.jar which is located in apache-tomcat-9.0.64/lib folder.

How to create war file if project doesn't have entry point?

There is a project in github:
https://github.com/chexagon/redis-session-manager
I downloaded and created jar file via maven. But I must use war file for deploying it to Tomcat and use it in our own application. Because of this project doesn't have web.xml file or any entry point (at least I couldn't find it) I couldn't create war file properly. Can anyone help me to solve this issue.
Thanks in advance
The software you downloaded is not a web application. It is a component that can be used as part of a web application.
Correction - Actually it is an add-on component / plugin for Tomcat itself ... that allows the session state of web applications to be persisted in Redis.
Turning it into a WAR file won't help.
Even putting it into your application's WAR file won't help.
The JAR file needs to be copied to the tomcat/lib directory. Then you add a a <Manager> element to the conf/server.xml file. The README.md file describes the attributes of <Manager>.

Update xml file in JAR with weblogic deployment plan

I have a java application(not a EJB, not a MDB, it has a class implements ApplicationLifecycleListener). I build this java application into a jar file then create an EAR file include this jar, deploy the EAR file on a weblogic server, it works perfectly fine.
Now I want to use weblogic deployment plan to update some of the values in a configuration file which located inside the jar file. I generated the deployment plan, but it does not recognize my configuration XML file. I tried manually add it to the deployment plan, and use the deployment plan to redeploy this application. But nothing is updated.
I have read some examples of updating ejbs, but did not find anything about update a JAR's configuration inside an EAR, can anyone please give me example or send leave a link on how to properly use weblogic deployment plan to update a configuration file inside a JAR which is packed within an EAR file. Thanks.
You probably have to place the XML file in a jar file with same name under the same path as the original and use this jar in AppFileOverrides.

Hibernate cannot find Persistence.xml

I have a web app i created with Hibernate in Netbeans. I can't run my app because of classpath issues. It can't find my persistence.xml file. this is the project's folder structure in Netbeans:
Web pages
- META-INF
- persistence.xml
- Web-INF
Source packages
- <default package>
- persistence.xml
com.company.me
- java source files
= (One of the files contains the main() method that i am using to run
the app. I am not running the project as web app but rather as normal app using the main() method as entry point)
You can see that persistence.xml is in two places. I just put them there to test if it will find them. I read from some other posts that the persistence.xml must be in src/main/resources, I have tried to create that folder structure but it didn't work and put the META-INF/persistence.xml there but it didn't work.
I have also tried to create the same folder structure on the file system but it didn't work as well.
Put it in WEB-INF/classes. That's the root of the classpath for a web application.

How to deploy persistence.xml in a web project?

I have a web project created with 'Dynamic Web Project'. I don't use Ant neither Maven in this project and I want to deploy the persistence.xml file to the directory WEB-INF/classes/META-INF (that is the standard place where persistence.xml should reside according to the Java EE 7 standard in a war archive), but I don't see any way to configure this in Eclipse. Is there a way to achieve this?
Thank you.
Marcos
Simplify you have to add additional path (WEB-INF/classes/META-INF - I suppose that WEB-INF is already there). After that you have to create persistence.xml and add this folder to build path (Im not pretty sure if this is a necessary condition).

Categories

Resources