2015-08-28 55 views
4

我在JPA和Hibernate中很新颖,我试图在Spring MVC项目上使用@OrderBy注解运行在一个JBoss EAP 6.1+服务器上。@OrderBy导致java.lang.ClassCastException:antlr.CommonToken不能转换为antlr.Token

所以我会试着解释我的情况。

我有2个项目:第一个被命名为模型-GEN-wifipnsd,它仅包含模型类由代表Web应用程序的第二个项目(名为WIFIPNSD)使用。

1)因此,对于模型-GEN-wifipnsd我有这个的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>model-gen-wifipnsd</groupId> 
    <artifactId>model-gen-wifipnsd</artifactId> 
    <version>1.0</version> 
    <packaging>jar</packaging> 

    <dependencies>  
      <dependency> 
       <groupId>org.hibernate.javax.persistence</groupId> 
       <artifactId>hibernate-jpa-2.1-api</artifactId> 
       <version>1.0.0.Final</version> 
      </dependency>  
      <dependency> 
       <groupId>org.hibernate</groupId> 
       <artifactId>hibernate-core</artifactId> 
       <version>4.3.11.Final</version> 
      </dependency> 
      <dependency> 
       <groupId>org.springframework.data</groupId> 
       <artifactId>spring-data-jpa</artifactId> 
       <version>1.8.2.RELEASE</version> 
      </dependency> 
     </dependencies> 
</project> 

