This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Deploy MySQL Database to Glasfish using Intellij  RSS feed

 
Brett Wiggins
Greenhorn
Posts: 20
IntelliJ IDE Mac OS X MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I've written a Servlet that queries a database and displays the results. I'm developing in IntelliJ Ultimate but it doesn't deploy the MySQL jar file to the GlassFish domain lib directory. I was getting a ClassNotFound exception until I manually copied it to the domain lib directory, which fixed the problem. Below are some screenshots of my environment. I really am stuck on this.



In the image above on the right is the database window, I am able to connect to the database in Intellij.

The Below image shows the dependencies window. MySQL is listed.



I have no idea why the MySQL library is not getting deployed with the application.

Brett.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data sources should be done in the app server (Glassfish in your case) then use JNDI to get it back, not direct JDBC.

Like you did, using direct JDBC, the app server checks its own library for the JDBC jar file, rather than the lib folder in your war file.

To deploy the JDNI directly, you need a persistence.xml along with your web app and when you deploy, a persistence unit will set up the JNDI for you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!