@OrderBy causing org.hibernate.HibernateException: Unable to parse order-by fragment

后端 未结 3 1986
天命终不由人
天命终不由人 2020-12-18 00:13

I added a @OrderBy on my project and now i\'m getting the following error:

17:10:35,125 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 51)          


        
相关标签:
3条回答
  • 2020-12-18 00:18

    First at all, about the workaround, take into account that the hibernate-core version you are using is 4.3 (as you can see in the error's stacktrace) not the 4.0.1.

    In the simplest scenario, the workaround means that your app includes an antlr's jar. By default, the module org.hibernate that Wildfly AS loads cause the loading of the org.antlr module's jars. The explicit dependecy doesn't appear in your pom so maybe it is implicit referenced by another dependecy or the jar is already in the app's project and then packaged within.

    I think you should review and fix the dependencies and/or clean the jars archives but if you really can't do it I suggest you to try to exclude the antlr module using the corresponding deployment descriptor that you will must package into your app. Sorry I don't have any example of descriptor to show you right now. Read this and this doc to know how to write it and to learn about classloading and Jboss AS modules dependencies. Don't worry about the AS version referenced in these links, respect of this issue applies pretty much the same.

    Improve: To find out which dependency includes antlr you can use maven dependecy plugin. I run this command line on your list of dependecies:

    mvn dependency:tree -Dincludes=antlr

    The output is:

    [INFO] \- org.hibernate:hibernate-infinispan:jar:4.2.1.Final:compile
    [INFO]    \- org.hibernate:hibernate-core:jar:4.2.1.Final:compile
    [INFO]       \- antlr:antlr:jar:2.7.7:compile
    

    I am guessing but you are packaging your web application within the dependencies you list, because there is not parent pom or referenced bom that set scope other than compile. In that case it is really a mess, I suggest to you to use Wildfly BOMs to resolve the version of the dependencies that you app needs (read about here and here to know how to use/add it) and begin for setting scope provided to all dependencies that Wildfly provides (so they are listed in the BOM). Next, maybe you need to declare explicit reference to some Wildfly's module to include the jars/dependencies in your classpath's app that aren't includes automatically or by default, but I thinks it is for another question.

    About the workaround, in your case you should add something like this (according to the pom of Wildfly project) to exclude the antlr jar, and probably something else is missing too.

    <dependency>
      <groupId>org.picketbox</groupId>
      <artifactId>picketbox-infinispan</artifactId>
      <version>4.0.21.Final</version>
      <exclusions>
        <exclusion>
          <groupId>org.picketbox</groupId>
          <artifactId>picketbox-spi-bare</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.picketbox</groupId>
          <artifactId>jbosssx-bare</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.jboss.logging</groupId>
          <artifactId>jboss-logging-spi</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.infinispan</groupId>
          <artifactId>infinispan-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-infinispan</artifactId>
      <version>4.2.1.Final</version>
      <exclusions>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    0 讨论(0)
  • 2020-12-18 00:34

    Got the same issue while deploying the web application in JBOSS EAP 6 and fixed it adding antr dependency with the provided scope at the root level.

    <dependency>
       <groupId>antlr</groupId>
       <artifactId>antlr</artifactId>
       <scope>provided</scope>
    </dependency>
    
    0 讨论(0)
  • 2020-12-18 00:41

    After several attempts with exclusions, I solved adding

    -DANTLR_USE_DIRECT_CLASS_LOADING=true
    

    to JAVA_OPTS in JBoss launching script as suggested here.

    0 讨论(0)
提交回复
热议问题