Netbeans Project: Resolve Data Source Problems
Asked Answered
A

7

7

In Netbeans 7.1.1. I have a Java project for a web application that I deploy on Tomcat 7. The project is migrated from an earlier version from Netbeans (together with all my other projects).

The problem is that my project now is in an error state. Its name is in red and it has a little yellow triangle in its blue globe project icon. When I right click on the project I see the option to "Resolve Data Source Problem.".

Unfortunately this option does not resolve the problem. When I choose the option I get a dialog with the text: "To resolve, select a Data Source name below then click Add Connection. Database connections for the Data Sources referenced in this project could not be located."

When I select the data source that can't be located (jdbc/mydb) and press the "Add Connection" button, it opens the "New Connection Wizard" but when I press the "Finish" button, I get an "Unable to add connection. Connection already exists."

The connection is already defined in my context.xml and my project is running and deploying without any problems.

Here is my context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myapp.com">
    <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" 
        maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/mydb" 
        password="secret" type="javax.sql.DataSource" 
        url="jdbc:mysql://127.0.0.1:3306/mydb?autoReconnect=true" 
        username="user" validationQuery="select 1"/>

</Context>

How can I get my Netbeans project out of this "Resolve Data Source problem"?

Avaricious answered 1/4, 2012 at 21:29 Comment(0)
M
4

I figured it out on that the solution had been right under my nose all along.

Right click the globe icon of your project > select resolve datasource problem > then select your jdbc name of your resource from the options available. > click add a connection.

A window appears and you should make sure that the resource reference URL is the same as the name of the database you are trying to connect to.

Metz answered 10/10, 2012 at 12:34 Comment(0)
B
3

I had the exact same issue and in order to fix it, this is what I did:

  1. In Netbeans, go to the Files view.

  2. Locate inside your project a folder called setup.

  3. Edit the file datasource-1-jdbc.xml (this name may vary).

  4. Correct de data on it.

  5. Go to Projects view and right click on your project.

  6. Click on Resolve data source problem...

  7. Select the JDBC name and click on Add connection.

  8. Configure the connection and that's it.

PD: I've also removed all previous configured connection to the database (in the services > Databases category).

Hope this helps.

Biafra answered 30/10, 2012 at 11:59 Comment(0)
B
2

I had the same problem. Tried all the tricks. Nothing worked. So without wasting any more time I created a new project in Netbeans 7.1.2 and copied the directories from the old project in to the new project.

It works fine now. Hope this helps

Blumenfeld answered 12/6, 2012 at 15:24 Comment(0)
L
2

The easiest way is

  1. Delete the persistent.xml file.

  2. Go to any of your entity class on the project and check the error close to the class name. It will request you to create another persistent.xml.

  3. Follow the link and create a new persistent.xml with the required data-source name.

This process will create a new table structure for your project without any data.

You can use other means to import your data to the new table.

Lotus answered 24/8, 2012 at 11:27 Comment(0)
A
2

I have encountered the same problem. It can be resolved by carefully editing at the add connection menu. Try match the 'host' , and url between your actual definition at the context.xml and the add connection menu entry. My problem was using 127.0.0.1 as host in the context.xml while using localhost in the add connection menu.

Alfaro answered 26/5, 2013 at 4:46 Comment(0)
C
0

I had the same problem once I changed the project name. What I did to solve the problem was an magical incidence.

Phase 1

  1. Done a "project clean" first.
  2. Right clicked on project name and select "Open required projects".
  3. Done a clean & build again

The problem solved? No, then proceed phase 2.

Phase 2

  1. Open context.xml in Configuration Files
  2. Delete the connection pool
  3. Do Phase 1 again

I'm using Apache-Tomcat & MySQL. These processes solved the problem and the system is working perfectly without any issues.

Crepe answered 29/7, 2013 at 8:41 Comment(0)
G
-3

You can easily open project from your new netbeans. Choose previous netbeans project directory's all project, then all the project's will be in your new netbean.

Globate answered 26/6, 2012 at 7:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.