2),这是* **的pom.xml相关的文件wIFIPNSD Web应用程序项目:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>it.mycompany</groupId> 
    <artifactId>projectName</artifactId> 
    <name>GestioneUtenzeCloud</name> 
    <packaging>war</packaging> 
    <version>1.0.0-BUILD-SNAPSHOT</version> 
    <properties> 
     <java-version>1.7</java-version> 
     <org.springframework-version>4.1.7.RELEASE</org.springframework-version> 
     <org.aspectj-version>1.6.10</org.aspectj-version> 
     <org.slf4j-version>1.6.6</org.slf4j-version> 
     <spring-security.version>4.0.2.RELEASE</spring-security.version> 
    </properties> 
    <dependencies> 
     <!-- Spring --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${org.springframework-version}</version> 
      <exclusions> 
       <!-- Exclude Commons Logging in favor of SLF4j --> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 

     <!-- AspectJ --> 
     <dependency> 
      <groupId>org.aspectj</groupId> 
      <artifactId>aspectjrt</artifactId> 
      <version>${org.aspectj-version}</version> 
     </dependency> 

     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.15</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com.sun.jdmk</groupId> 
        <artifactId>jmxtools</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jmx</groupId> 
        <artifactId>jmxri</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>javax.jms</groupId> 
        <artifactId>jms</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

     <!-- @Inject --> 
     <dependency> 
      <groupId>javax.inject</groupId> 
      <artifactId>javax.inject</artifactId> 
      <version>1</version> 
     </dependency> 

     <!-- Servlet --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <!-- Test --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.7</version> 
      <scope>test</scope> 
     </dependency> 

     <!-- add --> 
     <dependency> 
      <groupId>org.apache.velocity</groupId> 
      <artifactId>velocity</artifactId> 
      <version>1.6.2</version> 
     </dependency> 
     <dependency> 
      <groupId>velocity-tools</groupId> 
      <artifactId>velocity-tools</artifactId> 
      <version>1.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>${spring-security.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-ldap</artifactId> 
      <version>${spring-security.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>${spring-security.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-taglibs</artifactId> 
      <version>${spring-security.version}</version> 
      <exclusions> 
       <exclusion> 
        <artifactId>spring-tx</artifactId> 
        <groupId>org.springframework</groupId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.ldap</groupId> 
      <artifactId>spring-ldap-core</artifactId> 
      <version>2.0.3.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context-support</artifactId> 
      <version>4.1.7.RELEASE</version> 
     </dependency> 
     <!-- <dependency> 
      <groupId>org.springframework.data</groupId> 
      <artifactId>spring-data-commons</artifactId> 
      <version>1.8.2.RELEASE</version> 
     </dependency>--> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>4.1.7.RELEASE</version> 
     </dependency> 
     <dependency> 
       <groupId>org.hibernate.javax.persistence</groupId> 
       <artifactId>hibernate-jpa-2.1-api</artifactId> 
       <version>1.0.0.Final</version> 
      </dependency>  
      <dependency> 
       <groupId>org.hibernate</groupId> 
       <artifactId>hibernate-core</artifactId> 
       <version>4.3.11.Final</version> 
      </dependency> 
      <dependency> 
       <groupId>org.springframework.data</groupId> 
       <artifactId>spring-data-jpa</artifactId> 
       <version>1.8.2.RELEASE</version> 
      </dependency> 
     <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>4.1.7.RELEASE</version> 
    </dependency> 
     <dependency> 
      <groupId>model-gen-wifipnsd</groupId> 
      <artifactId>model-gen-wifipnsd</artifactId> 
      <version>1.0</version>   
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>4.1.7.RELEASE</version> 
     </dependency> 

     <dependency> 
      <groupId>org.webjars</groupId> 
      <artifactId>webjars-locator</artifactId> 
      <version>0.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.webjars</groupId> 
      <artifactId>jquery</artifactId> 
      <version>2.0.3</version> 
     </dependency> 

     <dependency> 
      <groupId>org.webjars</groupId> 
      <artifactId>bootstrap</artifactId> 
      <version>3.0.0</version> 
     </dependency> 

    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-eclipse-plugin</artifactId> 
       <version>2.9</version> 
       <configuration> 
        <additionalProjectnatures> 
         <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
        </additionalProjectnatures> 
        <additionalBuildcommands> 
         <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
        </additionalBuildcommands> 
        <downloadSources>true</downloadSources> 
        <downloadJavadocs>true</downloadJavadocs> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.5.1</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArgument>-Xlint:all</compilerArgument> 
        <showWarnings>true</showWarnings> 
        <showDeprecation>true</showDeprecation> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.2.1</version> 
       <configuration> 
        <mainClass>org.test.int1.Main</mainClass> 
       </configuration> 
      </plugin> 

     </plugins> 
    </build> 
</project> 

好了,到模型类(内模型-GEN-wifipnsd项目)我已经绘制这个领域:

@OneToMany(fetch=FetchType.EAGER) 
@OrderBy("flgTipPrg") 
@JoinColumns({ 
    @JoinColumn(name="COD_MEC_ATT", referencedColumnName="COD_SCU_UT"), 
    @JoinColumn(name="DAT_ANN_SCO_ATT", referencedColumnName="DAT_ANN_SCO_RIL") 
    }) 
private List<Twp1007Progetto> twp1007Progettos; 

正如你可以看到我已经推杆的@OrderBy(“flgTipPrg”)根据定义为Twp1007Progetto模型类本场订购列表:

@Column(name="FLG_TIP_PRG") 
private String flgTipPrg; 

的问题是,使用这种@OrderBy( “flgTipPrg”)我得到这个异常:

10:26:17,279 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.serverManagement.controller.management.http: org.jboss.msc.service.StartException in service jboss.serverManagement.controller.management.http: Address already in use: bind localhost/127.0.0.1:9990 
    at org.jboss.as.server.mgmt.HttpManagementService.start(HttpManagementService.java:224) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14] 
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1] 
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25] 
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25] 
Caused by: java.net.BindException: Address already in use: bind 
    at sun.nio.ch.Net.bind0(Native Method) [rt.jar:1.8.0_25] 
    at sun.nio.ch.Net.bind(Net.java:436) [rt.jar:1.8.0_25] 
    at sun.nio.ch.Net.bind(Net.java:428) [rt.jar:1.8.0_25] 
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214) [rt.jar:1.8.0_25] 
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) [rt.jar:1.8.0_25] 
    at org.jboss.sun.net.httpserver.ServerImpl.<init>(ServerImpl.java:144) 
    at org.jboss.sun.net.httpserver.HttpServerImpl.<init>(HttpServerImpl.java:54) 
    at org.jboss.sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:38) 
    at org.jboss.com.sun.net.httpserver.HttpServer.create(HttpServer.java:147) 
    at org.jboss.as.domain.http.server.ManagementHttpServer.create(ManagementHttpServer.java:162) 
    at org.jboss.as.server.mgmt.HttpManagementService.start(HttpManagementService.java:190) [jboss-as-server-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14] 
    ... 5 more 

10:26:17,344 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 
10:26:18,479 ERROR [org.jboss.remoting.remote.connection] (Remoting "andreanobili:MANAGEMENT" read-1) JBREM000200: Remote connection failed: java.io.IOException: Connessione interrotta dal software del computer host 
10:26:18,488 ERROR [org.jboss.remoting.remote.connection] (Remoting "andreanobili:MANAGEMENT" read-1) JBREM000200: Remote connection failed: java.io.IOException: Connessione interrotta dal software del computer host 
10:26:19,092 WARN [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015960: Class Path entry activation.jar in /C:/Program Files (x86)/EAP-6.2.0/jboss-eap-6.2/standalone/deployments/WIFIPNSD.war/WEB-INF/lib/mail-1.4.jar does not point to a valid jar for a Class-Path reference. 
10:26:19,274 INFO [org.jboss.as.jpa] (MSC service thread 1-7) JBAS011401: Read persistence.xml for wifipnsdPU 
10:26:19,723 WARN [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause) 
10:26:19,723 WARN [org.jboss.as.ee] (MSC service thread 1-1) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause) 
10:26:19,818 WARN [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016012: Deployment deployment "WIFIPNSD.war" contains CDI annotations but beans.xml was not found. 
10:26:19,862 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 48) JBAS011402: Starting Persistence Unit Service 'WIFIPNSD.war#wifipnsdPU' 
10:26:19,999 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 48) HCANN000001: Hibernate Commons Annotations {4.0.1.Final-redhat-2} 
10:26:20,013 INFO [org.hibernate.Version] (ServerService Thread Pool -- 48) HHH000412: Hibernate Core {4.2.7.SP1-redhat-3} 
10:26:20,015 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 48) HHH000206: hibernate.properties not found 
10:26:20,019 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 48) HHH000021: Bytecode provider name : javassist 
10:26:20,037 INFO [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 48) HHH000204: Processing PersistenceUnitInfo [ 
    name: wifipnsdPU 
    ...] 
10:26:20,230 WARN [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (ServerService Thread Pool -- 48) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections 
10:26:20,253 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 48) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 
10:26:20,260 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (ServerService Thread Pool -- 48) HHH000422: Disabling contextual LOB creation as connection was null 
10:26:20,505 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (ServerService Thread Pool -- 48) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory 
10:26:20,510 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 48) HHH000397: Using ASTQueryTranslatorFactory 
10:26:20,552 INFO [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 48) HV000001: Hibernate Validator 4.3.1.Final-redhat-1 
10:26:21,387 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."WIFIPNSD.war#wifipnsdPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."WIFIPNSD.war#wifipnsdPU": javax.persistence.PersistenceException: [PersistenceUnit: wifipnsdPU] Unable to build EntityManagerFactory 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25] 
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25] 
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1] 
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: wifipnsdPU] Unable to build EntityManagerFactory 
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924) 
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) 
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76) 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14] 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14] 
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14] 
    ... 4 more 
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.collection.OneToManyPersister 
    at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:253) 
    at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:201) 
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:415) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1794) 
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) 
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) 
    ... 9 more 
Caused by: org.hibernate.HibernateException: Unable to parse order-by fragment 
    at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.translate(OrderByFragmentTranslator.java:69) 
    at org.hibernate.sql.Template.translateOrderBy(Template.java:721) 
    at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:561) 
    at org.hibernate.persister.collection.OneToManyPersister.<init>(OneToManyPersister.java:88) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_25] 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_25] 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_25] 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408) [rt.jar:1.8.0_25] 
    at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:231) 
    ... 14 more 
