2 Replies Latest reply on Jul 9, 2007 7:10 AM by M Z

    Seems some kind of config error with BEANs, please help

    M Z Newbie

      The following test (after applying http://jira.jboss.com/jira/browse/JBSEAM-1494, other way the error message could not be found for locale)

      @Test
      public void test() throws Exception {
      new FacesRequest() {
      @Override
      protected void invokeApplication() {
      invokeMethod("#{Dumper.dump}");
      }

      @Override
      protected void renderResponse() throws Exception {
      Object facesMessages = getValue ("#{Dumper.report}");

      // FacesMessages facesMessages = (FacesMessages) getValue ("#{Dumper.facesMessages}");
      // List msgs = facesMessages.getCurrentGlobalMessages();
      // boolean found = false;
      // for (FacesMessage message: msgs) {
      // String detail = message.getSummary();
      // System.out.println ("Detail - "+detail);
      // if (detail.indexOf("Finished in")>-1) {
      // found = true;
      // }
      // }
      // assert found;
      }


      }.run();
      }

      Successfully calls the method, but cannot getValue with exception

      javax.el.PropertyNotFoundException: Property 'report' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_0
      at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:199)
      at javax.el.BeanELResolver.property(BeanELResolver.java:273)
      at javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
      at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      at org.jboss.seam.jsf.SeamApplication.evaluateExpressionGet(SeamApplication.java:324)
      at org.jboss.seam.mock.BaseSeamTest$Request.getValue(BaseSeamTest.java:412)

      Property declared as

      @Out
      private Map<String, DataUpdateReport> report;

      (the same with the others,
      @In @Out
      private FacesMessages facesMessages;
      for example.
      Adding getters\setters doesn't help)

        • 1. Re: Seems some kind of config error with BEANs, please help
          Pete Muir Master

          Try posting the whole stack trace, the whole code of the beans involved and use the [ code ] tags

          • 2. Re: Seems some kind of config error with BEANs, please help
            M Z Newbie

            The exception

            javax.el.PropertyNotFoundException: Property 'report' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_0
             at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:199)
             at javax.el.BeanELResolver.property(BeanELResolver.java:273)
             at javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
             at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
             at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
             at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
             at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
             at org.jboss.seam.jsf.SeamApplication.evaluateExpressionGet(SeamApplication.java:324)
             at org.jboss.seam.mock.BaseSeamTest$Request.getValue(BaseSeamTest.java:412)
             at dk.company.product.test.DumperTest$1.renderResponse(DumperTest.java:77)
             at org.jboss.seam.mock.BaseSeamTest$Request.renderResponsePhase(BaseSeamTest.java:562)
             at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:548)
             at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:466)
             at dk.company.product.test.DumperTest.test(DumperTest.java:100)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
             at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
             at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
             at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
             at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
             at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
             at org.testng.TestRunner.runWorkers(TestRunner.java:678)
             at org.testng.TestRunner.privateRun(TestRunner.java:624)
             at org.testng.TestRunner.run(TestRunner.java:495)
             at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
             at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
             at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
             at org.testng.SuiteRunner.run(SuiteRunner.java:190)
             at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
             at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
             at org.testng.TestNG.run(TestNG.java:699)
             at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
             at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)


            the test class

            package dk.company.product.test;
            
            import java.util.List;
            
            import javax.faces.application.FacesMessage;
            import javax.persistence.EntityManager;
            import javax.persistence.EntityManagerFactory;
            import javax.persistence.Persistence;
            
            import org.jboss.seam.core.FacesMessages;
            import org.jboss.seam.log.Logging;
            import org.jboss.seam.mock.SeamTest;
            import org.testng.annotations.Test;
            
            import dk.company.product.DumperBean;
            
            public class DumperTest extends SeamTest {
            
             @Test
             public void test_1_COMPONENT_Dumper () throws Exception {
            
             //Name got from persistence.xml, tag <persistence-unit
             EntityManagerFactory emf = Persistence.createEntityManagerFactory("truetrade");
             final EntityManager em = emf.createEntityManager();
            
             em.getTransaction().begin();
            
             DumperBean dumperBean = new DumperBean ();
             dumperBean.set4UnitTestEntityManager(em);
             dumperBean.set4UnitTestFacesMessages(new FacesMessages());
             dumperBean.set4UnitTestLog(Logging.getLog(DumperBean.class));
            
             dumperBean.dump();
            
             em.getTransaction().commit();
             em.close();
            
             FacesMessages facesMessages = dumperBean.get4UnitTestFacesMessages();
             List<FacesMessage> msgs = facesMessages.getCurrentMessages();
             boolean found = false;
             for (FacesMessage message: msgs) {
             String summary = message.getSummary();
             System.out.println ("Detail - "+summary);
             if (summary.indexOf("Finished in")>-1) {
             found = true;
             }
             }
             assert found;
            
             }
            
            
             @Test
             public void test() throws Exception {
             new FacesRequest() {
             @Override
             protected void invokeApplication() {
             invokeMethod("#{Dumper.dump}");
             }
            
             @Override
             protected void renderResponse() throws Exception {
             @SuppressWarnings("unused")
             Object facesMessages = getValue ("#{Dumper.report}");
            
            // FacesMessages facesMessages = (FacesMessages) getValue ("#{Dumper.facesMessages}");
            // List<FacesMessage> msgs = facesMessages.getCurrentGlobalMessages();
            // boolean found = false;
            // for (FacesMessage message: msgs) {
            // String detail = message.getSummary();
            // System.out.println ("Detail - "+detail);
            // if (detail.indexOf("Finished in")>-1) {
            // found = true;
            // }
            // }
            // assert found;
             }
            
            
             }.run();
             }
            
            }


            and the tested bean

            package dk.company.product;
            
            import java.util.ArrayList;
            import java.util.LinkedHashMap;
            import java.util.List;
            import java.util.Map;
            
            import javax.ejb.Stateless;
            import javax.persistence.EntityManager;
            import javax.persistence.Query;
            
            import org.jboss.seam.annotations.In;
            import org.jboss.seam.annotations.Logger;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.core.FacesMessages;
            import org.jboss.seam.log.Log;
            
            import dk.company.product.data.Address;
            import dk.company.product.data.Catalog;
            import dk.company.product.data.Category;
            import dk.company.product.data.Company;
            import dk.company.product.data.CompanyCatalogShop;
            import dk.company.product.data.CompanyCatalogShopId;
            import dk.company.product.data.FavoriteList;
            import dk.company.product.data.Item;
            import dk.company.product.data.ItemStorageDetail;
            import dk.company.product.data.Shop;
            import dk.company.product.data.Storage;
            import dk.company.product.data.User;
            import dk.company.product.dict.ItemUnitType;
            import dk.company.product.dict.UserStatus;
            import dk.company.product.util.TestUtil;
            
            @Stateless
            @Name("Dumper")
            public class DumperBean implements Dumper {
            
             private static final Class<?>[] TABLE = {
             ItemStorageDetail.class, Storage.class, Address.class, CompanyCatalogShop.class, Item.class, Category.class,
             Catalog.class, User.class, Company.class, FavoriteList.class, Shop.class
             };
            
             private static final String[] CATEGORY_LEVEL_1 = {
             "Træ","Byggematerialer","Isenkram","Have & fritid","Hjemmets udstyr","Øvrige varer"
             };
             private static final String[][] CATEGORY_LEVEL_2 = {
             {},
             {"Cement & kalk","Betonvarer","Teglvarer","Øvrige bygningsdele af sten","Keramiske produkter","Fibercementvarer (eternit)","Gipsvarer","Træelementer","Træbaserede pla-der","Finer","Døre & vinduer","Færdige bygningsdele","Skabselementer","Isoleringsmaterialer","Pap og flydende sorte produkter","Maling, lim, fuge og gulvbelæg-ning","Plastmaterialer","Glas","Metalprofiler & plader"}
             };
             private static final String[][][] CATEGORY_LEVEL_3 = {
             {{}},
             {{"Cement","Kalk","Facadepuds","Mørtel t/mur","Beton","Kridt & gips","Sten & grus"}}
             };
            
             private static final String[][] ITEM = {
             {"SÆK", "40", " 25.0", "GULLEX A MURCEMENT 25KG", "5146882", "3010-5146882", "80.00"},
             {"PS", "42", " 25.0", "AALBORG CEMENT BASIS 25KG", "8321663", "3010-8321663", "46.05"},
             {"SÆK", "42", " 25.0", "AALBORG CEMENT RAPID 25KG", "8321689", "3010-8321689", "49.00"},
             {"SÆK", "42", " 25.0", "AALBORG CEMENT MESTER LAVALKALI 25KG", "8321721", "3010-8321721", "50.00"},
             {"SÆK", "42", " 25.0", "AALBORG WHITE HVID 25KG", " 8919599", "3010-8919599", " 77.00"}
             };
            
             private static final String[][] ADDRESS_STORAGE = {
             {"Hedereslevej, 37", "Kolding", "6000"},
             {"Koldingvej, 232", "Årchus", "6200"},
             };
            
             @Logger
             private Log log;
            
             @In
             private EntityManager entityManager;
            
             @In
             private FacesMessages facesMessages;
            
             private Map<String, DataUpdateReport> report;
            
             public String dump() {
             report = new LinkedHashMap<String, DataUpdateReport>();
             long start = System.currentTimeMillis();
             log.info("Dumper.dump() action called");
            
             StringBuffer sb = new StringBuffer("Status: ");
            
             Query query;
            
             for (int i = 0; i < TABLE.length; i++) {
             query = entityManager.createQuery("delete from " + TABLE.getName());
             report(TABLE, query.executeUpdate());
             }
            
             for (int i = 0; i < 3; i++) {
             Company company = new Company("Company #" + i, "ID" + i);
             persist(company);
            
             List<FavoriteList> fl = new ArrayList<FavoriteList>();
             for (int j = 0; j < 2; j++) {
             FavoriteList favoriteList = new FavoriteList("FavoriteList #" + (i * 10 + j), company);
             persist(favoriteList);
             fl.add(favoriteList);
             }
            
             for (int j = 0; j < 3; j++) {
             User user = new User(UserStatus.Active, "ID" + (10 * i + j));
             user.setCompany(company);
             persist(user);
             }
             for (int j = 0; j < 3; j++) {
             Catalog catalog = new Catalog("Catalog #" + (i * 10 + j), "SyncID#" + (i * 10 + j));
             persist(catalog);
             Shop shop = new Shop("Shop #" + i * 10 + j);
             persist(shop);
            
             List<Storage> storageList = new ArrayList<Storage>();
            
             for (int aId = 0; aId < ADDRESS_STORAGE.length; aId++) {
             Address address = new Address();
             address.setStreet(ADDRESS_STORAGE[aId][0]);
             address.setCity(ADDRESS_STORAGE[aId][1]);
             address.setZip(ADDRESS_STORAGE[aId][2]);
             persist(address);
            
             Storage storage = new Storage(shop, address, "Storage of shop " + shop.getTitle() + " with #" + aId, "SyncID#" + Math.random());
             persist(storage);
            
             storageList.add(storage);
             }
            
             CompanyCatalogShopId ccsId = new CompanyCatalogShopId(company.getId(), catalog.getId(), shop.getId());
             CompanyCatalogShop ccs = new CompanyCatalogShop();
             ccs.setId(ccsId);
            
             persist(ccs);
            
             for (int k = 0; k < CATEGORY_LEVEL_1.length; k++) {
             Category category = new Category(CATEGORY_LEVEL_1[k], "SyncID#" + (i * 10 + j * 3 + k));
             category.getCatalogs().add(catalog);
             persist(category);
             for (int k2 = 0; CATEGORY_LEVEL_2.length > k && k2 < CATEGORY_LEVEL_2[k].length; k2++) {
             Category category2 = new Category(CATEGORY_LEVEL_2[k][k2], "SyncID#" + (i * 10 + j * 3 + k * 10 + k2));
             category2.getCategoriesForCategoryParentId().add(category);
             persist(category2);
            
             for (int k3 = 0; CATEGORY_LEVEL_3.length>k && CATEGORY_LEVEL_3[k].length > k2 && k3 < CATEGORY_LEVEL_3[k][k2].length; k3++) {
             Category category3 = new Category(CATEGORY_LEVEL_3[k][k2][k3], "SyncID#" + (i * 10 + j * 3 + k * 10 + k2 * 10 + k3));
             category3.getCategoriesForCategoryParentId().add(category2);
             persist(category3);
             if (k3 == 0) {
             for (int i1 = 0; i1 < ITEM.length; i1++) {
             Item item = new Item(ITEM[i1][3], ItemUnitType.TYPE1, "SyncID#" + (i * 10 + j * 5 + k * 20 + i1));
             item.setNumber1(ITEM[i1][4]);
             item.setNumber2(ITEM[i1][5]);
             item.getCategories().add(category2);
             item.setUnitSize(Integer.parseInt(ITEM[i1][1]));
             persist(item);
            
             for (int l = 0; l < storageList.size(); l++) {
             ItemStorageDetail itemStorageDetail = new ItemStorageDetail(item, storageList.get(l), l > 0, Doub-le.parseDouble(ITEM[i1][6]), "SyncID#" + String.valueOf(TestUtil.getRandomIndex(100000)));
             persist(itemStorageDetail);
             }
            
             if (Math.random() < 0.1) {
             FavoriteList favoriteList = TestUtil.getRandomElement(fl);
             favoriteList.getItems().add(item);
             persist(favoriteList);
             }
             }
             }
             }
             }
             }
             }
            
             }
            
             for (String table : report.keySet()) {
             DataUpdateReport updateReport = report.get(table);
             sb.append(updateReport);
             sb.append("\n");
             }
            
             long duration = (System.currentTimeMillis() - start);
             facesMessages.add(sb.toString());
             facesMessages.add("Finished in #0 ms", duration);
            
             return null;
             }
            
             private void persist(Object object) {
             reportCreateInc(object.getClass().getSimpleName());
             entityManager.persist(object);
             }
            
             private void reportCreateInc(String table) {
             DataUpdateReport updateReport = report.get(table);
             if (updateReport != null) {
             updateReport.setInsert(updateReport.getInsert() + 1);
             }
             }
            
             private void report(Class<?> clazz, int deleteCount) {
             DataUpdateReport updateReport = report.get(clazz.getSimpleName());
             if (updateReport == null) {
             updateReport = new DataUpdateReport();
             report.put(clazz.getSimpleName(), updateReport);
             }
             updateReport.setTable(clazz.getSimpleName());
             updateReport.setDelete(deleteCount);
             }
            
             private class DataUpdateReport {
             private String table;
             private int delete;
             private int insert;
            
             public int getDelete() {
             return delete;
             }
            
             public void setDelete(int delete) {
             this.delete = delete;
             }
            
             public int getInsert() {
             return insert;
             }
            
             public void setInsert(int insert) {
             this.insert = insert;
             }
            
             public String getTable() {
             return table;
             }
            
             public void setTable(String table) {
             this.table = table;
             }
            
             public String toString() {
             StringBuffer sb = new StringBuffer();
             sb.append("Table " + table + ", deleted " + delete + ", created " + insert);
             return sb.toString();
             }
             }
            
             public void set4UnitTestEntityManager(EntityManager entityManager) {
             this.entityManager = entityManager;
             }
            
             public FacesMessages get4UnitTestFacesMessages() {
             return facesMessages;
             }
            
             public void set4UnitTestFacesMessages(FacesMessages facesMessages) {
             this.facesMessages = facesMessages;
             }
            
             public Log get4UnitTestLog() {
             return log;
             }
            
             public void set4UnitTestLog(Log log) {
             this.log = log;
             }
            
            }
            


            Also, I've tried to add @Out annotation or getters & setter. It didn't help.