This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 185500 - Driver is not configured out of the box when using JPA in Java SE projects
Summary: Driver is not configured out of the box when using JPA in Java SE projects
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Sergey Petrov
URL:
Keywords:
: 76756 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-05 10:40 UTC by Petr Jiricka
Modified: 2015-09-17 13:10 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-05-05 10:40:03 UTC
This was originally filed as bug 178970, re-filing as a clean issue.

1. Create a Java SE project (Ant or Maven - the problem is reproducible with both).
2. Set the source level to JDK 6.
3. Create Entity Classes from database, using the bundled JavaDB database,
choose e.g. the Customer table. Create Persistence Unit as suggested etc.
4. Create JPA controller classes for the entity classes you just generated
5. In the main class, put the following in the main method: 
  System.out.println("cust" + new CustomerJpaController().getCustomerCount());
6. Run the application

The running of application will fail, because the JBDC driver is missing. 
We should improve the out of box experience for the database drivers and add
them to the project's libraries/dependencies, if the driver class is not on the runtime classpath yet.
Comment 1 Sergey Petrov 2010-05-06 10:06:55 UTC
after fix need to be verified with maven as it may take a lot of time to add some dependencies and time may depend on internet connection.
Comment 2 Sergey Petrov 2012-06-13 11:17:58 UTC
*** Bug 76756 has been marked as a duplicate of this bug. ***
Comment 3 Petr Jiricka 2012-09-18 07:54:29 UTC
A few notes on this:
- The driver should be added to the runtime-only classpath, which was introduced recently. This type of classpath is not implemented for Ant JavaSE project (in that case it's always runtime+compiletime), but it can be used for Maven SE project.
- Where can we get the Maven coordinates for the driver? Do we have this information? We should at least have it for the drivers that are well-known to us: MySQL, OracleDB, Derby.
- There is also a new utility method for creating a temporary in-memory LibraryImplementation based on jar location and Maven coordinates, but I am not sure if that will be needed in this case.
Comment 4 Sergey Petrov 2012-09-18 10:02:29 UTC
in my opinion it's ok to add to compile+runtime if it's the same as manual addition by users. can't say about maven, it will work properly if all maven artifacts are specified in a registered jdbc library.
Comment 5 Sergey Petrov 2012-09-21 13:50:19 UTC
If connection is registered we have driver registered also, but it doesn't mean we know any maven artifact and addition of corresponding jar to a project may trigger full maven index download and may be quite long for first time.
Comment 6 Sergey Petrov 2013-08-05 07:33:05 UTC
with new db api to get library from a connection, we may have proper maven artifacts in some cases.
Comment 7 Martin Balin 2015-09-17 13:10:07 UTC
Report from old NetBeans version. Due to code changes since it was reported likely not reproducible now. Feel free to reopen if happens in 8.0.2 or 8.1.