簡體   English   中英

無法將 org.apache.qpid.jms.provider.amqp.AmqpProviderFactory 轉換為 org.apache.qpid.jms.provider.ProviderFactory

[英]Cannot cast org.apache.qpid.jms.provider.amqp.AmqpProviderFactory to org.apache.qpid.jms.provider.ProviderFactory

我一直試圖解決這個問題,現在需要一個不同的視角。 我正在使用 spring 並合並了這個 spring 引導啟動包,以便我可以利用 AMQP 協議: amqp-10-jms-spring-boot-starter ,我已經成功配置並且目前正在工作。 當我將它部署到 Jboss eap7 容器“這是一個請求”時,問題就出現了。 所以當我第一次部署這個應用程序時,一切都很好。 當我重新部署相同的應用程序而沒有先取下容器時,就會出現問題(因為我不應該這樣做)。 這是我迄今為止所想到和嘗試過的:

  1. 春天的東西沒有被正確清理? 查看一些 JMC 飛行計划統計數據,沒有看到任何讓我感到意外的東西。 沒有剩余的 Springframework 或 JMSConnectionFactory 實例。
  2. Wildlfy 類路徑問題? 我在 jboss-deployment 中忽略了 artemis 庫和 artemis 模塊
  3. Good Friend google 99% 的時間都是本壘打。 這次雖然沒有太大的方向。

Jboss-部署-結構

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <exclude-subsystems>
            <subsystem name="jaxrs" />
            <subsystem name="messaging-activemq" />
        </exclude-subsystems>
        <exclusions>
            <module name="org.hibernate" slot="main" />
            <module name="org.apache.activemq.artemis" slot="main" />
            <module name="org.apache.activemq.artemis.ra" slot="main" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

請記住,我在這里還有其他代碼,這些代碼包括 JSR 包、Hibernate、spring-web 等依賴項。 為了完整起見,我留下了這些。

pom.xml

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <scope>runtime</scope>
        </dependency>


        <!-- Spring Data/DB -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>4.3.10.RELEASE</version>
        </dependency>
        <dependency> <!-- works with spring 4.3.10-->
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.11.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-java8</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>hibernate-core</artifactId>
                    <groupId>org.hibernate</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>hibernate-core</artifactId>
                    <groupId>org.hibernate</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- Spring JMS-->
        <dependency>
            <groupId>org.amqphub.spring</groupId>
            <artifactId>amqp-10-jms-spring-boot-starter</artifactId>
            <version>0.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>

最后我的堆棧跟蹤

22:44:08,293 ERROR [org.apache.qpid.jms.provider.ProviderFactory] (ServiceEvent-144) Failed to create Provider instance for amqp, due to: java.io.IOException: Provider scheme NOT recognized: [amqp]
22:44:08,293 ERROR [org.apache.qpid.jms.JmsConnectionFactory] (ServiceEvent-144) Failed to create JMS Provider instance for: amqp
22:44:08,293 ERROR [stderr] (ServiceEvent-144) Exception in thread "ServiceEvent-144" org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Provider scheme NOT recognized: [amqp]
22:44:08,293 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
22:44:08,293 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:570)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:658)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at my.test.Producertest.send(Producertest:62)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at java.lang.reflect.Method.invoke(Method.java:498)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:256)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:177)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:140)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:134)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at java.lang.Thread.run(Thread.java:745)
22:44:08,294 ERROR [stderr] (ServiceEvent-144) Caused by: javax.jms.JMSException: Provider scheme NOT recognized: [amqp]
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:86)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:108)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.JmsConnectionFactory.createConnection(JmsConnectionFactory.java:211)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.JmsConnectionFactory.createConnection(JmsConnectionFactory.java:191)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
22:44:08,294 ERROR [stderr] (ServiceEvent-144)  ... 21 more
22:44:08,294 ERROR [stderr] (ServiceEvent-144) Caused by: java.io.IOException: Provider scheme NOT recognized: [amqp]
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.provider.ProviderFactory.findProviderFactory(ProviderFactory.java:124)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.provider.ProviderFactory.findProviderFactory(ProviderFactory.java:99)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.provider.ProviderFactory.create(ProviderFactory.java:70)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.JmsConnectionFactory.createProvider(JmsConnectionFactory.java:329)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.JmsConnectionFactory.createConnection(JmsConnectionFactory.java:200)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  ... 24 more
22:44:08,295 ERROR [stderr] (ServiceEvent-144) Caused by: java.lang.ClassCastException: Cannot cast org.apache.qpid.jms.provider.amqp.AmqpProviderFactory to org.apache.qpid.jms.provider.ProviderFactory
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.util.FactoryFinder.newInstance(FactoryFinder.java:129)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  at org.apache.qpid.jms.provider.ProviderFactory.findProviderFactory(ProviderFactory.java:122)
22:44:08,295 ERROR [stderr] (ServiceEvent-144)  ... 28 more

沒有什么能幫助我抓住這里的稻草。 所以任何方向都是有幫助的。 我可以只使用 JMS API,稍后我會嘗試。 但我希望能解決這個問題。 提前致謝。

更新

我將所有代碼都排除在外,並創建了一個簡單的服務。 amqp-10-jms-spring-boot-starter 不是罪魁禍首。 我懷疑我的 Spring 事件偵聽器或我的 AsynchronousSocketChannel 以某種方式干擾(與 Jboss 或直接)並保持一個差事連接。

好吧,我發現了這個問題。 請注意,我僅在將此應用程序移至 Tomcat 后才發現核心問題。 其中指出“您創建了一個未被刪除的線程”。 我的代碼使用 AsynchronousSocketChannel 類來監聽我關心的端口。 默認實現使用類 AnsychronousChannelGroup,在這種情況下不會被清除,一旦您將通道組分配給 socketchannel,您就可以通過這種方式清除線程。 我將在今天晚些時候將我的代碼上傳到一個 github 帳戶,以便人們可以使用它。 Java 8 錯誤?

我認為這與 JBOSS 類加載機制有關。 當我們從 WLS 遷移到 JBOSS 時,我們遇到了幾個這樣的奇怪問題。 一個建議您在應用程序啟動時使用 Class.forName 來實例化所需的驅動程序類/庫。 您可以嘗試的另一個方法是刪除 standalone.xml/domain.xml 中的子系統(子系統 xmlns="urn:jboss:domain:messaging-activemq:1.0")並檢查。 希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM