java ee - CDI: ProxyObject ClassCastException when inject DAO -


i trying instantiate dao classes using cdi 1.0 in websphere 8.0. in workspace have ejb class located in ejb project calls dao class located in dao project. followed this example (in portuguese, sorry) used producer method. these classes:

the dao class (in dao project):

public class naturezadao extends basedao<naturezaorm> {      @inject     public naturezadao(entitymanager em) throws daoexception {         super(naturezaorm.class, em);     }      // ...  } 

the producer class (in dao project):

import java.io.serializable;  import javax.enterprise.context.applicationscoped; import javax.enterprise.context.requestscoped; import javax.enterprise.inject.disposes; import javax.enterprise.inject.produces; import javax.persistence.entitymanager; import javax.persistence.entitymanagerfactory; import javax.persistence.persistenceunit;  /**  * code extracted   * http://blog.caelum.com.br/acessando-multiplos-bancos-de-dados-com-jpa-e-cdi/  */ @applicationscoped public class entitymanagerproducer implements serializable {      @persistenceunit     private entitymanagerfactory factory;      @requestscoped     @produces     public entitymanager createentitymanager() {         system.err.println("\t\tentitymanagerproducer.createentitymanager()");         return factory.createentitymanager();     }      public void closeentitymanager(@disposes entitymanager manager) {         system.err.println("\t\tentitymanagerproducer.closeentitymanager()");         if (manager.isopen()) {             manager.close();         }     }  } 

the ejb class (in ejb project):

@stateless public class naturezaservicebean extends basesb implements naturezaservice {      @inject     private naturezadao naturezadao;      @override     @transactionattribute(transactionattributetype.not_supported)     public list<naturezaorm> listnaturezaspropositura() throws businessexception, entitynotfoundexception {         try {             return this.naturezadao.listbytipoativodeputado(                 tiponaturezaenum.me, simnaoenum.s, simnaoenum.s);         } catch (objectnotfounddaoexception e) {             throw new entitynotfoundexception(e);         } catch (daoexception e) {             throw new businessexception(e);         }     }      // ...  } 

when initialize server, apparently there no problem. however, when call ejb method, got exception:

[22/04/15 14:39:26:838 brt] 0000001a injectinjecti e   cwowb0102e: ocorreu um erro jcdi: org.javassist.tmp.java.lang.object_$$_javassist_0 incompatible javassist.util.proxy.proxyobject [22/04/15 14:39:26:839 brt] 0000001a businessexcep e   cntr0019e: ejb threw unexpected (non-declared) exception during invocation of method "listnaturezaspropositura". exception data: javax.ejb.ejbexception: injection failure; nested exception is: java.lang.classcastexception: org.javassist.tmp.java.lang.object_$$_javassist_0 incompatible javassist.util.proxy.proxyobject java.lang.classcastexception: org.javassist.tmp.java.lang.object_$$_javassist_0 incompatible javassist.util.proxy.proxyobject 

i not sure if makes difference, in both projects there beans.xml files in meta-inf directory.

any suggestion missing here?

thanks,

rafael afonso


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -