gpt4 book ai didi

java - ClassCastException 原因

转载 作者:行者123 更新时间:2023-12-02 11:05:50 28 4
gpt4 key购买 nike

我正在获取 ClassCastException 。这两个类来自不同的 jar,但是JettyContinuationProviderFactory 正在实现 ContinuationProviderFactory 类。

Caused by: javax.xml.ws.WebServiceException: java.lang.ClassCastException: Cannot cast org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory to org.apache.cxf.transport.http.ContinuationProviderFactory
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:371) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:539) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_80]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
... 23 more
Caused by: java.lang.ClassCastException: Cannot cast org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory to org.apache.cxf.transport.http.ContinuationProviderFactory
at java.lang.Class.cast(Class.java:3186) [rt.jar:1.7.0_80]
at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:326) [cxf-rt-core-2.7.14.jar:2.7.14]
at org.apache.cxf.bus.spring.SpringBeanLocator.getBeanOfType(SpringBeanLocator.java:138) [cxf-rt-core-2.7.14.jar:2.7.14]
at org.apache.cxf.bus.CXFBusImpl.getExtension(CXFBusImpl.java:107) [cxf-rt-core-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.http.AbstractHTTPDestination.initConfig(AbstractHTTPDestination.java:519) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.http.AbstractHTTPDestination.<init>(AbstractHTTPDestination.java:149) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.servlet.ServletDestination.<init>(ServletDestination.java:52) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.servlet.ServletDestinationFactory.createDestination(ServletDestinationFactory.java:33) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:305) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:142) [cxf-rt-bindings-soap-2.7.14.jar:2.7.14]
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:83) [cxf-api-2.7.14.jar:2.7.14]
at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:62) [cxf-api-2.7.14.jar:2.7.14]
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:170) [cxf-rt-frontend-simple-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
... 32 more

17:02:35,992 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cisBusiness]] (ServerService Thread Pool -- 57) JBWEB000287: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fulFillment': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: java.lang.ClassCastException: Cannot cast org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory to org.apache.cxf.transport.http.ContinuationProviderFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_80]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: javax.xml.ws.WebServiceException: java.lang.ClassCastException: Cannot cast org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory to org.apache.cxf.transport.http.ContinuationProviderFactory
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:371) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:539) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_80]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
... 23 more
Caused by: java.lang.ClassCastException: Cannot cast org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory to org.apache.cxf.transport.http.ContinuationProviderFactory
at java.lang.Class.cast(Class.java:3186) [rt.jar:1.7.0_80]
at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:326) [cxf-rt-core-2.7.14.jar:2.7.14]
at org.apache.cxf.bus.spring.SpringBeanLocator.getBeanOfType(SpringBeanLocator.java:138) [cxf-rt-core-2.7.14.jar:2.7.14]
at org.apache.cxf.bus.CXFBusImpl.getExtension(CXFBusImpl.java:107) [cxf-rt-core-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.http.AbstractHTTPDestination.initConfig(AbstractHTTPDestination.java:519) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.http.AbstractHTTPDestination.<init>(AbstractHTTPDestination.java:149) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.servlet.ServletDestination.<init>(ServletDestination.java:52) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.servlet.ServletDestinationFactory.createDestination(ServletDestinationFactory.java:33) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:305) [cxf-rt-transports-http-2.7.14.jar:2.7.14]
at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:142) [cxf-rt-bindings-soap-2.7.14.jar:2.7.14]
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:83) [cxf-api-2.7.14.jar:2.7.14]
at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:62) [cxf-api-2.7.14.jar:2.7.14]
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:170) [cxf-rt-frontend-simple-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334) [cxf-rt-frontend-jaxws-2.7.14.jar:2.7.14]
... 32 more

我在 Tomcat 中制作了 SOAP Web 服务的演示,运行良好。但是这些错误是在 JBOSS EAP 6 的情况下生成的。任何人都可以提供帮助吗?

最佳答案

这可能是一个类加载问题,您的类路径上可能有 2 个不同的 jar,它们都包含 ContinuationProviderFactory.class

代码的不同部分现在可能使用该接口(interface)的不同版本,因此您的 JettyContinuationProviderFactory 现在正在实现一个版本,但您传递 JettyContinuationProviderFactory 实例的方法to 期待其他接口(interface)。

这会产生无法通过强制转换解决的类型冲突,因此会出现此异常。尽管这看起来很愚蠢,但从 JVM 类加载的角度来看,它非常有意义。

它在 Tomcat 上工作的原因是你的类路径可能恰好更干净。解决方案是调查类路径上的哪些 jar 正在提供 ContinuationProviderFactory 并消除重复项。

关于java - ClassCastException 原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50967700/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com