The name of the driver class for the datasource is missing (Netbeans+ PostgreSql + Glassfish)
Asked Answered
R

9

9

I'm trying to develop an EJB application using Netbeans 8 on a Postgres 9.2 db and Glassfish 4 server.

Once I created connection pool and JDBC resources in the glassfish admin panel, I'm not able to add entities using the datasource. Netbeans still giving me an error:

The name of the driver class for the datasource is missing

I've already tried adding libraries to the project. I copied postgresql-9.2-1002.jdbc4.jar and postgresql-9.2-1002.jdbc3.jar files in C:\Program Files\glassfish-4.0\glassfish\domains\domain1\lib folder.

Screenshot: http://imageshack.com/a/img843/6884/w3ko.png

If I create entities using a connection created before(in NB Services/Databases), it works, but result set after any query is empty. Any idea?

Here the connection pool I created: http://imageshack.com/a/img838/8286/bkw8.png

This is my persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="Esempio-ejbPU" transaction-type="JTA">
    <jta-data-source>try_</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>
Retsina answered 23/4, 2014 at 21:22 Comment(2)
Hmm I get the same error. Maybe a bug in Netbeans? As a workaround you can create your entities manually.Allhallowmas
Shutdown the server and try again. But this doesn't show any tables on my database.Allhallowmas
R
0

Solved: it was a connection pool issue. Creating a driver one in glassfish admin panel I've got no more problems.

Retsina answered 26/4, 2014 at 8:32 Comment(3)
could you mention which driver you installed?Moreland
This is not an answer. You need to describe how you solved it or even better accept @Iragi KNJ answer which describes how to solve this (at least it did for me)Isodynamic
how you solved it?Berbera
B
13

Apologies for being straightforward, but I believe that on this specific situation, you are all wrong. What should be done is:

  • Go to your Glassfish server administration panel (Link should look like this: http://localhost:4848/common/index.jsf (Under Additional Properties tab)
    • Click on Services in Netbeans
    • Click on Server
    • Right-click on your server name [A pop-up contextual menu appears]
    • Click on View Domain Admin Console [Note: Your server must be running in order to see that feature. A browser tab is automatically launched, if the server is running. You know that your server is running if you see a greenish arrow pointing to the right on the right of the server instance]
  • Click on resources
  • Click on JDBC
  • Click on JDBC Connection Pools
  • Add the following properties by clicking every time on the button Add Property (After selecting the pool name and editing it):

    • driverClass: com.mysql.jdbc.Driver
    • URL : jdbc:mysql://localhost/your_database_name
    • password : your_password to the database management system
    • serverName : localhost or your_server_name
    • user : root or your_username to access the database management system
    • databaseName : your_database_name
  • Set up your JDBC Resources [jdbc/your_pool_name]

  • Point to the specific connection pool you just setup by selecting it in the drop down box.

Save everything (The button usually is on the upper-right corner of your Internet browser) Don't forget that the JDBC Resources is always connected to a connection pool. So ensure that it is the case for you. They, JDBC Connection Pools and JDBC Resources, are usually located under JDBC in the left pane menu of your server administration panel. Go back to whatever you were doing, and try again. Please also note that this works for MySQL Database Management Systems. You might need to change the driver class as well as the URL if using another DBMS. You may find additional information on YouTube [http://www.youtube.com/].

I believe this is the answer.

Biles answered 12/10, 2015 at 22:40 Comment(1)
Worket perfectly for me with the driverClass: com.mysql.cj.jdbc.Driver on mysql 8.0.23Berbera
W
2

For me the issue was that I had added a new JDBC driver JAR file to Glassfish, but I hadn't added it to NetBeans.

The first step is to copy your JAR file to NetBean's EXT folder. For me, that folder is: "C:\Program Files\NetBeans 8.0.1\ide\modules\ext"

Next, we need to add the JDBC driver as described below:

  • In NetBeans, select Window > Services menu option which adds the Services tab to the explorer panel.
  • Expand the "Database" tree node
  • Right click on the "Drivers" tree node and select "New Driver..."
  • In the "New JDBC Driver" window press "Add..." which opens a dialog that says "Select Driver".
  • Navigate to the EXT folder where you copied your JAR file and select the JAR file.
  • Press OK.
  • The new driver will be added to the list.

When I attempted to create an "Entity class from database", I still ran into issues when I selected my connection. After trying various things what worked for me was to:

  • Open the Database tree node again and delete each of the database connections.
  • Return to the Projects tabs and go through the steps to create an "Entity class from database".
  • When the dialog appears, in the drop down select "New Data Source".
  • Select the driver and then enter the information for your database.
  • After recreating the connection I was able to create the Entity class from the selected database table.

Good luck!

Willhite answered 5/3, 2015 at 19:21 Comment(0)
T
2

Steps in Netbeans:
Go To-->Service Tab-->Right Click on Drivers-->New Driver--> Add your driver jar file here

Netbeans automatically populates details of driver from JAR file.Check Driver Class value, this value we will use in Glassfish server connection pool.

Steps in Glassfish:

Go to Glassfish Admin panel
In your JDBC Connection pool add property driverClass and paste the value of Driver Class registered with Netbeans Drivers tab in previous step.

Toxicity answered 29/2, 2020 at 6:33 Comment(0)
R
1

I resolved this issue like this:

  1. Delete the datasource in glassfish.
  2. Create the connection datasource in Netbeans (Tab Services --> Databases)
  3. Create a Enterprise project
  4. Create Entity classes from Databases
  5. Execute the wizard
  6. Deploy the project in glassfish from NetBeans
  7. Enter to Glassfish Admin console and check the created datasource in Resources-->JDBC (Must be created a pool and datasource).
Ride answered 30/7, 2014 at 20:1 Comment(0)
R
0

Solved: it was a connection pool issue. Creating a driver one in glassfish admin panel I've got no more problems.

Retsina answered 26/4, 2014 at 8:32 Comment(3)
could you mention which driver you installed?Moreland
This is not an answer. You need to describe how you solved it or even better accept @Iragi KNJ answer which describes how to solve this (at least it did for me)Isodynamic
how you solved it?Berbera
R
0

I faced the same problem, so:

  • First of all, it's not Jboss or Glassfish problem. it's Netbeans or Eclipse.

  • Second to resolve that, do the below:

    1. Delete all connections (in Netbeans: from Services tab disconnect first then left click Delete)
    2. Recreate the connection again (in Netbeans: from Services tab then Database, left click New Connection. in the New Connection Wizard and after choosing the connection type, focus on JDBC URL and copy past from standalone. then Finish)
Rossetti answered 30/11, 2014 at 20:54 Comment(0)
S
0

adding the driver jar file to "{$installation_folder}\NetBeans 8.0.1\ide\modules\ext" fixed the problem for me

Skate answered 2/12, 2014 at 3:6 Comment(0)
R
0

In the connection pool properties, In the URL property don't forget "localhost"

Reputed answered 4/2, 2016 at 2:12 Comment(0)
C
0

In my case I had to go to glassfish admin panel and change the driver class of Derby connection pool (under JDBC resources) to "org.apache.derby.jdbc.ClientDataSource"

Consign answered 20/5, 2019 at 18:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.