Workaround for EJB local invoke "Java.lang.ClassCastException: $Proxy cannot is cast to Com.tgb.ejb.UserManager" exception problem

Source: Internet
Author: User
Tags jboss jboss server

EJB Local invocation: The Web client and the EJB server are deployed to the same jboss, and the clients and servers communicate through a single JVM.

When a Web client is called locally, it is necessary to refer to the EJB server-side packaged jar, without referencing the jndi.properties file under the jar and SRC under Jboss/client, in the following way:

<%@ page language= "java" import= "java.util.*,javax.naming.*,com.tgb.ejb.*" pageencoding= "Utf-8"%><%String Path = Request.getcontextpath (); String basepath = request.getscheme () + "://" + request.getservername () + ":" + request.getserverport () + path + "/";%>&L T;html>when the browser enters the URL address that the client publishes, JBoss reports the following exception:

13:02:30,924 ERROR [[JSP]] Servlet.service () for Servlet JSP threw exceptionjava.lang.ClassCastException: $Proxy 96 Cannot is cast to Com.tgb.ejb.UserManagerat Org.apache.jsp.index_jsp._jspservice (index_jsp.java:79) at Org.apache.jasper.runtime.HttpJspBase.service (httpjspbase.java:70) at Javax.servlet.http.HttpServlet.service ( httpservlet.java:803) at Org.apache.jasper.servlet.JspServletWrapper.service (jspservletwrapper.java:373) at Org.apache.jasper.servlet.JspServlet.serviceJspFile (jspservlet.java:336) at Org.apache.jasper.servlet.JspServlet.service (jspservlet.java:265) at Javax.servlet.http.HttpServlet.service ( httpservlet.java:803) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter ( applicationfilterchain.java:290) at Org.apache.catalina.core.ApplicationFilterChain.doFilter ( applicationfilterchain.java:206) at Org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter ( replyheaderfilter.java:96) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter ( Applicationfilterchain.java:235) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:206) at Org.apache.catalina.core.StandardWrapperValve.invoke (standardwrappervalve.java:230) at Org.apache.catalina.core.StandardContextValve.invoke (standardcontextvalve.java:175) at Org.jboss.web.tomcat.security.SecurityAssociationValve.invoke (securityassociationvalve.java:182) at Org.jboss.web.tomcat.security.JaccContextValve.invoke (jacccontextvalve.java:84) at Org.apache.catalina.core.StandardHostValve.invoke (standardhostvalve.java:127) at Org.apache.catalina.valves.ErrorReportValve.invoke (errorreportvalve.java:102) at Org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke (cachedconnectionvalve.java:157) at Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:109) at Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:262) at Org.apache.coyote.http11.Http11Processor.process (http11processor.java:844) at Org.apache.coyote.http11.http11protocol$http11Connectionhandler.process (http11protocol.java:583) at Org.apache.tomcat.util.net.jioendpoint$worker.run ( jioendpoint.java:446) at Java.lang.Thread.run (thread.java:619)
Solution: Locate the Jboss-service.xml file under the Jboss-4.2.3.ga\server\default\deploy\jboss-web.deployer\meta-inf path of the JBoss server and <attribute name= "Usejbosswebloader" >false</attribute> false to True, restart JBoss, problem solved.

    usejbosswebloader
    Generally, this should be avoided because when the same classes and resources are available in different applications, There are conflicts between different JBoss applications: Two war applications WarA, Warb below are com.tgb.User.class files;

I hope that my explanation can help you to improve.

Workaround for EJB local invoke "Java.lang.ClassCastException: $Proxy cannot is cast to Com.tgb.ejb.UserManager" exception problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.