Topic
10 replies Latest Post - ‏2010-12-17T17:36:40Z by sutter
YarlagaddaRajesh
YarlagaddaRajesh
3 Posts
ACCEPTED ANSWER

Pinned topic Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

‏2010-12-11T08:49:56Z |
Hi,

I am working with EJB3.0 on WAS7 with Apache OpenJPA1.2.3.

is there any differences in unidirectional one to many assosiations from toplink to OpenJPA.

why because earlier we worked with EJB3.0 on Glassfish with Toplink. Now, we are moving the appication to WAS7.

WAS7 supports ApacheOpenJPA as JPA for transactions.

we face the issue now on WAS7 with unidirectional one to many mappings not picking data from database. throwing PersistenceException and UnsupportedException with openjpa1.2.3

how to take care of these things from application end. Why because, we are not able to do configurations on serverside.

i go through some discussions " http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.zseries.doc/info/zseries/ae/tejb_configpp.html " specifying serverside configurations.

please reply me.

Thanks in Advance,
Rajesh Yarlagadda
Updated on 2010-12-17T17:36:40Z at 2010-12-17T17:36:40Z by sutter
  • sutter
    sutter
    94 Posts
    ACCEPTED ANSWER

    Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

    ‏2010-12-13T16:15:19Z  in response to YarlagaddaRajesh
    Hi Rajesh Yarlagadda,
    I am not aware of any issues with OpenJPA's unidirectional one-to-many relationship processing. Can you provide additional detail on the scenario and the problems you are experiencing? Are you using application-managed or container-managed persistence? If your application executes as expected with TopLink, is that a stand-alone JSE application, or are you configuring WebSphere to use TopLink as your JPA provider? What type of enhancement processing [1] are you using? If you are using container-managed persistence, then letting the container classloader invoke the enhancement processing is probably the best way to go. If using application-managed, then using either build-time or the javaagent approach would be good.

    Also, if you can provide your persistence.xml as well as your Entity definitions, that information would help. As well as more information on the specific exceptions and call stacks.

    Thanks,
    Kevin

    [1] http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
    • YarlagaddaRajesh
      YarlagaddaRajesh
      3 Posts
      ACCEPTED ANSWER

      Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

      ‏2010-12-14T06:15:45Z  in response to sutter
      Hi,

      i am working on EJB3.0 and OpenJPA1.2.3 version on WAS7.
      we are using container mangaed transactions.Earlier we use glassfish as application server and toplink is default for glassfish to do EJB managed transactions. Now we are moving to WAS7 with OpenJPA.

      this is not a enhacement type we're doing migration from glassfish to WAS7.

      when we move from toplink in glassfish to OpenJPA in WAS7 these mappings are not supporting throwing
      12/9/10 9:00:06:068 CST 00000018 BusinessExcep E CNTR0020E:
      EJB threw an unexpected (non-declared) exception during invocation of method "stateExists" on bean "BeanId(lmt-33171#LLMT-ejb.jar#LocStateFacade, null)".

      Exception data: <openjpa-1.2.3-SNAPSHOT-r422266:965640 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:

      An error occurred while parsing the query filter 'SELECT o FROM LocState o where o.deleted = false and o.country.id = 88 AND UPPER(o.name) = 'KARAMCHEDU'.

      Error message: org.apache.openjpa.kernel.jpql.TokenMgrError: Lexical error at line 1, column 93. Encountered: "\"" (34), after : ""

      12/9/10 0:51:13:407 CST 00000016 RegisteredSyn E WTRN0074E: Exception caught from after_completion synchronization operation: <openjpa-1.2.3-SNAPSHOT-r422266:965640 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null

      i tried mapping like this

      @OneToMany(cascade ={CascadeType.ALL}) or

      @OneToMany(mappedBy="roomConfigurations", cascade ={CascadeType.ALL}) or

      @OneToMany(targetEntity="RoomConfiguration.class", cascade ={CascadeType.ALL})
      @JoinTable
      (
      name="ROOM_ROOMCONFIGURATION",
      joinColumns={ @JoinColumn(name="ROOM_ID", referencedColumnName="ROOM_ID") },
      inverseJoinColumns={ @JoinColumn(name="ROOMCONFIGURATIONS_ID", referencedColumnName="ROOMCONFIGURATIONS_ID") }
      )
      @OneToMany(cascade ={CascadeType.ALL})
      @AssociationTable(
      table=@Table(name=” ROOM_ROOMCONFIGURATION”),
      joinColumns=
      @JoinColumn(name=" ROOM_ID ", referencedColumnName=" ROOM_ID "),
      inverseJoinColumns=
      @JoinColumn(name=" ROOMCONFIGURATIONS_ID ", referencedColumnName=" ROOMCONFIGURATIONS_ID ")
      )

      suggest me to do changes that are required either in server side or applications side.
      • sutter
        sutter
        94 Posts
        ACCEPTED ANSWER

        Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

        ‏2010-12-14T15:13:19Z  in response to YarlagaddaRajesh
        Okay, let's focus on the error being reported. I don't think you have a problem with your mappings. I would suggest reverting them back to what you had originally with TopLink (it's actually EclipseLink that is shipped with Glassfish).

        The error being reported is as follows:

        >
        > Exception data: <openjpa-1.2.3-SNAPSHOT-r422266:965640 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
        >
        > An error occurred while parsing the query filter 'SELECT o FROM LocState o where o.deleted = false and o.country.id = 88 AND UPPER(o.name) = 'KARAMCHEDU'.
        >
        > Error message: org.apache.openjpa.kernel.jpql.TokenMgrError: Lexical error at line 1, column 93. Encountered: "\"" (34), after : ""
        >

        This would indicate a potential problem with the JPQL statements in your application. Although the error message shows single quotes, is there any chance that the JPQL in your code has double quotes (") around the KARAMCHEDU literal?

        Technically, JPQL only allows single quotes for their literals. Double quotes will not parse correctly due to the syntax defined by the JPA specification.

        Due to other JPA providers allowing double quotes, OpenJPA has recently been updated [1] to support double quotes. But, this was in the 2.0.x stream, not the 1.2.x stream that you are using.

        I would suggest changing your JPQL statements to use single quotes to get around this problem. If you feel that the support for double quotes is a requirement, then you will have to raise that issue with WebSphere support (via the PMR process). The easiest path will be to use single quotes instead.

        Hope this helps,
        Kevin

        [1] https://issues.apache.org/jira/browse/OPENJPA-1782
        • YarlagaddaRajesh
          YarlagaddaRajesh
          3 Posts
          ACCEPTED ANSWER

          Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

          ‏2010-12-15T12:00:09Z  in response to sutter
          hi,

          I tried by placing double quotes it was also throwing same exception.

          I used to use Glassfish with Toplink and everything was fine. only problem is, WAS uses openJPA. Not a problem I thought, maybe a couple of changes but shouldn't be an issue.

          Well a week later and I've gotten knowhere! I can not for the life of me see why my app refuses to insert new rows into tables throws PersistenceException : null

          If WAS suppports toplink that would be great, as I don't care what JPA source I use as long as it's working

          Do you know where I can find an example of WAS using toplink as I think WAS is built on openJPA so I guess there's some work to do to get it working, or should it just work?

          If i have to move on OpenJPA, which level is enough to do changes in my application either at Query level or at mapping level?

          Thanks in Advance,
          Rajesh Yarlagadda
          • sutter
            sutter
            94 Posts
            ACCEPTED ANSWER

            Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

            ‏2010-12-15T14:20:49Z  in response to YarlagaddaRajesh
            Hi Rajesh Yarlagadda,

            >
            > I tried by placing double quotes it was also throwing same exception.
            >
            I think you misunderstood my reply. From the error message, it looked like you were already using double quotes, which is not supported in the version of OpenJPA that you are using. I asked you to try using single quotes. From this reply, it sounds like you have tried both types of quotes with no success.

            Based on your previous forum postings, the problem does seem to focused on your JPQL statements. The JPQL parser is not liking something about your "KARAMCHEDU" literal. That's where column 93 starts and that's what the exception text is pointing at, so that's where I would focus your efforts.

            Personally, at this point, I would open a PMR for this problem. Everything that you have described should be working just fine. I know of no problems with the scenario you have described. This would lead me to believe that you have some type of environment or coding issue (entity definition, persistence unit definition, JPQL definition, classpath issue, etc). By opening a PMR, the support teams will be better equipped to help debug the problem.

            >
            > If WAS suppports toplink that would be great, as I don't care what JPA source I use as long as it's working
            >
            WebSphere can support the use of alternate JPA providers. It's part of the Java EE contracts to support alternate JPA providers. WebSphere does support and ship Apache OpenJPA. If you want to plug in an alternate provider, you can follow these instructions [1]. Be aware that the IBM support does stop at the plug point for the alternate provider. So, any problems found with TopLink and/or EclipseLink will have to be worked through their support channels, not IBM's.

            [1] http://publib.boulder.ibm.com/infocenter/wasinfo/fep/topic/com.ibm.websphere.jpafep.multiplatform.doc/info/ae/ae/tejb_jpa3rdparty.html

            >
            > If i have to move on OpenJPA, which level is enough to do changes in my application either at Query level or at mapping level?
            >
            It looks like you are currently using the proper level of OpenJPA for the WAS v7 environment. I believe the latest fixpack for WAS v7 is 7.0.0.13. That would contain the latest and greatest version of OpenJPA that is supported on the base WAS v7.

            If you want to move up to the JPA 2.0 level of functionality, then you should get the OSGi/JPA 2.0 Feature Pack for WAS v7 [2]. As long as you have a license for WAS v7, this feature pack is free to download and install. This feature pack contains the OpenJPA 2.0.x service stream.

            [2] http://www-01.ibm.com/software/webservers/appserv/was/featurepacks/osgi/

            Either of these versions should work for the scenarios that you have described.

            Good luck,
            Kevin
            • nchanilk
              nchanilk
              2 Posts
              ACCEPTED ANSWER

              Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

              ‏2010-12-15T20:25:09Z  in response to sutter
              Hi Sutter,

              Thank you very much for your reply.

              We tried the approach option (1) which you have suggested. But we are experiencing the problems on getting EnitityManager. EntityManager always returns the null value. When we look at the log file, we found the below log trace.

              "JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManagerFactory factory for the llmt-ejbPU persistent unit from the oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider provider in jar:file:/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/ccit-vm-01Node01Cell/LLMT.ear/LLMT-ejb.jar!/ module."

              llmt-ejbPU: is our persistance Unit
              LLMT-ejb.jar: is having our application entities and persistance.xml.

              We have also tried by configuring Hibernate as a service provider but we still face the same issue.

              Please find the below work log which we have done for third party provider.
              1. Added <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider> in persistance.xml file ( also tried with the "oracle.toplink.essentials.PersistenceProvider")
              2. Added the required information in META-INF file. (Provider information)
              3. Added the toplink-essentials.jar file into the ear file lib folder. ( tried by placin the jar file in lmt.ear/lib/,lmt.ear/LLMT-ejb/jar/lib,lmt.ear/LLMT-web.jar/WEB-INF/lib folders, but none of them works.
              4. We are having parent_last enabled on server, our application libraries load first and then it will load the server libraries.

              Option(2): we are trying to get help from the Admin team to see how we can update the common platform with the fixpacks. But we want to achieve by changing the JPA provider to toplink rather than upgrading the system.

              We want to check on the below.
              1. Do we need to do any plugin installation? profile configuration on server for third party JPA providers?(Any way we are not allowed to do on the common platform, just want to get the confirmation on this)
              2. We cannot place the third party libraries into our common global WAS7 server, Is there any way we can achieve this by modifying our application ear file.
              3. Is "oneToMany", Object related quries will work as we expetcted in the manner of TopLink in openJPA2.0?

              It would be really greate if you help us in resolving this issue.
              Once again thank you so much for helping us on this.

              Regards,
              Anil
              • sutter
                sutter
                94 Posts
                ACCEPTED ANSWER

                Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

                ‏2010-12-15T21:08:04Z  in response to nchanilk
                Hi nchanilk,
                I don't have any personal experience with using EclipseLink in a WebSphere environment (you have to realize that my focus is on OpenJPA). But, maybe this link will help. This is a presentation that describes how to utilize the Hibernate JPA provider as an alternate provider. Although the specific packaging of the Hibernate JPA provider (ie. jar files) is different from EclipseLink, the same concepts would apply.

                https://www.ibm.com/developerworks/mydeveloperworks/wikis/form/anonymous/api/library/53181ccd-bcd4-431f-b968-0b5f6d46d652/document/192a432b-28bb-4080-b037-345e5d83da76/attachment/61e74f67-1d60-4120-ba25-ad7264c9f4f6/media/AlternateJPAProviders_TestReport.pdf

                Concerning the error message:
                > "JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManagerFactory factory for the llmt-ejbPU persistent unit from the oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider provider in jar:file:/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/ccit-vm-01Node01Cell/LLMT.ear/LLMT-ejb.jar!/ module."

                Doesn't EclipseLink have some tracing or debug information that you can turn on to get more information why this Provider could not be utilized? It sounds like the server is finding the provider and calling out to it, but the EMF can not be created...

                > 3. Added the toplink-essentials.jar file into the ear file lib folder. ( tried by placin the jar file in lmt.ear/lib/,lmt.ear/LLMT-ejb/jar/lib,lmt.ear/LLMT-web.jar/WEB-INF/lib folders, but none of them works.

                I would try using the shared library approach as documented in the presentation above.

                > 3. Is "oneToMany", Object related quries will work as we expetcted in the manner of TopLink in openJPA2.0?

                OneToMany relationships should work just fine with either version of OpenJPA -- 1.2.x or 2.0.x. Your scenario sounds simple enough.

                At this point, I would recommend the PMR route. It sounds like some tracing and/or debugging of your environment is going to be required to get to the bottom of these problems. Whether you stick with the WebSphere JPA solution, or if you try to get EclipseLink to work.

                Good luck,
                Kevin
                • nchanilk
                  nchanilk
                  2 Posts
                  ACCEPTED ANSWER

                  Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

                  ‏2010-12-15T21:46:38Z  in response to sutter
                  Hi Suttler,

                  Thank you very much for your quick response.

                  1. "https://www.ibm.com/developerworks/mydeveloperworks/wikis/form/anonymous/api/library/53181ccd-bcd4-431f-b968-0b5f6d46d652/document/192a432b-28bb-4080-b037-345e5d83da76/attachment/61e74f67-1d60-4120-ba25-ad7264c9f4f6/media/AlternateJPAProviders_TestReport.pdf"

                  Even though we want to have top link essentials as a provider, But we have tried configuring Hibernate as a provider to see whether third party provider configuration is possible or not. I forgot to mention that i followed the document from the above url to configure Hibernate provider with the shared library path on local environment and got the same "EMF can not be created message.."
                  2. "Doesn't Eclipse Link have some tracing or debug information that you can turn on to get more information why this Provider could not be utilized?"

                  Unfortunately the more tracing is not possible in top link, because it is a third party component.

                  3. "OneToMany relations should work just fine with either version of OpenJPA -- 1.2.x or 2.0.x. Your scenario sounds simple enough."

                  The OnetoMany relations are not working as expected in openJPA1.2.2. In our relations we are having multiple relations across the tables in Schema.
                  ex: a sample scenario
                  In Table A "ID" is a primary key which is mapped to Table B "ID_1" column foreignKey
                  In Table C "ID" is a primary key which is mapped to Table B "ID_2" column foreign key (table B ID_1,ID_2 are having the composite primaryKey). This is the sample scenario like this we are having interdependency across most of the tables.
                  Now in TableA entity class we want to declare
                  @OneToMany
                  public List<TableC> tableCValues; But it returns the null values. But In top link it returns the expected List of values. ( We have tried all OneToMany options which was provided by Rajesh in the earlier posts).
                  Can you please help us in understanding more on PMR route to proceed further.

                  Regards,
                  Anil
                  • sutter
                    sutter
                    94 Posts
                    ACCEPTED ANSWER

                    Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

                    ‏2010-12-15T22:18:41Z  in response to nchanilk
                    Hi Anil,
                    I'm sorry that you are still experiencing problems. Even though you think there is problem with the OneToMany, the error messages that were posted earlier pointed out a problem with the JPQL syntax that was being used. If the query is not being parsed correctly, then the results will be null.

                    > Unfortunately the more tracing is not possible in top link, because it is a third party component.
                    But, EclipseLink still has tracing capabilities. Even if it doesn't mesh with the WebSphere trace logs, you could look at the trace from EclipseLink that should show errors.

                    > Can you please help us in understanding more on PMR route to proceed further.
                    http://www-947.ibm.com/support/entry/portal/Overview/Software/WebSphere/WebSphere_Application_Server

                    By opening a PMR, then the appropriate support personnel will get involved to help decipher and debug your situation. And, if a problem is discovered with OpenJPA, then a fix can be provided through the WebSphere support mechanism.

                    Kevin
                    • sutter
                      sutter
                      94 Posts
                      ACCEPTED ANSWER

                      Re: Urgent Solution for OpenJPA1.2.3 on WAS7 with EJB3.0

                      ‏2010-12-17T17:36:40Z  in response to sutter
                      Hi Anil,
                      I just debugged another situation on the Apache OpenJPA forums that might be related to your scenario...

                      A uni-directional OneToMany with a Foreign Key scenario was not working like TopLink's implementation. Is that what you are attempting to use? In this case, I reproduced the problem when using a 1.0 version of the persistence.xml header (vs 2.0 version). The support for FK's in this type of relationship mapping was new for 2.0. And, in order to be backward-compliant with the TCK, we had to issue an error message if this was attempted with a 1.0 version. Not sure if this applies to your scenario, but I thought I would give you a pointer to the JIRA:

                      https://issues.apache.org/jira/browse/OPENJPA-1607

                      Kevin