问题
I am using Jboss7.0.1 Final to deploy my web application, But I don't want to use default Resteasy jar provided by Jboss so I made the changes in jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<dependencies>
<module name="javaee.api">
<imports>
<exclude path="org/apache/xml/security/**" />
</imports>
</module>
<module name="com.mrf.portal.configuration" />
<module name="org.jboss.resteasy.resteasy-jackson-provider"
services="import" />
</dependencies>
<exclusions>
<module name="org.apache.log4j" />
<!-- This one always goes last. -->
<module name="javax.api" />
<module name="org.apache.commons.logging" />
<module name="org.jboss.as.jaxrs" />
<module name="org.jboss.resteasy.resteasy-jaxrs" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.jboss.resteasy.jackson-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Now project deployed successfully but when this code call.
static {
try {
client = new ResteasyClientBuilder().build();
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
}
}
It is throwing below exception:
07:19:11,034 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 11 01 2016 07:19:11,033 DEBUG DocumentProvider:60 - Unable to retrieve config: expandEntityReferences defaults to true
07:19:11,053 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 11 01 2016 07:19:11,052 DEBUG DocumentProvider:60 - Unable to retrieve config: expandEntityReferences defaults to true
07:19:11,095 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 11 01 2016 07:19:11,094 WARN RegisterBuiltin:103 - ClassNotFoundException: Unable to load builtin provider: org.jboss.resteasy.plugins.interceptors.CacheControlInterceptor
07:19:11,116 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 11 01 2016 07:19:11,115 WARN RegisterBuiltin:103 - ClassNotFoundException: Unable to load builtin provider: org.jboss.resteasy.plugins.interceptors.encoding.ClientContentEncodingHeaderInterceptor
07:19:11,139 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 11 01 2016 07:19:11,138 WARN RegisterBuiltin:103 - ClassNotFoundException: Unable to load builtin provider: org.jboss.resteasy.plugins.interceptors.encoding.ServerContentEncodingHeaderInterceptor
07:19:11,287 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/mdf-portal-web].[Faces Servlet]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.ClassCastException: org.jboss.resteasy.logging.impl.Log4jLogger cannot be cast to org.jboss.resteasy.logging.Logger at org.jboss.resteasy.logging.Logger.getLogger(Logger.java:92) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.plugins.providers.YamlProvider.(YamlProvider.java:42) [resteasy-yaml-provider-2.3.1.GA.jar:] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_79] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.7.0_79] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.7.0_79] at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.7.0_79] at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:148) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2175) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:748) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1366) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1310) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:70) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:31) [resteasy-jaxrs-3.0.8.Final.jar:] at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.getProviderFactory(ResteasyClientBuilder.java:309) [resteasy-client-3.0.8.Final.jar:] at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:317) [resteasy-client-3.0.8.Final.jar:] at com.alu.ipprd.mdf.soa.portal.integration.rest.Constants.(Constants.java:200) [mdf-portal-integration-0.0.1-SNAPSHOT.jar:] at com.alu.ipprd.bsm.soa.portal.bean.LoginBean.doLogin(LoginBean.java:897) [classes:] at com.alu.ipprd.bsm.soa.portal.bean.LoginBean.verifyLogged(LoginBean.java:1150) [classes:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_79] at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.10.Final.jar:] at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.10.Final.jar:] at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2464) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final] at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final] at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2168) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2116) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:288) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:246) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:] at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_79]
来源:https://stackoverflow.com/questions/34713258/java-lang-classcastexceptionjboss-resteasy-logging