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
        marina vatkina added a comment -

        Reassigning to Tim for the jws investigation.

        Tim, please keep in mind that javax.persistence.Persistence uses context
        classloader to load the provider classes:
        https://glassfish.dev.java.net/source/browse/glassfish/persistence-api/src/java/javax/persistence/Persistence.java?rev=1.7&view=markup

        Show
        marina vatkina added a comment - Reassigning to Tim for the jws investigation. Tim, please keep in mind that javax.persistence.Persistence uses context classloader to load the provider classes: https://glassfish.dev.java.net/source/browse/glassfish/persistence-api/src/java/javax/persistence/Persistence.java?rev=1.7&view=markup
        Hide
        Tim Quinn added a comment -

        Sorry for the ping-pong effect of where this issue belongs.

        If I understand Lance's forum posts and this issue correctly, this problem is
        not involved at all with an Java EE app client using Java Web Start to launch
        the app client. I think this is confirmed by the stack trace Lance has included
        in the issue - the app client code does not appear, and Java Web Start is
        starting Lance's user application class directly (not through the app client
        container).

        So the issue does involve a regular Java application that uses Toplink and Lance
        is trying to launch that application using Java Web Start.

        I can lend my experience working with Java Web Start to help investigate this
        problem further, but it does not fit in the app client component. (I know
        Marina had asked in e-mail earlier today about which component this issue would
        best fit and I'm only now able to catch up on some things.)

        Show
        Tim Quinn added a comment - Sorry for the ping-pong effect of where this issue belongs. If I understand Lance's forum posts and this issue correctly, this problem is not involved at all with an Java EE app client using Java Web Start to launch the app client. I think this is confirmed by the stack trace Lance has included in the issue - the app client code does not appear, and Java Web Start is starting Lance's user application class directly (not through the app client container). So the issue does involve a regular Java application that uses Toplink and Lance is trying to launch that application using Java Web Start. I can lend my experience working with Java Web Start to help investigate this problem further, but it does not fit in the app client component. (I know Marina had asked in e-mail earlier today about which component this issue would best fit and I'm only now able to catch up on some things.)
        Hide
        gfbugbridge added a comment -

        <BT6550501>

        Show
        gfbugbridge added a comment - <BT6550501>
        Hide
        marina vatkina added a comment -

        Tim, while I still think that it's a JWS classloader issue that either
        Persistence class or Toplink can do much about, I'm ok to keep it at one place
        for now.

        To your point that JWS is not in charge: the stack trace starts with
        com.sun.javaws.Launcher, followed by what look like a Main class (Lance, can you
        please attach the sources and the steps?).

        Unfortunately (see bug
        https://glassfish.dev.java.net/issues/show_bug.cgi?id=2814 that is filed as a
        'patch') Persistence doesn't report any problems that it might encounter trying
        to load the providers listed under META-INF/services. Which make me think that
        the problem is caused by the classes not being visible to the classloader.

        thanks,
        -marina

        Show
        marina vatkina added a comment - Tim, while I still think that it's a JWS classloader issue that either Persistence class or Toplink can do much about, I'm ok to keep it at one place for now. To your point that JWS is not in charge: the stack trace starts with com.sun.javaws.Launcher, followed by what look like a Main class (Lance, can you please attach the sources and the steps?). Unfortunately (see bug https://glassfish.dev.java.net/issues/show_bug.cgi?id=2814 that is filed as a 'patch') Persistence doesn't report any problems that it might encounter trying to load the providers listed under META-INF/services. Which make me think that the problem is caused by the classes not being visible to the classloader. thanks, -marina
        Hide
        lancea added a comment -

        I attached a zip which contains the source as well as everything to run the
        simple app from inside netbeans, via javawebstart (just double click the jnlp),
        and via java -jar.

        This is a standard netbeans project so the jars are in the dist directory.

        Show
        lancea added a comment - I attached a zip which contains the source as well as everything to run the simple app from inside netbeans, via javawebstart (just double click the jnlp), and via java -jar. This is a standard netbeans project so the jars are in the dist directory.
        Hide
        lancea added a comment -

        Created an attachment (id=895)
        webstart sample of the failure

        Show
        lancea added a comment - Created an attachment (id=895) webstart sample of the failure
        Hide
        Tim Quinn added a comment -

        Just to clarify one thing. I did not mean to claim that Java Web Start is not
        in charge of the launch. In fact, my point earlier was to say that it is
        directly in charge. I was explaining that this does not involve the app
        client container or the Java Web Start launch of the app client container, and
        so is not point to something being wrong in the app client container component
        as originally assigned.

        Marina's point about which class loader javax.persistence.Persistence uses for
        loading is well taken. I was still thinking in terms of the solution to the
        problem we saw with TopLinkEssentials. Lance's problem may have similar causes
        but i is not exactly the same situation (because TLE is not involved in this
        stack trace.) Sorry about confusing things.

        Lance, by any chance have you tried with with other earlier Java SE releases
        such as 1.6.0 or 1.5.x? If so, did you get the same results?

        Show
        Tim Quinn added a comment - Just to clarify one thing. I did not mean to claim that Java Web Start is not in charge of the launch. In fact, my point earlier was to say that it is directly in charge. I was explaining that this does not involve the app client container or the Java Web Start launch of the app client container, and so is not point to something being wrong in the app client container component as originally assigned. Marina's point about which class loader javax.persistence.Persistence uses for loading is well taken. I was still thinking in terms of the solution to the problem we saw with TopLinkEssentials. Lance's problem may have similar causes but i is not exactly the same situation (because TLE is not involved in this stack trace.) Sorry about confusing things. Lance, by any chance have you tried with with other earlier Java SE releases such as 1.6.0 or 1.5.x? If so, did you get the same results?
        Hide
        lancea added a comment -

        Hi Tim,

        I am currently using Java SE 6 Update1. I saw the same problem with J2SE 5
        update 10.

        The results are the same. The program i provided for the repro is extremely
        trivial in the zip bundle.

        Show
        lancea added a comment - Hi Tim, I am currently using Java SE 6 Update1. I saw the same problem with J2SE 5 update 10. The results are the same. The program i provided for the repro is extremely trivial in the zip bundle.
        Hide
        marina vatkina added a comment -

        Lance,

        It seems like a user error to me. So far I tried to run as (no NetBeans in the
        picture):
        %<dir>/JPAWebStart/dist java -jar JPAWebStart.jar

        and it failed with "No Persistence provider for EntityManager named DJPU".

        Notice that it's not the PU name that is specified in the persistence.xml and
        the source. When I recompiled the SimpleTableDemo.java and repackaged it into
        the jar, it just worked.

        Yes, your error message prints the expected PU name, but may be that was not
        what was there in the persistence.xml.

        Can you please double check everything and make sure that you don't have another
        version of META-INF/persistence.xml in your classpath.

        Show
        marina vatkina added a comment - Lance, It seems like a user error to me. So far I tried to run as (no NetBeans in the picture): %<dir>/JPAWebStart/dist java -jar JPAWebStart.jar and it failed with "No Persistence provider for EntityManager named DJPU". Notice that it's not the PU name that is specified in the persistence.xml and the source. When I recompiled the SimpleTableDemo.java and repackaged it into the jar, it just worked. Yes, your error message prints the expected PU name, but may be that was not what was there in the persistence.xml. Can you please double check everything and make sure that you don't have another version of META-INF/persistence.xml in your classpath.
        Hide
        marina vatkina added a comment -

        I meant of cource <dir>/JPAWebStart/dist% java -jar JPAWebStart.jar

        Show
        marina vatkina added a comment - I meant of cource <dir>/JPAWebStart/dist% java -jar JPAWebStart.jar
        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: