You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jens Leisenberg (JIRA)" <ji...@apache.org> on 2012/07/09 21:25:33 UTC

[jira] [Created] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Jens Leisenberg created OPENJPA-2227:
----------------------------------------

             Summary: OpenJPA doesn't find custom SequenceGenerators
                 Key: OPENJPA-2227
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 2.2.0, 2.1.0, 2.0.0
         Environment: WebSphere Application Server V8.0 and V8.5
            Reporter: Jens Leisenberg
            Priority: Blocker
         Attachments: ClassNotFoundException.txt

I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).

When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.

ExampleConfiguration:
{code}
@Entity
@SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
public class Customer implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
    private long id;
{code}

The example will produce the stacktrace attached.

It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.

I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jody Grassel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jody Grassel reassigned OPENJPA-2227:
-------------------------------------

    Assignee: Jody Grassel
    
> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Assignee: Jody Grassel
>            Priority: Blocker
>         Attachments: ClassNotFoundException.txt
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jody Grassel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jody Grassel resolved OPENJPA-2227.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2.1
                   2.3.0
                   2.1.2
    
> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Assignee: Jody Grassel
>            Priority: Blocker
>             Fix For: 2.1.2, 2.3.0, 2.2.1
>
>         Attachments: ClassNotFoundException.txt, OPENJPA-2227-2.2.x.patch
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jody Grassel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13419586#comment-13419586 ] 

Jody Grassel commented on OPENJPA-2227:
---------------------------------------

This problem doesn't show up in the JSE (which likely applies to JUnits) environment because the application ClassLoader would be the ClassLoader responsible for loading both the OpenJPA and JUnit/JSE application classes.  In a JEE environment, you have a hierarchy of ClassLoaders - in the WebSphere case, OpenJPA would be loaded by one of the OSGi ClassLoaders, application code lives in Application ClassLoaders which are children of the OSGi ClassLoaders.

When SequenceMetaData initializes, it attempts to perform a Class.forName() lookup for the class denoted in the sequenceName entry.  However, it scopes the lookup to the ClassLoader responsible for loading the OpenJPA classes, so it would never be able to check child ClassLoaders for application-custom SequenceGenerators.

Curiously, the SequenceMetaData.instantiate() method takes a ClassLoader envLoader argument (which, tracking back a couple frames in the stack trace, originates with a call to StoreContext.getClassloader() -- which returns the Thread Context ClassLoader that was current when the StoreContext was created.)  A modification to instantiate() to first perform the original Class.forName() lookup, falling back to a Class.forName() lookup using envLoader if the first call results in a ClassNotFoundException seems to resolve the issue in my test environment.
                
> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Assignee: Jody Grassel
>            Priority: Blocker
>         Attachments: ClassNotFoundException.txt
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jens Leisenberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Leisenberg updated OPENJPA-2227:
-------------------------------------

    Attachment: ClassNotFoundException.txt
    
> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Priority: Blocker
>         Attachments: ClassNotFoundException.txt
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jody Grassel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jody Grassel updated OPENJPA-2227:
----------------------------------

    Attachment: OPENJPA-2227-2.2.x.patch

Uploaded copy of the patch for 2.2.x, as integration for this branch needs to be delayed.
                
> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Assignee: Jody Grassel
>            Priority: Blocker
>         Attachments: ClassNotFoundException.txt, OPENJPA-2227-2.2.x.patch
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Work started] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jody Grassel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on OPENJPA-2227 started by Jody Grassel.

> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Assignee: Jody Grassel
>            Priority: Blocker
>         Attachments: ClassNotFoundException.txt
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (OPENJPA-2227) OpenJPA doesn't find custom SequenceGenerators

Posted by "Jody Grassel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jody Grassel closed OPENJPA-2227.
---------------------------------

    
> OpenJPA doesn't find custom SequenceGenerators
> ----------------------------------------------
>
>                 Key: OPENJPA-2227
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2227
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>         Environment: WebSphere Application Server V8.0 and V8.5
>            Reporter: Jens Leisenberg
>            Assignee: Jody Grassel
>            Priority: Blocker
>             Fix For: 2.1.2, 2.3.0, 2.2.1
>
>         Attachments: ClassNotFoundException.txt, OPENJPA-2227-2.2.x.patch
>
>
> I'm trying to use a custom SequenceGenerator within an enterprise application using openJPA (providing by WebSphere).
> When defining a custom Sequence a ClassNotFoundException (for the Sequence class) will be thrown when trying to insert data into the database.
> ExampleConfiguration:
> {code}
> @Entity
> @SequenceGenerator(name="MySequence", sequenceName="org.apache.openjpa.generator.UIDGenerator()")
> public class Customer implements Serializable {
>     @Id
>     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="MySequence")
>     private long id;
> {code}
> The example will produce the stacktrace attached.
> It seems that the wrong class loader is used to instantiate the custom sequence class. A very similar issue seems to be: OPENJPA-758. With JavaSE (JUnit) all is working fine, but after deploying into WAS the Exception will occur.
> I think within the method SequenceMetaData.instantiate(Classloader envLoader) the JavaTypes.classForName() -method with parameter mustExist=false should be used instead of the pure Class.forName() call. But I'm not sure about the Metadata-parameter needed for this method call.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira