8 Replies Latest reply on Jul 9, 2009 3:47 PM by ookami2110

    java.lang.RuntimeException: java.lang.ClassCastException: $P

      Hi all,
      I am using Jboss application server 4.2.3 GA.
      my problem is, when I create a stateless session bean and deploy that works fine but if I change this bean to stateful session bean by changing annotation, that give classCastException

      package com.logica.heca.lpr.ruleengine;
      
      import com.logica.heca.lpr.common.exception.FatalException;
      import com.logica.heca.lpr.common.exception.RuleParserException;
      import com.logica.heca.lpr.domain.contact.ContactVO;
      import com.logica.heca.lpr.domain.ruleengine.RuleDefinitionVO;
      import com.logica.heca.lpr.ruleengine.helper.RuleParser;
      
      import javax.ejb.EJBException;
      import javax.ejb.Stateful;
      import java.io.Serializable;
      
      /**
       * <p/>
       * Created by: kumarrg
       * Date: 17-Jun-2009
       * Time: 14:33:02
       * </br>
       * This software is a part of the LPR system, developed by Logica.
       */
      @Stateful(name = "RuleEngine")
      public class RuleEngineBean implements RuleEngineLocal, RuleEngineRemote, RuleEngine, Serializable {
      
       // private static final Logger logger= Logger.getLogger(RuleEngineBean.class);
      
       /**
       * @param contactVO to be validated against rules
       * @return ContactdVo populated with ruleId and Error Source object
       */
       public ContactVO processContact(ContactVO contactVO) {
      // try {
      // StatelessSession session = getRuleBase().newStatelessSession();
      // session.execute(contactVO);
       return contactVO;
      // } catch (Throwable ex) {
      // logger.fatal("Severe error while processing ContactVo rule", ex);
      // throw new FatalException("Fatal error while parsing rule");
      // }
       }
      
      // private RuleBase getRuleBase()throws RuleParserException {
      // // return new RuleBaseBuilder().getRuleBase();
      // return null;
      // }
      
       /**
       * parse rule as per Drools rules 4 format
       * @param ruleDefinitionVO RuleDefinitionLite
       * @return RuleDefinitionErrorVO if any error found else null
       */
       public void parseRule(RuleDefinitionVO ruleDefinitionVO) throws RuleParserException{
       try {
       new RuleParser().parseRule(ruleDefinitionVO);
       } catch (Throwable ex) {
       // logger.fatal("Severe error while parsing rule",ex);
       throw new EJBException("Fatal error while parsing rule");
       }
       }
      
       /**
       * clears Cache of RuleBase in Rule Engine
       */
       public void clearCache() {
       try {
       new RuleBaseBuilder().clearCache();
       } catch (Throwable ex) {
       // logger.fatal("Severe Error while clearing RuleBase cache", ex);
       throw new EJBException("Fatal error while clearing RuleBase cache");
       }
       }
      }
      

      the exact error is
      d-25]. The thread terminates
      java.lang.ClassCastException: $Proxy61 cannot be cast to com.logica.heca.lpr.ruleengine.RuleEngineRemote
       at com.logica.heca.lpr.services.facade.RuleEngineFacade.process(RuleEngineFacade.java:31)
       at com.logica.heca.lpr.dataLoader.DataLoaderThread.run(DataLoaderThread.java:129)
      11:51:54,243 ERROR [STDERR] Exception in thread "DataLoaderThread-25"
      11:51:54,243 ERROR [STDERR] java.lang.RuntimeException: java.lang.ClassCastException: $Proxy61 cannot be cast to com.logica.h
      eca.lpr.ruleengine.RuleEngineRemote
      11:51:54,243 ERROR [STDERR] at com.logica.heca.lpr.dataLoader.DataLoaderThread.run(DataLoaderThread.java:187)
      

      I am running client and server code on same server
      help from any one would be highly appreciable.

      Thanks
      -Ravi


        • 1. Re: java.lang.RuntimeException: java.lang.ClassCastException
          wolfgangknauf

          Hi,

          please post also the lookup code of "com.logica.heca.lpr.dataLoader.DataLoaderThread.run".

          Is your client an application client or a web app?

          How is the structure of your app?
          If application client: Does the client JAR contain the most recent version of your EJB jars?
          If web app or other EJB: does the WAR file contain a copy of the EJB classes?

          Best regards

          Wolfgang

          • 2. Re: java.lang.RuntimeException: java.lang.ClassCastException

            Thanks Wolfgang Knauf !!

            This problem was solved now that was due to Classloader. issue
            the scenario is,I have Mbean application runing in its own classloader isolation scope and ejb 3.0 ear running in own. Mbean Application is calling bean from ejb ear. but since in ear-deployer.xml the CallByValue and Isolated attributes were set to false that was the exact problem, when I switched those and CallByValue attribute in Jboss-service.xmls' to true Mbean application is able to call bean but now I have new problem as side effect in ejb application I am calling another bean using Local Interface that was not working. could you please help why it would not be able to call Local inteface of ejb reside in same ear

            in response of your question

            My Client is an Mbean application that reads data files from one directory then transform and validate that data using Jboss rule engine(this running in its own class loader scope) Mbean application contains ejb-client.jar that contains remote and other classes

            DataLoaderThread.java(Client)

             public void run() {
             try {
             PatientFacade patientFacade = new PatientFacade();
             isRunning = true;
             init();
            
             contactCache = new ContactVOCache();
            
             while (isRunning) {
             // TODO: decide (from a system setting) if this server is supposed to work as data loader, otherwise just go to sleep again.
            
             ZipHandler zipHandler = null;
             File file;
             contactCache.clear();
            
             try {
            
             file = queue.removeFile(); // This method puts the thread to sleep until a file is available.
             long startTime = System.currentTimeMillis(); // New file detected. Measure the exucution time for statistic purpose.
             long nextInfoTime = startTime + 5000;
            
             if (logger.isInfoEnabled()) {
             logger.info("New file detected: " + file);
             }
            
             zipHandler = new ZipHandler(file);
            
             RawFileStatus rawFileStatus = zipHandler.getStatus();
             boolean rawFileWasRejectedByInitialValidation = (rawFileStatus.getError() != null);
            
             long rawFileId = saveRawFile(zipHandler, rawFileStatus); // Always save the zip file to the raw data archive
            
             if (rawFileWasRejectedByInitialValidation) {
             if (logger.isInfoEnabled()) {
             logger.info("Raw data file " + zipHandler + " saved with raw data ID " + rawFileId + ". This file was rejected by the initial validation - no further processing is done.");
             }
             } else {
             String provider = rawFileStatus.getProviderName();
             long dataProducer = 1; // TODO: Transform raw file "provider" to a dataProducer via database lookup.
            
             if (logger.isInfoEnabled()) {
             logger.info("Raw data file " + zipHandler + " saved with raw data ID " + rawFileId);
             }
            
             int numberOfContacts = 0;
            
            
             RawZipStreamIterator rawZipStreamIterator = new RawZipStreamIterator(file);
             while (rawZipStreamIterator.hasNext()) {
             RawFileRecordIndud indud = rawZipStreamIterator.nextIndud();
             ContactVOAssemblerFromRawdata assembler = new ContactVOAssemblerFromRawdata();
             ContactVO contactVO = assembler.createContactVO(indud);
             contactVO.setReportedByDataProducerID(dataProducer);
            
             contactVO = ruleEngine.process(contactVO); // NOTE: Remote call means that we get a new instance in contactVO !!!!
            
             numberOfContacts++;
            
             // TODO: contactVO.setValidationStatus( /* String validationStatus */);
             //TODO contactCache is just dummy classes need to be chagend with real implemntation
             contactVO.setValidationTimestamp(new Date());
             contactCache.push(contactVO);
            
             if (logger.isInfoEnabled() && nextInfoTime < System.currentTimeMillis()) {
             nextInfoTime += 5000;
             logger.info("Number of contacts processed until now: " + numberOfContacts);
             }
             }
            
             rawZipStreamIterator.close();
            
             if (contactCache.getErrorPercentage() > ERROR_PERCENTAGE) {
             //TODO where we have to go from now
             } else {
             if (logger.isInfoEnabled()) logger.info("Starting to save contacts to the database.");
             ContactFacade contactFacade = ContactFacade.getInstance();
            
             int saveCounter = 0;
             int saveErrorCounter = 0;
             int saveOkCounter = 0;
             while (contactCache.hasMore()) {
             saveCounter++;
             ContactVO contact = contactCache.pop();
             try {
             contactFacade.saveContact(contact);
             saveOkCounter++;
             } catch (Exception e) {
             saveErrorCounter++;
             logger.error("Could not save contact no. " + saveCounter, e);
             }
             }
             logger.info("Tried to save " + saveCounter + " contacts. " + saveOkCounter + " were saved, " + saveErrorCounter + " failed");
             }
            
             if (logger.isInfoEnabled())
             logger.info("Raw file processed. Total number of contacts: " + numberOfContacts + "." +
             " Execution Time: " + (System.currentTimeMillis() - startTime) / 1000L + " sec.");
            
            // TODO: update raw file archive, to set the time, when the processing of this file was completed.x
            // TODO: update the marker for this data producer, that a new total error list is to be produced
            
             }
            
             zipHandler.close();
             zipHandler = null;
             FileUtils.delete(file);
            
             } catch (DataLoaderException t) {
             logger.error("DataLoaderThread[" + this.getName() + "] execute error", t);
             } finally {
             if (zipHandler != null) {
             zipHandler.close();
             }
             }
             }
             } catch (InterruptedException e) {
             logger.info("DataLoaderThread[" + this.getName() + "] stopped");
             } catch (Error error) {
             isRunning = false;
             logger.error("Severe error in the worker thread [" + this.getName() + "]. The thread terminates", error);
             throw error;
             } catch (Throwable t) {
             isRunning = false;
             logger.error("What happend? ... we got an unexpected Exception in the worker thread [" + this.getName() + "]. The thread terminates", t);
             throw new RuntimeException(t);
             }
             isRunning = false;
             }
            

            RuleEngineBean. java(EJB-Bean)
            @Stateful(name = "RuleEngine")
            public class RuleEngineBean implements RuleEngineRemote, RuleEngine{
            
             private static final Logger logger= Logger.getLogger(RuleEngineBean.class);
             private RuleBase ruleBase = null;
             /**
             * @param contactVO to be validated against rules
             * @return ContactdVo populated with ruleId and Error Source object
             */
             public ContactVO processContact(ContactVO contactVO) {
             try {
             StatelessSession session = ruleBase.newStatelessSession();
             session.execute(contactVO);
             return contactVO;
             } catch (Throwable ex) {
             logger.fatal("Severe error while processing ContactVo rule", ex);
             throw new EJBException("Fatal error while parsing rule");
             }
             }
             @PostConstruct
             private void getRuleBase(){
             try {
             ruleBase = new RuleBaseBuilder().getRuleBase();
             } catch (RuleParserException ex) {
             logger.error("Rule Parser Exception while initializing Rulebase");
             throw new EJBException(ex);
             }
             }
            
             /**
             * parse rule as per Drools rules 4 format
             * @param ruleDefinitionVO RuleDefinitionLite
             * @return RuleDefinitionErrorVO if any error found else null
             */
             public void parseRule(RuleDefinitionVO ruleDefinitionVO) throws RuleParserException{
            
             new RuleParser().parseRule(ruleDefinitionVO);
            
             }
            
             /**
             * clears Cache of RuleBase in Rule Engine
             */
             public void clearCache() {
             try {
             new RuleBaseBuilder().clearCache();
             } catch (Throwable ex) {
             logger.fatal("Severe Error while clearing RuleBase cache", ex);
             throw new EJBException("Fatal error while clearing RuleBase cache");
             }
             }
            }

            RuleBaseBuilder class used by RuleEngineBean and Call another bean Using Local interface and gives error
            
            public class RuleBaseBuilder implements Serializable {
            
             private final static Logger logger = Logger.getLogger(RuleBaseBuilder.class);
             private static final RuleBaseCache cache = new RuleBaseCache();
            
             /**
             * getRuleBase method builds and returns rulebase
             * from cache if available, else buils and returns new rule base
             *
             * @return RuleBase with all rules
             */
             public RuleBase getRuleBase() throws RuleParserException {
             RuleBase ruleBase = cache.getRuleBase();
             if (ruleBase == null) {
             ruleBase = buildRuleBase();
             cache.putRuleBase(ruleBase);
             }
             return ruleBase;
             }
            
             /**
             * Clears cache
             */
             public void clearCache() {
             cache.remove();
             }
            
            
             private RuleBase buildRuleBase() {
             List<RuleDefinitionVO> list = this.getDBRules();
             RuleBase rb = RuleBaseFactory.newRuleBase();
            
             for (RuleDefinitionVO ruleVO : list) {
            
             try {
             if(ruleVO.getId()<=100000){continue;}
             rb.addPackage(new RuleParser().buildPackage(ruleVO));
            
             } catch (Exception e) {
             //todo MUST FIX deside what todo if some rules failed to load in memory
             Rule rule=new Rule(ruleVO) ;
             logger.error("Rule:"+ rule.getId() + " can't loaded to memory " + e.getMessage());
             }
             }
             return rb;
             }
            
             private List<RuleDefinitionVO> getDBRules() {
             RuleManagerLocal manager = getRuleMangerLocal();
             List<RuleDefinitionVO> list = manager.getAllRules();
             logger.debug("Downloaded Rules from database");
            
             return list;
             }
             /**
             * TODO refactoring
             */
             public RuleManagerLocal getRuleMangerLocal() {
             try {
             return (RuleManagerLocal) new InitialContext().lookup("lpr/RuleManager/local");
             } catch (NamingException e) {
             throw new LPRException(LPRErrorCode.SYSTEM_INTERNAL_ERROR, "Failed to get RuleManagerRemote", e);
             } catch (Throwable t) {
             throw new LPRException(LPRErrorCode.SYSTEM_INTERNAL_ERROR, "Failed to get RuleManagerRemote", t);
             }
             }
            }
            
            


            exception stack trace
            
            09:51:20,994 ERROR [STDERR] java.lang.RuntimeException: com.logica.heca.lpr.common.exception.LPRException: Failed to get Rule
            ManagerRemote
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorH
            andler.java:113)
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:623)
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:131)
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
            09:51:20,994 ERROR [STDERR] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:315)
            09:51:21,010 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:320)
            09:51:21,010 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
            09:51:21,010 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
            09:51:21,010 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            09:51:21,010 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:139)
            09:51:21,010 ERROR [STDERR] at $Proxy116.processContact(Unknown Source)
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.services.facade.RuleEngineFacade.process(RuleEngineFacade.java:31)
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.dataLoader.DataLoaderThread.run(DataLoaderThread.java:129)
            09:51:21,010 ERROR [STDERR] Caused by: com.logica.heca.lpr.common.exception.LPRException: Failed to get RuleManagerRemote
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleMangerLocal(RuleBaseBuilder.java:95)
            
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getDBRules(RuleBaseBuilder.java:82)
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.buildRuleBase(RuleBaseBuilder.java:63)
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleBase(RuleBaseBuilder.java:48)
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleEngineBean.getRuleBase(RuleEngineBean.java:46)
            09:51:21,010 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            09:51:21,010 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            09:51:21,010 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            09:51:21,010 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
            09:51:21,010 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(LifecycleInvocationConte
            xtImpl.java:159)
            09:51:21,010 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorH
            andler.java:109)
            09:51:21,010 ERROR [STDERR] ... 14 more
            09:51:21,010 ERROR [STDERR] Caused by: javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundExceptio
            n: No ClassLoaders found for: com.logica.heca.lpr.services.RuleManagerLocal (no security manager: RMI class loader disabled)]
            
            09:51:21,010 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:786)
            09:51:21,010 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
            09:51:21,010 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392)
            09:51:21,010 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleMangerLocal(RuleBaseBuilder.java:93)
            
            09:51:21,010 ERROR [STDERR] ... 24 more
            09:51:21,025 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.logica.heca.lpr.servi
            ces.RuleManagerLocal (no security manager: RMI class loader disabled)
            09:51:21,025 ERROR [STDERR] at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:535)
            09:51:21,025 ERROR [STDERR] at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
            09:51:21,025 ERROR [STDERR] at org.jboss.system.JBossRMIClassLoader.loadProxyClass(JBossRMIClassLoader.java:82)
            09:51:21,025 ERROR [STDERR] at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
            09:51:21,025 ERROR [STDERR] at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
            09:51:21,025 ERROR [STDERR] at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
            09:51:21,025 ERROR [STDERR] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
            09:51:21,025 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
            09:51:21,025 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            09:51:21,025 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            09:51:21,025 ERROR [STDERR] at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
            09:51:21,025 ERROR [STDERR] at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
            09:51:21,025 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
            09:51:21,025 ERROR [STDERR] ... 27 more
            09:51:21,307 ERROR [DataLoaderThread] What happend? ... we got an unexpected Exception in the worker thread [DataLoaderThrea
            d-26]. The thread terminates
            javax.ejb.EJBException: java.lang.RuntimeException: com.logica.heca.lpr.common.exception.LPRException: Failed to get RuleMana
            gerRemote
             at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:337)
             at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:320)
             at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
             at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:139)
             at $Proxy116.processContact(Unknown Source)
             at com.logica.heca.lpr.services.facade.RuleEngineFacade.process(RuleEngineFacade.java:31)
             at com.logica.heca.lpr.dataLoader.DataLoaderThread.run(DataLoaderThread.java:129)
            Caused by: java.lang.RuntimeException: com.logica.heca.lpr.common.exception.LPRException: Failed to get RuleManagerRemote
             at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:113)
             at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:623)
             at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:131)
             at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
             at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
             at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
             at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:315)
             ... 8 more
            Caused by: com.logica.heca.lpr.common.exception.LPRException: Failed to get RuleManagerRemote
             at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleMangerLocal(RuleBaseBuilder.java:95)
             at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getDBRules(RuleBaseBuilder.java:82)
             at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.buildRuleBase(RuleBaseBuilder.java:63)
             at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleBase(RuleBaseBuilder.java:48)
             at com.logica.heca.lpr.ruleengine.RuleEngineBean.getRuleBase(RuleEngineBean.java:46)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(LifecycleInvocationContextImpl.java:159)
             at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:109)
             ... 14 more
            Caused by: javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: No ClassLoaders found for
            : com.logica.heca.lpr.services.RuleManagerLocal (no security manager: RMI class loader disabled)]
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:786)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
             at javax.naming.InitialContext.lookup(InitialContext.java:392)
             at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleMangerLocal(RuleBaseBuilder.java:93)
             ... 24 more
            Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.logica.heca.lpr.services.RuleManagerLocal (no sec
            urity manager: RMI class loader disabled)
             at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:535)
             at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
             at org.jboss.system.JBossRMIClassLoader.loadProxyClass(JBossRMIClassLoader.java:82)
             at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
             at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
             at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
             at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
             at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
             at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
             at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
             at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
             at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
             ... 27 more
            09:51:21,338 ERROR [STDERR] Exception in thread "DataLoaderThread-26"
            09:51:21,338 ERROR [STDERR] java.lang.RuntimeException: javax.ejb.EJBException: java.lang.RuntimeException: com.logica.heca.l
            pr.common.exception.LPRException: Failed to get RuleManagerRemote
            09:51:21,338 ERROR [STDERR] at com.logica.heca.lpr.dataLoader.DataLoaderThread.run(DataLoaderThread.java:199)
            09:51:21,338 ERROR [STDERR] Caused by: javax.ejb.EJBException: java.lang.RuntimeException: com.logica.heca.lpr.common.excepti
            on.LPRException: Failed to get RuleManagerRemote
            09:51:21,338 ERROR [STDERR] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:337)
            09:51:21,338 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:320)
            09:51:21,338 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
            09:51:21,338 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
            09:51:21,338 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:139)
            09:51:21,354 ERROR [STDERR] at $Proxy116.processContact(Unknown Source)
            09:51:21,354 ERROR [STDERR] at com.logica.heca.lpr.services.facade.RuleEngineFacade.process(RuleEngineFacade.java:31)
            09:51:21,354 ERROR [STDERR] at com.logica.heca.lpr.dataLoader.DataLoaderThread.run(DataLoaderThread.java:129)
            09:51:21,354 ERROR [STDERR] Caused by: java.lang.RuntimeException: com.logica.heca.lpr.common.exception.LPRException: Failed
            to get RuleManagerRemote
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorH
            andler.java:113)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:623)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:131)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
            09:51:21,354 ERROR [STDERR] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:315)
            09:51:21,354 ERROR [STDERR] ... 8 more
            09:51:21,354 ERROR [STDERR] Caused by: com.logica.heca.lpr.common.exception.LPRException: Failed to get RuleManagerRemote
            09:51:21,354 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleMangerLocal(RuleBaseBuilder.java:95)
            
            09:51:21,354 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getDBRules(RuleBaseBuilder.java:82)
            09:51:21,369 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.buildRuleBase(RuleBaseBuilder.java:63)
            09:51:21,369 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleBase(RuleBaseBuilder.java:48)
            09:51:21,369 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleEngineBean.getRuleBase(RuleEngineBean.java:46)
            09:51:21,369 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            09:51:21,369 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            09:51:21,369 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            09:51:21,369 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
            09:51:21,369 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(LifecycleInvocationConte
            xtImpl.java:159)
            09:51:21,369 ERROR [STDERR] at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorH
            andler.java:109)
            09:51:21,369 ERROR [STDERR] ... 14 more
            09:51:21,369 ERROR [STDERR] Caused by: javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundExceptio
            n: No ClassLoaders found for: com.logica.heca.lpr.services.RuleManagerLocal (no security manager: RMI class loader disabled)]
            
            09:51:21,369 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:786)
            09:51:21,385 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
            09:51:21,385 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392)
            09:51:21,385 ERROR [STDERR] at com.logica.heca.lpr.ruleengine.RuleBaseBuilder.getRuleMangerLocal(RuleBaseBuilder.java:93)
            
            09:51:21,385 ERROR [STDERR] ... 24 more
            09:51:21,385 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.logica.heca.lpr.servi
            ces.RuleManagerLocal (no security manager: RMI class loader disabled)
            09:51:21,385 ERROR [STDERR] at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:535)
            09:51:21,385 ERROR [STDERR] at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
            09:51:21,385 ERROR [STDERR] at org.jboss.system.JBossRMIClassLoader.loadProxyClass(JBossRMIClassLoader.java:82)
            09:51:21,385 ERROR [STDERR] at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
            09:51:21,385 ERROR [STDERR] at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
            09:51:21,385 ERROR [STDERR] at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
            09:51:21,385 ERROR [STDERR] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
            09:51:21,385 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
            09:51:21,400 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            09:51:21,400 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            09:51:21,400 ERROR [STDERR] at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
            09:51:21,400 ERROR [STDERR] at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
            09:51:21,400 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
            09:51:21,400 ERROR [STDERR] ... 27 more
            


            • 3. Re: java.lang.RuntimeException: java.lang.ClassCastException
              wolfgangknauf

              Hi,

              please post the content of the MBean archive (you can use "jar tf MyJar.jar" for this)
              Where in this jar (or included jars) are located the following classes: RuleManagerLocal, RuleBaseBuilder, RuleEngineBean and DataLoaderThread?

              I think you don't need to play with the Classloader, this should hopefully work out of the box. But I am not sure.

              Best regards

              Wolfgang

              • 4. Re: java.lang.RuntimeException: java.lang.ClassCastException

                Wolfgang Knauf,
                Where should i post jar file?, I am not able to find any upload link on this page.

                • 5. Re: java.lang.RuntimeException: java.lang.ClassCastException
                  wolfgangknauf

                  Hi,

                  I meant that you post the output of the "jar tf ..." command. This displays just the structure of the JAR.

                  Best regards

                  Wolfgang

                  • 6. Re: java.lang.RuntimeException: java.lang.ClassCastException

                    Hi,

                    I ran into the same problem.
                    But in my case the scoping didn't solve the problem.

                    I'm running two jboss servers:
                    One on a virtual machine (ubuntu-jeos, jboss5.1.0 GA). The other one on my windows (winXP, jboss5.0.1 GA).
                    I am developing 2 Applications on my windows with NetBeans6.7.
                    The fist is a Java EE project with one stateless session bean:

                    RemoteInterface:

                    
                    package de.aco.avc.ejb;
                    import javax.ejb.Remote;
                    
                    @Remote
                    public interface SessionBeanRemote {
                    
                     public String sayHello();
                    }
                    
                    


                    The Bean:
                    
                    package de.aco.avc.ejb;
                    
                    import javax.ejb.Stateless;
                    
                    @Stateless
                    public class SessionBean implements SessionBeanRemote {
                    
                     public String sayHello()
                     {
                     String hello = "IT WORKS!";
                     return hello;
                     }
                    
                    }
                    


                    First I 'm deploying this project on my windows jboss server. After that I'm sending the [PROJECT].ear file to the remote jboss on my linux which binds the jndi names like that:

                    +- EE-AVC (class: org.jnp.interfaces.NamingContext)
                     | +- SessionBean (class: org.jnp.interfaces.NamingContext)
                     | | +- remote (class: Proxy for: de.aco.avc.ejb.SessionBeanRemote)
                     | | +- remote-de.aco.avc.ejb.SessionBeanRemote (class: Proxy for: de.aco.avc.ejb.SessionBeanRemote)
                    


                    The second application is a java web project with one servlet to call the remote methods. It contains the .jar file of the EE application mentioned above plus:

                    * servlet-api.jar
                    * jbossall-client.jar
                    * jboss-j2ee.jar
                    * jboss-ejb3-proxy-client.jar

                    
                    package de.aco.avc.web;
                    
                    import de.aco.avc.ejb.SessionBean;
                    import de.aco.avc.ejb.SessionBeanRemote;
                    import java.io.IOException;
                    import java.io.PrintWriter;
                    import java.util.Properties;
                    import java.util.logging.Level;
                    import java.util.logging.Logger;
                    import javax.naming.InitialContext;
                    import javax.naming.NamingException;
                    import javax.rmi.PortableRemoteObject;
                    import javax.servlet.ServletException;
                    import javax.servlet.http.HttpServlet;
                    import javax.servlet.http.HttpServletRequest;
                    import javax.servlet.http.HttpServletResponse;
                    
                    public class AServlet extends HttpServlet {
                    
                     protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                     throws ServletException, IOException {
                     response.setContentType("text/html;charset=UTF-8");
                     PrintWriter out = response.getWriter();
                     String hello = "DOESNT WORK";
                     //String object = "NO OBJECT";
                     try {
                     try {
                    
                     Properties props = new Properties();
                     props.setProperty("java.naming.factory.initial",
                     "org.jnp.interfaces.NamingContextFactory");
                     props.setProperty("java.naming.factory.url.pkgs",
                     "org.jboss.naming:org.jnp.interfaces");
                    
                     //HOST
                     props.setProperty("java.naming.provider.url", "jnp://ubuntu-jeos.it-ng.local:1099");
                    
                     /*DEBUG
                     InitialContext icx = new InitialContext(props);
                     Object obj = (Object)icx.lookup("EE-AVC/SessionBean/remote");
                     object = obj.toString();
                     */
                    
                    
                    
                     SessionBeanRemote sbr = (SessionBeanRemote)icx.lookup("EE-AVC/SessionBean/remote");
                     hello = sbr.sayHello();
                    
                    
                     } catch (NamingException ex) {
                     Logger.getLogger(AServlet.class.getName()).log(Level.SEVERE, null, ex);
                     }
                    
                    
                     out.println("<html>");
                     out.println("<head>");
                     out.println("<title>Servlet AServlet</title>");
                     out.println("</head>");
                     out.println("<body>");
                     out.println("<h1>Servlet AServlet at " + request.getContextPath () + "</h1>");
                     //out.println("<h2>" + object +"</h2>");
                     out.println("<h2>" + hello +"</h2>");
                     out.println("</body>");
                     out.println("</html>");
                    


                    I am running and deplying this application on my windows.
                    The lookup works perfect but I can't cast the remote object reference to my SessionBeanRemote object.
                    Jboss throws an exception:
                    java.lang.ClassCastException: javax.naming.Reference cannot be cast to de.aco.avc.ejb.SessionBeanRemote
                    


                    For scoping I edited the jboss-app.xml for the EE project like this:
                     <loader-repository>
                     de.aco.avc.ejb:loader=Loader1
                     </loader-repository>
                    
                    

                    And the jboss-app.xml for the web project:
                     <class-loading>
                     <loader-repository>de.aco.avc.web:loader=Loader2</loader-repository>
                     </class-loading>
                    


                    I don't have any clue what i'm doing wrong. I also tried to run both applications on the same jboss, which works fine.

                    I hope this is enough information for you guys to see what my fault is.

                    Thanks,
                    Basti


                    • 7. Re: java.lang.RuntimeException: java.lang.ClassCastException
                      jaikiran

                       

                      * servlet-api.jar
                      * jbossall-client.jar
                      * jboss-j2ee.jar
                      * jboss-ejb3-proxy-client.jar


                      Remote these from the (both) application packaging. You don't need these since they are already shipped in AS.

                      One on a virtual machine (ubuntu-jeos, jboss5.1.0 GA). The other one on my windows (winXP, jboss5.0.1 GA).


                      So your server is 5.0.1.GA and the client is 5.1.0.GA. I remember there was an incompatibility between AS version in the 5.x series. Let me check which exact version caused the incompatibility.


                      • 8. Re: java.lang.RuntimeException: java.lang.ClassCastException

                        Thanks for the quick reply.

                        I will try to use the 5.1.0GA version on both machines tomorrow.