Re: Is "Run JPQL Query" working?

2019-07-25 Thread Richard Grin
Hi Geertjan,

Simple and quick to reproduce:

  1. Create a new Maven Web Application Project (Java EE 8). Associate it with 
Payara 5.192 server.

  2. Right click on the new project and New Entity classes from database. 
Choose the sample database (Java DB). Add the CUSTOMER table. Any package for 
the entities (i.e. entities). Finish.

  3. Some code must be added into persistence.xml. This step is necessary 
because there is a very annoying problem I have already reported in a previous 
message: no match between the "design" and the "source" view of 
persistence.xml. With the previous versions of NetBeans, these lines were 
automatically added into the file. Now it is "added" in the design view but not 
into the file!

Add jta-data-source and provider in persistence.xml:

org.eclipse.persistence.jpa.PersistenceProvider
jdbc/sample

Add transaction-type="JTA" too.

Finally:


http://java.sun.com/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_2.xsd;>
  
  
org.eclipse.persistence.jpa.PersistenceProvider
jdbc/sample

  

  


4. Start Payara and Run the application; no problem, "Hello World!" in the 
brower (is this step necessary?)

5. Right click on persistence.xml > Run JPQL Query and type
select c from Customer c

The error message:
javax.persistence.PersistenceException: No Persistence provider for 
EntityManager named samplePU
at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)

If I had dependencies in pom.xml for the group org.eclipse.persistence, the 
error changes:

javax.persistence.PersistenceException: Exception [EclipseLink-7060] (Eclipse 
Persistence Services - 2.5.2.v20140319-9ad6abd): 
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/sample].
Internal Exception: javax.naming.NoInitialContextException: Need to specify 
class name in environment or system property, or in an application resource 
file: java.naming.factory.initial
at 
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:766)
at 
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
at 
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304)
at 
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336)
at 
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:302)
Caused by: Exception [EclipseLink-7060] (Eclipse Persistence Services - 
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/sample].
Internal Exception: javax.naming.NoInitialContextException: Need to specify 
class name in environment or system property, or in an application resource 
file: java.naming.factory.initial
at 
org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:520)
at 
org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:109)
at 
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at 
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:204)
at 
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:741)
at 
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
at 
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
... 6 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name 
in environment or system property, or in an application resource file: 
java.naming.factory.initial
at 
java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:685)
at 
java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
at 
java.naming/javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:402)
at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:413)
at 
org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:103)
... 11 more


However if I add some code to the project for JSF, the project works well 
without any error to display the data of the database linked to the data source 
jdbc/sample. So the problem happens only 

Is "Run JPQL Query" working?

2019-07-23 Thread Richard Grin
Hi,

NetBeans 11.1 beta 4 (I have not installed the final version yet).

I can't use the tool to test the JPQL queries with a right click on 
persistence.xml > "Run JPQL Query".

The JPQL query: "select c from Customer c" with the sample database 
provided by the installation. I have generated the entities with New > 
"Entity Classes From Database...".

I receive this message: javax.persistence.PersistenceException: No 
Persistence provider for EntityManager named null
     at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)

persistence.xml:


http://java.sun.com/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_2.xsd;>
   
org.eclipse.persistence.jpa.PersistenceProvider
     jdbc/sample
     
   
     
   


Any help?

Richard Grin


-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists