WebSphere Application Server & Liberty

 View Only
Expand all | Collapse all

EclipseLink Named Query Parameter is not recognized in WAS 9.0.5.12

  • 1.  EclipseLink Named Query Parameter is not recognized in WAS 9.0.5.12

    Posted Tue November 22, 2022 05:29 AM
    Hello

    We are trying to migrate to EclipseLink from Apache OpenJPA. We have used our Eclipselink jar (V2.5.2) in classpath and Shared Library. However while executing the application it is referring the eclipselink jar in the Websphere "C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.jpa.eclipselink.jar".

    And the JPA Named Query parameter is not getting recognized and throwing the following exception. Appreciate any help. Thanks.

    [22/11/22 15:49:06:990 IST] 000000d4 MDBListenerIm I WMSG0042I: MDB Listener FCInvCoaM4PListenerPort started successfully for JMSDestination jms/GCPS.BPFCINV.PROCESS.INT.RESPONSE
    [22/11/22 15:49:09:520 IST] 000000db SystemOut O 2022-11-22 15:49:09,520 MessageListenerThreadPool : 0 DEBUG AsyncLogger.ThreadNameStrategy=UNCACHED (user specified null, default is UNCACHED)
    [22/11/22 15:49:09:520 IST] 000000db SystemOut O 2022-11-22 15:49:09,520 MessageListenerThreadPool : 0 DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
    [22/11/22 15:49:10:959 IST] 000000db LocalExceptio E CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "onMessage". Exception data: javax.ejb.EJBException: MDB PostConstruct failure; nested exception is: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/domainContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-28017] (Eclipse Persistence Services - 2.6.9.WAS-v20211116-c34c592f4a): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Unable to predeploy PersistenceUnit [GCPS_JPA] in invalid state [DeployFailed].
    Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.9.WAS-v20211116-c34c592f4a): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Deployment of PersistenceUnit [GCPS_JPA] failed. Close all factories for this PersistenceUnit.
    Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.9.WAS-v20211116-c34c592f4a): org.eclipse.persistence.exceptions.JPQLException
    Exception Description: Syntax error parsing [SELECT c.id.systemValue FROM SystemConfig c WHERE c.id.countryCode = :countryCode AND c.id.systemArea = :systemArea AND c.id.systemField = :systemField AND c.activeFlag = 'Y'].
    [69, 82] The identification variable ' :countryCode' is not following the rules for a Java identifier.
    [140, 153] The identification variable ' :systemField' is not following the rules for a Java identifier.
    at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:503)
    at com.ibm.ejs.container.MessageDrivenBeanO.initialize(MessageDrivenBeanO.java:259)
    at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:105)
    at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:982)
    at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1084)
    at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:63)
    at com.ibm.ejs.container.activator.Activator.preInvokeActivateBean(Activator.java:264)
    at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3242)
    at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:2579)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:89)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:601)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1909)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/domainContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-28017] (Eclipse Persistence Services - 2.6.9.WAS-v20211116-c34c592f4a): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Unable to predeploy PersistenceUnit [GCPS_JPA] in invalid state [DeployFailed].
    Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.9.WAS-v20211116-c34c592f4a): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Deployment of PersistenceUnit [GCPS_JPA] failed. Close all factories for this PersistenceUnit.

    ------------------------------
    PRABA RAMASAMY
    ------------------------------


  • 2.  RE: EclipseLink Named Query Parameter is not recognized in WAS 9.0.5.12

    Posted Wed November 30, 2022 04:29 PM
    Hello!

    At first, I couldn't understand why this is failing. There isn't anything obviously wrong with the query and I could not reproduce the failure with a simple test that I wrote. However, I was finally able to reproduce the failure and figured out why this is failing. I was only able to reproduce the failure after I copy/paste the SQL string from the error message pasted above!

    First, let's look at the String in the error message:
    ```
    Syntax error parsing [SELECT c.id.systemValue FROM SystemConfig c WHERE c.id.countryCode = :countryCode AND c.id.systemArea = :systemArea AND c.id.systemField = :systemField AND c.activeFlag = 'Y']
    ```

    What isn't obvious is that some of the spaces in this string are not actually spaces! I mean, they are spaces, but some of those characters are actually non-breaking spaces. This becomes more obvious if we convert this String (which EclipseLink prints literally) to Hex values:

    [0053, 0045, 004c, 0045, 0043, 0054, 0020, 0063, 002e, 0069, 0064, 002e, 0073, 0079, 0073, 0074, 0065, 006d, 0056, 0061, 006c, 0075, 0065, 0020, 0046, 0052, 004f, 004d, 0020, 0053, 0079, 0073, 0074, 0065, 006d, 0043, 006f, 006e, 0066, 0069, 0067, 0020, 0063, 0020, 0057, 0048, 0045, 0052, 0045, 0020, 0063, 002e, 0069, 0064, 002e, 0063, 006f, 0075, 006e, 0074, 0072, 0079, 0043, 006f, 0064, 0065, 0020, 003d, 00a0, 003a, 0063, 006f, 0075, 006e, 0074, 0072, 0079, 0043, 006f, 0064, 0065, 0020, 0041, 004e, 0044, 0020, 0063, 002e, 0069, 0064, 002e, 0073, 0079, 0073, 0074, 0065, 006d, 0041, 0072, 0065, 0061, 0020, 003d, 0020, 003a, 0073, 0079, 0073, 0074, 0065, 006d, 0041, 0072, 0065, 0061, 0020, 0041, 004e, 0044, 0020, 0063, 002e, 0069, 0064, 002e, 0073, 0079, 0073, 0074, 0065, 006d, 0046, 0069, 0065, 006c, 0064, 0020, 003d, 00a0, 003a, 0073, 0079, 0073, 0074, 0065, 006d, 0046, 0069, 0065, 006c, 0064, 0020, 0041, 004e, 0044, 0020, 0063, 002e, 0061, 0063, 0074, 0069, 0076, 0065, 0046, 006c, 0061, 0067, 0020, 003d, 0020, 0027, 0059, 0027]

    The Hex value "0020" denotes a regular space character. The odd Hex values you can find in this array are "00a0". These "00a0" values are the non-breaking spaces.

    The reason this is important is because EclipseLink uses "Character.isWhitespace"(https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isWhitespace(char)) to determine if a character in the string is whitespace. According to the documentation, "Character.isWhitespace()" does not recognize non-breaking spaces as "whitespace". This is messing up the parsing of this query string and causing the failure.

    Replacing these non-breaking space characters with space characters resolved the issue for me locally. There maybe support delivered in the future to EclipseLink to support extended ASCII character sets, however that would need to be delivered as a much larger feature support I think. For now, simply removing the offending characters from the string will simply resolve the issue.

    ------------------------------
    Will DAZEY
    ------------------------------