glassfish
  1. glassfish
  2. GLASSFISH-2916

cannot use Toplink with JavaWebstart on XP

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 9.0peur1
    • Fix Version/s: future release
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      2,916

      Description

      Trying to start an application using java webstart which uses toplink results in
      the following stack trace

      javax.persistence.PersistenceException: No Persistence provider for
      EntityManager named JPAWebStartPU
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
      at WebStartTest.<init>(WebStartTest.java:32)
      at WebStartTest.main(WebStartTest.java:43)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.sun.javaws.Launcher.executeApplication(Unknown Source)
      at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
      at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
      at com.sun.javaws.Launcher.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      The app can be run without error via java -jar or from within netbeans....

      This Java SE 6 U1 as used in testing

        Activity

        Hide
        lancea added a comment -

        Marina,

        You are looking at an old version i believe. The issue is starting via the jnlp
        file, not via java -jar which works fine.

        javax.persistence.PersistenceException: No Persistence provider for
        EntityManager named JPAWebStartPU
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
        at WebStartTest.<init>(WebStartTest.java:32)
        at WebStartTest.main(WebStartTest.java:43)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.javaws.Launcher.executeApplication(Unknown Source)
        at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
        at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
        at com.sun.javaws.Launcher.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

        <?xml version="1.0" encoding="UTF-8"?>
        <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
        <persistence-unit name="JPAWebStartPU" transaction-type="RESOURCE_LOCAL">

        <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
        <class>entity.TestPerson</class>
        <properties>
        <property name="toplink.jdbc.url"
        value="jdbc:derby:c:\javadb\databases\testDB;create=true"/>
        <property name="toplink.jdbc.user" value="APP"/>
        <property name="toplink.jdbc.driver"
        value="org.apache.derby.jdbc.EmbeddedDriver"/>
        <property name="toplink.jdbc.password" value="APP"/>
        <property name="toplink.ddl-generation" value="create-tables"/>
        </properties>
        </persistence-unit>
        </persistence>
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc.//DTD JNLP 1.5//EN"
        "http://www.netbeans.org/jnlp/DTD/jnlp.dtd">
        <jnlp codebase="file:///C:/Netbeans/JPAWebStart" href="JPAWebStart.jnlp">
        <information>
        <title>JPAWebStart</title>
        <vendor>Company, Inc.</vendor>
        <homepage href="homepage.html"/>
        <description> </description>
        <icon href="default"/>
        <offline-allowed/>
        </information>
        <resources>
        <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
        </resources>
        <resources>
        <jar download="eager" href="dist/JPAWebStart.jar" main="false"/>
        </resources>
        <resources locale="" os="">
        <jar download="eager" href="dist/lib/toplink-essentials.jar" main="false"
        version=""/>
        </resources>
        <resources locale="" os="">
        <jar download="eager" href="dist/lib/derby.jar" main="false" version=""/>
        </resources>
        <application-desc main-class="WebStartTest"/>
        </jnlp>
        import entity.TestPerson;
        import java.io.IOException;
        import javax.persistence.EntityManager;
        import javax.persistence.EntityManagerFactory;
        import javax.persistence.Persistence;
        /*

        • WebStartTest.java
          *
        • Created on April 25, 2007, 9:39 AM
          *
        • To change this template, choose Tools | Template Manager
        • and open the template in the editor.
          */

        /**
        *

        • @author Owner
          */
          public class WebStartTest {

        private EntityManagerFactory emf;

        private EntityManager em;

        /** Creates a new instance of WebStartTest */
        public WebStartTest() {
        try

        { System.out.println(getClass().getClassLoader().getResources("resourcename")); }

        catch (IOException ex)

        { ex.printStackTrace(); }

        emf = Persistence.createEntityManagerFactory("JPAWebStartPU");
        em = emf.createEntityManager();
        }

        /**

        • @param args the command line arguments
          */
          public static void main(String[] args) { System.out.println("Starting WebStartTest"); WebStartTest x = new WebStartTest(); x.run(); }

        public void addSong(TestPerson person)

        { em.getTransaction().begin(); em.persist(person); em.getTransaction().commit(); System.out.println("Person created"); }

        private void run()

        { TestPerson p = new TestPerson(); p.setName("duke"); addSong(p); em.close(); emf.close(); }

        }

        Show
        lancea added a comment - Marina, You are looking at an old version i believe. The issue is starting via the jnlp file, not via java -jar which works fine. javax.persistence.PersistenceException: No Persistence provider for EntityManager named JPAWebStartPU at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60) at WebStartTest.<init>(WebStartTest.java:32) at WebStartTest.main(WebStartTest.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.sun.javaws.Launcher.executeApplication(Unknown Source) at com.sun.javaws.Launcher.executeMainClass(Unknown Source) at com.sun.javaws.Launcher.doLaunchApp(Unknown Source) at com.sun.javaws.Launcher.run(Unknown Source) at java.lang.Thread.run(Unknown Source) <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd "> <persistence-unit name="JPAWebStartPU" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider> <class>entity.TestPerson</class> <properties> <property name="toplink.jdbc.url" value="jdbc:derby:c:\javadb\databases\testDB;create=true"/> <property name="toplink.jdbc.user" value="APP"/> <property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/> <property name="toplink.jdbc.password" value="APP"/> <property name="toplink.ddl-generation" value="create-tables"/> </properties> </persistence-unit> </persistence> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc.//DTD JNLP 1.5//EN" "http://www.netbeans.org/jnlp/DTD/jnlp.dtd"> <jnlp codebase="file:///C:/Netbeans/JPAWebStart" href="JPAWebStart.jnlp"> <information> <title>JPAWebStart</title> <vendor>Company, Inc.</vendor> <homepage href="homepage.html"/> <description> </description> <icon href="default"/> <offline-allowed/> </information> <resources> <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/> </resources> <resources> <jar download="eager" href="dist/JPAWebStart.jar" main="false"/> </resources> <resources locale="" os=""> <jar download="eager" href="dist/lib/toplink-essentials.jar" main="false" version=""/> </resources> <resources locale="" os=""> <jar download="eager" href="dist/lib/derby.jar" main="false" version=""/> </resources> <application-desc main-class="WebStartTest"/> </jnlp> import entity.TestPerson; import java.io.IOException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; /* WebStartTest.java * Created on April 25, 2007, 9:39 AM * To change this template, choose Tools | Template Manager and open the template in the editor. */ /** * @author Owner */ public class WebStartTest { private EntityManagerFactory emf; private EntityManager em; /** Creates a new instance of WebStartTest */ public WebStartTest() { try { System.out.println(getClass().getClassLoader().getResources("resourcename")); } catch (IOException ex) { ex.printStackTrace(); } emf = Persistence.createEntityManagerFactory("JPAWebStartPU"); em = emf.createEntityManager(); } /** @param args the command line arguments */ public static void main(String[] args) { System.out.println("Starting WebStartTest"); WebStartTest x = new WebStartTest(); x.run(); } public void addSong(TestPerson person) { em.getTransaction().begin(); em.persist(person); em.getTransaction().commit(); System.out.println("Person created"); } private void run() { TestPerson p = new TestPerson(); p.setName("duke"); addSong(p); em.close(); emf.close(); } }
        Hide
        marina vatkina added a comment -

        This seems like a JDK bug as loader.getResources() returns no provider names in
        JDK 6 while it works correctly in JDK 5.

        Other notes:

        1. The jar file dist/JPAWebStart.jar doesn't run as 'java -jar' because it tries
        to access a wrong PU name. Recompiling src/SimpleTableDemo.java and repackaging
        the jar solved this problem.

        2. There is no need Netbeans to test the example. 'javaws JPAWebStart.jnlp'
        behaves the same. One will need to edit JPAWebStart.jnlp to point to your file
        location, and change persistence.xml in the dist/JPAWebStart.jar to point to the
        derby (javadb) location.

        3. Using JDK 5, I got a permission exception on TLE logger trying to access a
        System logging propery. But it went into actually creating an EMF.

        4. Using JDK 6, you do get 'No Persistence provider for EntityManager named
        JPAWebStartPU' exception because of the classloader issue.

        I'll check with Tim about the next steps.

        Show
        marina vatkina added a comment - This seems like a JDK bug as loader.getResources() returns no provider names in JDK 6 while it works correctly in JDK 5. Other notes: 1. The jar file dist/JPAWebStart.jar doesn't run as 'java -jar' because it tries to access a wrong PU name. Recompiling src/SimpleTableDemo.java and repackaging the jar solved this problem. 2. There is no need Netbeans to test the example. 'javaws JPAWebStart.jnlp' behaves the same. One will need to edit JPAWebStart.jnlp to point to your file location, and change persistence.xml in the dist/JPAWebStart.jar to point to the derby (javadb) location. 3. Using JDK 5, I got a permission exception on TLE logger trying to access a System logging propery. But it went into actually creating an EMF. 4. Using JDK 6, you do get 'No Persistence provider for EntityManager named JPAWebStartPU' exception because of the classloader issue. I'll check with Tim about the next steps.
        Hide
        lancea added a comment -

        Lowering this to a PR. It can be made to work with webstart, but we have to
        look to improve the error messages being returned here as the error is not
        correct below

        Show
        lancea added a comment - Lowering this to a PR. It can be made to work with webstart, but we have to look to improve the error messages being returned here as the error is not correct below
        Hide
        marina vatkina added a comment -

        reassign

        Show
        marina vatkina added a comment - reassign
        Hide
        Tom Mueller added a comment -

        Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

        Show
        Tom Mueller added a comment - Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

          People

          • Assignee:
            Mitesh Meswani
            Reporter:
            lancea
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: