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 235220 - NetBeans sample database JDBC resource not found
Summary: NetBeans sample database JDBC resource not found
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-29 09:26 UTC by arungupta
Modified: 2016-07-07 08:54 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description arungupta 2013-08-29 09:26:02 UTC
- Create a Maven or Ant-based Java EE project
- Use "Create Entity class from Database" wizard
- Use the sample database bundled with NetBeans
- By default, jdbc/sample JDBC resource does not exist in a fresh install of GlassFish. But creation of an entity in any project automatically deploys the resource.

So far so good ...

Now I delete the GlassFish installation and unzip a new GlassFish bundle. Redeploying the project now fails with:

java.lang.RuntimeException: Invalid resource : jdbc/sample__pm
    at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:593)
    at com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:517)
    at org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
    at org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)

because jdbc/sample JDBC resource does not exist in this GlassFish installation.

If I create another temporary project, create entity from this sample database, then the JDBC resource is again deployed to GlassFish.

Is there a configuration/option that allows me to create jdbc/sample JDBC resource in this new install of GlassFish, without creating this redundant project ?
Comment 1 Sergey Petrov 2013-08-29 09:56:28 UTC
Sorry, I don't know easier way but also don't see it as an issue on nb side yet from provided description.
Comment 2 Sergey Petrov 2013-08-29 10:06:37 UTC
It's not clear from email "Using this sample database makes the project dependent upon NetBeans.". If you are using any specific database, you are  alsways dependent on corresponding database. You can't be independent from nb as this db is part of nb distribution as I know.
Comment 3 Petr Jiricka 2013-08-29 16:26:20 UTC
I am thinking if the workaround is the following:
When creating Entity Classes from Database, you can create a new datasource using the Data Source dropdown. If you create a new datasource which points to the same sample database (jdbc:derby://localhost:1527/sample), then the following file will be created in the project:
setup/glassfish-resources.xml

This file contains the declarative description of the datasource+connection pool, and I believe now if you deploy the project to any (clean) GlassFish, the datasource will be deployed to the server. Cc'ing Tomas to confirm that this will work. In contrast, when using the predefined jdbc/sample resource, then setup/glassfish-resources.xml will not be created. 

Will this work as a workaround?

Regarding a solution/fix, how about if we created setup/glassfish-resources.xml even when using an existing datasource like jdbc/sample, would that fix this issue?
Comment 4 Sergey Petrov 2013-08-29 17:12:26 UTC
it's the diference in approaches, server should be already setup, and we don not provide all possible setups for all possible use cases just in case if setup is missed.
What is user will use already existent mysql datasource, should we create configuration to create this datasource as well, just in case if user will drop his gf and try another one with missed configuration?
Comment 5 TomasKraus 2013-08-29 19:47:41 UTC
Well, problem is that users have tools to destroy things ant they will do so all the time. And we'll be getting bug reports again and again.

Having resources file with pool and datasource setup will make it a bit more foolproof. I like this idea. Even in situation when such a resource exists on the server - we can retrieve resources attributes and store them. This will fortify sample against what Arun is pointing to.

If user wants to extend mysql then he shall do it in glassfish-resources.xml on project level. At least in those samples that should be reliable.

In user's own projects it's their own problem to keeps things working.

Another story is, if there is a chance to have this in 7.4 just day before code freeze.
Comment 6 Sergey Petrov 2013-08-30 03:34:31 UTC
I may mix terms a bit but it's not fortify sample, it's user project but with sample db usage but with sample jdbc resource created by ide. Also I may prefer some ui checkbox here, like "add datasource configuration to the project" next to datasource selection combobox. But if I'm the only one in opposition, I can try to add this by default and for hardcoded "jdbc/sample" only and not for other user jdbc resources. 

Yet in my opinion user resources are usually more portable rather then  local sample database. User may have remote db connection but will fail to deploy an application on other then local development system as only development system may have jdbc resources configured on the server. It's an argument for more general solution with "checkbox" or similar
Comment 7 Petr Jiricka 2013-08-30 06:30:26 UTC
Let's wait if the workaround works for Arun, and decide based on that.
Comment 8 Sergey Petrov 2013-09-04 08:21:09 UTC
so, no final afreement, it may have sense to add this option, either 
- "add datasource configuration" to the project, but there is a question with portability, i.e. glassfish vs others servers
- some button/wizard, somewhere like "create sample jdbc/sample ds" and it may be universal for any server with ds creation support

but in my opinion it's at most enhancement request, not an issue in current functionality.
Comment 9 arungupta 2013-09-04 22:08:26 UTC
I like the workaround where glassfish-resources.xml is created with the application if the JDBC resource is not already defined in the underlying GlassFish instance. This will make the sample portable at least.

The workaround will need to investigate the behavior if jdbc/sample JDBC resource already exists and possibly point to a different database.

Should jdbc/sample be changed to jdbc/netbeans_sample instead ?
Comment 10 Martin Balin 2016-07-07 08:54:27 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss