如何解决:antlr.CommonToken 无法转换为 antlr.Token?

问题描述

我刚刚完成了从 wildfly 9 到 23 的更新,现在正在重新设计我的 arquillian 实现以使用新的应用服务器版本。

依赖管理:

 <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.4.1.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-jakartaee8-with-tools</artifactId>
                <scope>import</scope>
                <type>pom</type>
                <version>21.0.2.Final</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

依赖:

        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-container-embedded</artifactId>
            <version>3.0.1.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>${arquillian.version}</version>
            <scope>test</scope>
        </dependency>

运行测试时出现此错误

[ERROR] org.<company name>.crs.auth.CrsUserServiceTest  Time elapsed: 71.828 s  <<< ERROR!
org.jboss.arquillian.container.spi.client.container.DeploymentException: 
Cannot deploy ert-tests.war: {"WFLYCTL0062: Composite operation Failed and was rolled back. Steps that Failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"ert-tests.war#ertDatasource\"" => "javax.persistence.PersistenceException: [PersistenceUnit: ertDatasource] Unable to build Hibernate SessionFactory
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: ertDatasource] Unable to build Hibernate SessionFactory
    Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.collection.OnetoManyPersister
    Caused by: org.hibernate.HibernateException: Unable to parse order-by fragment
    Caused by: java.lang.classCastException: antlr.CommonToken cannot be cast to antlr.Token"}}}}

在网上研究后,很多人说这是由于 antlr 的版本冲突(通常是手动导入的版本和带有 hibernate 的版本)。这是我的休眠导入:

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.20.Final</version>
            <scope>provided</scope>

            <exclusions>
                <exclusion>
                    <groupId>antlr</groupId>
                    <artifactId>antlr</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

其中明确没有带 antlr。事实上,如果我运行 mvn dependency:tree搜索 antlr,我不会得到任何结果。所以,如果我在类路径中没有任何版本或根本没有导入,我不确定我如何有冲突的版本。

我找到了 This文章,提到这可能是由于多个应用程序正在运行。但不确定这是否适用,因为我只有一个应用程序在运行并且只有一个实例(我认为)。在启动 arquillian 时,我从 Wildfly 15:50:35,940 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-4) No shutdown hook registered: Please call close() manually on application shutdown. 收到了这条消息,但是在运行测试时我收到了两次该消息。想知道这是否会导致问题,如果不是,还有什么可能?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)