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 257287 - glassfish-resources.xml is not used to define a datasource in an Enterprise Application project
Summary: glassfish-resources.xml is not used to define a datasource in an Enterprise A...
Status: RESOLVED WONTFIX
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 8.1
Hardware: PC Windows 10
: P2 normal (vote)
Assignee: Petr Hejl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-24 13:28 UTC by ricg
Modified: 2016-05-17 12:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The NetBeans project (84.84 KB, application/x-zip-compressed)
2015-12-24 13:28 UTC, ricg
Details
test project (45.88 KB, application/octet-stream)
2016-05-17 12:29 UTC, Petr Hejl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ricg 2015-12-24 13:28:21 UTC
Created attachment 157915 [details]
The NetBeans project

To reproduce the problem:

1. Create a new project, type "Java EE, Enterprise Application".

2. Create a new database with Java DB. user app/app.

3. Create a new entity "user". Tick "Create Persistence Unit.

DataSource : "New Data Source. JNDI 
name : jdbc/testBug 
Database Connection : choose the new database created in the step 2.

4. Create an EJB session bean stateless.

5. In this EJB add a reference to an entity manager :

@PersistenceContext(unitName = "testBugGlassfish-resources-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

6. Deploy the application.
Error message : Invalid resource : java:module/jdbc/testBug__pm

Remark : it works if the project is a "Java Web project" and not a "Java EE, Enterprise Application" (for a Java Web project glassfish-resources is used to define the datasource). (Petr Hejl solved it I think).

For an enterprise application glassfish-resources is in META-INF of the EJB module; for a Java Web project the file is in WEB-INF.
Comment 1 Petr Hejl 2016-05-17 10:20:52 UTC
This is really strange and might be a bug in GF. When I follow your steps, but instead of step 5 I just use (injected) datasource everything works nicely.
Comment 2 Petr Hejl 2016-05-17 10:41:12 UTC
Moving the persistence.xml and glassfish-resources.xml and changing scope to java:app works without problem. Unless I'll find anything wrong in project config I'll file a bug for GF.
Comment 3 Petr Hejl 2016-05-17 12:29:06 UTC
Filed https://java.net/jira/browse/GLASSFISH-21543.
Comment 4 Petr Hejl 2016-05-17 12:29:57 UTC
Created attachment 159782 [details]
test project

Simple test project.