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

后端 未结 3 1995
天命终不由人
天命终不由人 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.

    
      org.picketbox
      picketbox-infinispan
      4.0.21.Final
      
        
          org.picketbox
          picketbox-spi-bare
        
        
          org.picketbox
          jbosssx-bare
        
        
          org.jboss.logging
          jboss-logging-spi
        
        
          org.infinispan
          infinispan-core
        
      
    
    
    
      org.hibernate
      hibernate-infinispan
      4.2.1.Final
      
        
          org.hibernate
          hibernate-core
        
      
    
    

提交回复
热议问题