6 Replies Latest reply on Nov 27, 2012 6:58 AM by mathewrock

    How Test a BackingBean when persistence.xml is in other project.

    mathewrock Newbie

      Hi all.

      I have a problem to test BackingBean with arquillian. The problem are that I`m using arquitecture EJB3.0 (one project with xhtml and backingbean and other with Daos and Entities)  when I wanna testing my Backing bean in "createDeployment" I put classes that I use but it can´t recognize ".addAsResource("test-persistence.xml", "META-INF/persistence.xml")" and it give me that error


      Target state: deploy failed on Server AdminServer

      weblogic.application.naming.ReferenceResolutionException: [J2EE:160200]Error resolving ejb-ref "Dao" from module "test.war" of application "test". The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed becaxfound to implement the "DaoLocal" interface. Link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.


      Any idea????



          public static JavaArchive createDeployment() {

              return ShrinkWrap.create(JavaArchive.class, BackingBean.class.getName() + "test.jar")

                     .addClasses( BackingBean.class, Dao.class, Entity.class)

                     .addAsResource("test-persistence.xml", "META-INF/persistence.xml")

                     .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");


        • 1. Re: How Test a BackingBean when persistence.xml is in other project.
          Vineet Reynolds Apprentice

          I see you're trying to work with WebLogic, but which version of the container are you using? If you're using 10.3.x i.e. a JEE 5 compliant container, then the deployment will fail if you attempt to place an EJB in a WAR; support for EJBs in a WAR arrived only in JEE6/WLS12c. Under the hood, the JavaArchive (.jar) that you create, will be packaged in the WEB-INF/lib of a WAR and deployed. If you want to get this to work in WLS 10.3.x you'll need to create an EAR with an EJB-JAR module containing your EJBs, and a WAR containing your EJB client class (your backing bean and a web.xml file that has an ejb-ref/ejb-local-ref element).

          • 2. Re: How Test a BackingBean when persistence.xml is in other project.
            mathewrock Newbie

            I´m using wls12C:







            I`m not sure when declare createDeployment return WebArchive o JavaArchive (witch is diffence?) (I´m noob with arquillian) if this affect dor this problem or not? or if test should will go in EAR or CLI. In examples all view with  arquitecture EJB3.1 but no EJB 3.0. Do you know any example arquillian with this arquiteture??? That probably very usefull.


            Thx for answer.

            • 3. Re: How Test a BackingBean when persistence.xml is in other project.
              Vineet Reynolds Apprentice

              With WLS12c, you probably shouldnt get that deployment error that you're facing if you're using EJB 3.1 APIs. Also, it probably has nothing to do with the persistence.xml file unless the deployment is missing additional dependent classes and/or a WLS datasource.


              Is it possible for you to post a testcase that I could use to reproduce this error? I'd like to see if you're using the EJB 3.0 APIs in any particular manner that would result in this error.


              And to answer you question about using a WebArchive or a JavaArchive, you'll just need to remember that Arquillian cannot deploy an individual JAR file; in fact most containers will not allow for that, especially for EJB JARs. Therefore, Arquillian wraps up the JavaArchive (a JAR) inside a WAR, along with the testclasses, enhances this WAR with additional archives (other Arquillian extensions) as applicable. In WLS 10.3.x, this would matter when an EJB with a local view present in the JAR, since it would not be bound to the JNDI tree. When you attempt to reference the EJB from your test class (located in the WAR), you would be required to make entries in web.xml; an example is in the testsuite used by the WLS 10.3.x container.

              1 of 1 people found this helpful
              • 4. Re: How Test a BackingBean when persistence.xml is in other project.
                mathewrock Newbie

                This are TestCase:



                public class InformeRecMedicoTripulanteBBArquillianTest {



                    public static JavaArchive createDeployment() {

                        return ShrinkWrap.create(JavaArchive.class, InformeEntrenamientosTripulanteBB.class.getName() + "test.jar")



                                        InformeRecMedicoTripulanteBB.class, ControllerReportBase.class,

                                        ControllerReportListadoReconocimientoMedico.class, CuadroResumenBB.class,


                                        //clases padres.

                                        IBackingBean.class, EntidadSiucom.class,



                                        HistoricoTripulanteService.class, UsuarioServiceLocal.class,

                                        UnidadAplicacionService.class, CompetenciaLinguisticaService.class,

                                        RMedicoTripulanteService.class, HistCargoTripulanteService.class,


                                        HistoricoTripulante.class, HistoricoTripulantePK.class,

                                        EstadoTripulante.class, HorasInicializadasTripulante.class,

                                        HorasInicializadasTripulantePK.class, HistCargoTripulante.class,

                                        HistCargoTripulantePK.class, CargoTripulante.class,

                                        UnidadAerea.class, SistemaArmasParticular.class,

                                        Aeronave.class, Usuario.class,

                                        TripulanteEntrenamiento.class, UnidadAplicacion.class,

                                        HorasFuncion.class, CompetenciaLinguistica.class,

                                        ReconocimientoMedicoTripulante.class, ReconocimientoMedicoTripulantePK.class,

                                        TripulanteReconocimientoMedico.class, UnidadAerea.class,

                                        TipoFuerzas.class, AdaptadorEstacionCarga.class,

                                        TipoFAC.class, Empleo.class,

                                        SistemaArmasInspeccion.class, Diario.class,

                                        DiarioPK.class, NivelEstado.class,

                                        NivelEstadoPK.class, AeronaveBaja.class,

                                        AeronaveBajaPK.class, ConfiguracionAeronave.class,

                                        ConfiguracionAeronavePK.class, ElementoConfiguracion.class,

                                        ElementoConfiguracionPK.class, Pylon.class,

                                        ArmaCargaEstacion.class, HistoricoConfiguracionAeronave.class,

                                        HistoricoConfiguracionAeronavePK.class, GrupoConfiguracion.class,

                                        BaseAerea.class, Localidad.class,

                                        SistemaArmasGenerico.class, SistemaArmasInspeccionPK.class,

                                        CalificacionOperativa.class, Indicativo.class,

                                        TipoInspeccion.class, SitAdministrativa.class,

                                        AjenoEA.class, TipoAeronave.class,

                                        MotivoPerdidaCalificacion.class, EstadoMantenimiento.class,

                                        SistemaArmasParticular.class, MandoGenerador.class,

                                        Mac.class, SituacionAeronave.class,

                                        Pais.class, GrupoSanguineo.class,

                                        NivelMantenimiento.class, Aeropuerto.class,

                                        TipoAvion.class, Tripulante.class,

                                        ModoAcceso.class, TipoReconocimientoMedico.class,

                                        AptitudReconocimientoMedico.class, AeronaveInspeccion.class,



                                        HistCargoTripulanteDaoLocal.class, EscuadronDaoLocal.class,

                                        TipoEntrenamientoDaoLocal.class, UnidadAereaDaoLocal.class,

                                        SistemaArmasParticularDaoLocal.class, TipoReconocimientoMedicoDaoLocal.class,

                                        CargoTripulanteDaoLocal.class, HorasHHVDaoLocal.class,

                                        HorasHTRDaoLocal.class, HorasHOCNavDaoLocal.class,

                                        HorasOCHNavDaoLocal.class, HorasHOCNctDaoLocal.class,

                                        HorasOCHNctDaoLocal.class, HorasHOCInsDaoLocal.class,

                                        HorasOCHInsDaoLocal.class, HorasHOCCmdDaoLocal.class,

                                        HorasOCHCmdDaoLocal.class, HistoricoTripulanteDaoLocal.class,

                                        CompetenciaLinguisticaDaoLocal.class, UnidadAplicacionDaoLocal.class,

                                        RecMedicoTripulanteDaoLocal.class, GenericoDAOLocal.class,






                                        net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.class, net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.class,

                                        net.sf.jasperreports.engine.JRRewindableDataSource.class, net.sf.jasperreports.engine.JRDataSource.class,

                                        net.sf.jasperreports.engine.JasperPrint.class, net.sf.jasperreports.engine.JRPropertiesHolder.class,

                                        net.sf.jasperreports.engine.JRException.class, net.sf.jasperreports.engine.design.JasperDesign.class,

                                        net.sf.jasperreports.engine.design.events.JRChangeEventsSupport.class, net.sf.jasperreports.engine.base.JRBaseReport.class,

                                        net.sf.jasperreports.engine.JRReport.class, net.sf.jasperreports.engine.JRDefaultFontProvider.class,

                                        net.sf.jasperreports.engine.JRDefaultStyleProvider.class, net.sf.jasperreports.engine.JasperReport.class,

                                        net.sf.jasperreports.engine.util.JRVisitorSupport.class, net.sf.jasperreports.engine.JRVisitor.class,


                                        ea.ciges.siucom.zsv.ejb.exceptions.dispatchers.ErrorDispatcher.class, ea.ciges.siucom.zsv.ejb.exceptions.factory.BDFactory.class


                                .addAsResource("test-persistence.xml", "META-INF/persistence.xml")

                                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");



                    public void asd() { }


                • 5. Re: How Test a BackingBean when persistence.xml is in other project.
                  Vineet Reynolds Apprentice

                  Ah well, I dont think I'll be able to reproduce the error unless I have the source for those classes. But never mind - you may want to look at the @EJB annotations used in those classes. One or more of them, especially the ones referencing "Dao", are not resolved correctly during deployment.