title: Using JNDI Connection pool as Datanucleus PersistenceManagerFactory
body: <p>I am developing a web application using DataNucleus as DAO layer (mainly due to historical reasons). It runs inside Payara server (a Glassfish 4 fork)
  It works fine, but now I'd like to use a JNDI db connection pool to obtain the PersistenceManagerFactory for DataNucleus.
  From the documentation, it seems that the following code would suffice:</p>
  
  <pre><code>pmf = JDOHelper.getPersistenceManagerFactory( "jdbc/HxWmDb", context );
  </code></pre>
  
  <p>but this way I obtain an error starting the application (DbSession is the class which implements the DAO layer, and the error line is exactly the one above):</p>
  
  <pre><code>Caused by: java.lang.ClassCastException
  at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:262)
  at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:150)
  at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1791)
  at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1755)
  at ejb.DbSession.&lt;init&gt;(DbSession.java:119)
  ...
  Caused by: java.lang.ClassCastException: com.sun.gjc.spi.jdbc40.DataSource40 cannot be cast to org.omg.CORBA.Object
  at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:245)
  </code></pre>
  
  <p>Any suggestion?</p>
  
  <p>Little update, as requested by DN1:</p>
  
  <p>As a first approach, I tried exactly what is described in the link:</p>
  
  <pre><code>Properties properties = new Properties();
  properties.setProperty("datanucleus.ConnectionFactoryName","jdbc/HxWmDb");
  PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
  </code></pre>
  
  <p>And the error is, as already said, that a URI is anyway required:</p>
  
  <pre><code>Caused by: org.datanucleus.exceptions.NucleusException: You haven't specified persistence property 'datanucleus.ConnectionURL'
  </code></pre>