Caused by: java.lang.ClassCastException: antlr.CommonToken cannot be cast to antlr.Token 
    at antlr.CharScanner.makeToken(CharScanner.java:173) 
    at org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer.mIDENT(GeneratedOrderByLexer.java:239) 
    at org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer.nextToken(GeneratedOrderByLexer.java:139) 
    at antlr.TokenBuffer.fill(TokenBuffer.java:69) 
    at antlr.TokenBuffer.LA(TokenBuffer.java:80) 
    at antlr.LLkParser.LA(LLkParser.java:52) 
    at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.expression(GeneratedOrderByFragmentParser.java:565) 
    at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.sortKey(GeneratedOrderByFragmentParser.java:346) 
    at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.sortSpecification(GeneratedOrderByFragmentParser.java:241) 
    at org.hibernate.sql.ordering.antlr.GeneratedOrderByFragmentParser.orderByFragment(GeneratedOrderByFragmentParser.java:190) 
    at org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator.translate(OrderByFragmentTranslator.java:63) 
    ... 22 more 

10:26:21,847 INFO [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "WIFIPNSD.war" (runtime-name : "WIFIPNSD.war") 
10:26:21,850 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report 
JBAS014777: Services which failed to start:  service jboss.persistenceunit."WIFIPNSD.war#wifipnsdPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."WIFIPNSD.war#wifipnsdPU": javax.persistence.PersistenceException: [PersistenceUnit: wifipnsdPU] Unable to build EntityManagerFactory 
     service jboss.serverManagement.controller.management.http: org.jboss.msc.service.StartException in service jboss.serverManagement.controller.management.http: Address already in use: bind localhost/127.0.0.1:9990 

如果我删除@OrderBy(“flgTipPrg”)注释我没有例外,并且应用程序正确启动(但该列表未被排序)。

我该如何解决这个问题?从我所了解的在线阅读这个问题可能取决于这样的事实,即我可以在我的项目中有两个版本的antlr依赖项,但我绝对不确定这一点,我不知道如何解决它。

为什么?我错过了什么?我怎样才能解决这个问题?

+0

可能重复(http://stackoverflow.com/questions/29219543/orderby-causing-org-hibernate-hibernateexception-无法对解析顺序逐个FRAG) –

回答

4

有关于这个问题(例如this one)和错误很多问题,你应该,似乎由自动插入相关性造成的,ANTLR

尝试排除依赖在你的pom中添加的问题提出以上,所以:

<dependency> 
    ... 

    <exclusions> 
     <exclusion> 
     <groupId>antlr</groupId> 
     <artifactId>antlr</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
8

我不知道这是否是类似于你的情况,但我有类似的问题,而使用的WebLogic与它的功能称为部署计划。解决方案可以在antlr本身的Utils.class中找到。他们使用的方法getContextClassLoader:enter image description here

幸运的是在这个类我们将其禁用开关:enter image description here

您必须添加到应用服务器的JAVA_OPTS-DANTLR_USE_DIRECT_CLASS_LOADING=true 和解决问题应消失。

2

该修复程序正在使用@FilM​​iOs所说的系统属性(如果有足够的分数,我会对他的回复发表评论)。

无论如何,根本原因是线程类加载器和正常的类加载器指向不同的位置。正如这里所解释的:Difference between thread's context class loader and normal classloader

在我看来,在一个tomcat实例中,多个应用程序共享一个公共线程池。线程类加载器是无论哪个应用程序启动线程。但是当线程被另一个应用程序重用时,线程类加载器保持不变。因此有所不同。

要确认,请设置一个断点并观察以下两个结果,看看它们是否相同。

Thread.currentThread().getContextClassLoader() 

this.getClass().getClassLoader() 
[@OrderBy引起org.hibernate.HibernateException:无法解析顺序逐片段]的
相关问题