Primefaces LazyDataModel produces different output local tha

UI Components for JSF
Post Reply
SimonC
Posts: 2
Joined: 18 Apr 2013, 13:54

18 Apr 2014, 13:14

I have a problem where I use Primefaces 4.0 on wildfly8 (jboss 8) server.

I have the same server localy with the same settings than a remote server where the app would be deployed in porduction.

When I deploy the app to remote server the p:dataTable are empty. Only the tables that uses primefaces LazyDataModel are empty.

There is no error in log.

I have also tried to deploy the maven build ear taht I deploy to reomote server also on a local server and localy is working as it should. Obviously there si some difference on the remote server but I can not see what it could be, the standalone.xml are the same localy and remotly

Any hints what coud cause this strange behaviour?

I have put some prints to see what is heppening in the code and in the count method I get 4520 returned, so the sql is working ok the porbem is thet in the xhtml if I put #{billsBean.billsData.rowCount} just before the table where the data should be I get 0. On the local macine for the same view and the same code I get 4520

So it looks like the data gets lost somewhere in the rendering of the table.


Code: Select all

@Named
@Stateless
public class LazyBillsDataModel extends LazyDataModel<Bill> implements Serializable {

private static final long serialVersionUID = -6488655263171321725L;

@Inject
@DomainsDB
private EntityManager em;

@EJB
BillHandler billHandler;

@Inject private Logger log;

public LazyBillsDataModel() {
    super();
}

@Override
public List<Bill> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
    System.out.println(">>>>>>>> enetering load data for BILLS");
    log.debug(">>>>>>>> enetering load data for BILLS");

    if (sortField == null || sortField.equals("")) {
        sortField = "bill.dateCreate";
    }

    List<Bill> data = selectData(first, pageSize, sortField, DataUtilsWeb.transformSortOrder(sortOrder), filters);
    // row count
    this.setRowCount(count(filters));

    return data;
}

private int count(Map<String, String> filters) {
    String hql = "select count(bill.idBill) from Bill bill ";
    if (filters != null && filters.size() > 0) {
        hql += " where " + prepereWhereFilters(filters);
    }

    Query querry = em.createQuery(hql);
    fillQueryWitkFilterData(querry, filters);

    System.out.println(">>>>>>>> count " + ((Long) querry.getSingleResult()).intValue());

    return ((Long) querry.getSingleResult()).intValue();
}

@SuppressWarnings("unchecked")
private List<Bill> selectData(int first, int pageSize, String sortField, String sortOrder, Map<String, String> filters) {

    List<Bill> data = new ArrayList<Bill>();

    String hql = "select bill from Bill bill left join fetch bill.organization left join fetch bill.billType left join fetch bill.billStatus ";

    if (filters != null && filters.size() > 0) {
        hql += " where " + prepereWhereFilters(filters);
    }

    // sorting
    if (sortField != null && !sortField.equals("")) {
        hql += " order by " + sortField;
        if (sortOrder != null && !sortOrder.equals("")) {
            hql += " " + sortOrder;
        }
    }

    Query querry = em.createQuery(hql);
    fillQueryWitkFilterData(querry, filters);

    // define query boundaries
    querry.setFirstResult(first);
    querry.setMaxResults(pageSize);
    data = (List<Bill>) querry.getResultList();

    System.out.println(">>>>>>>> BILLS laoded num : " + data.size());
    log.debug(">>>>>>>> BILLS laoded num : " + data.size());

    return data;
}

 ......
 }

SimonC
Posts: 2
Joined: 18 Apr 2013, 13:54

18 Apr 2014, 14:46

I've solved the issue

It looks like the standalone.xml have changed in the wildfly 8.0 FINAL release, localy I had the 8.0 FINAL from 20.2.2014 and on server I had 8.0 FINAL from 18.4.2014

And after comparing the standalone.xml from both servers they differed

So i started merging them and I fout that this part wass missing from ejb3 subsystem

Code: Select all

<subsystem xmlns="urn:jboss:domain:ejb3:2.0>

  <stateless>
       <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
  </stateless>
not shure what this flag does but after inserting this text the primfaces table apeared full of data.

ifloor
Posts: 5
Joined: 31 Aug 2013, 06:38

18 Jun 2015, 19:54

Thank you very much!
I know it is a little bit old, but your advice was perfect!
I searched a lot in the Internet, but didnt find anything, and your suggestion solved the problem!

Just to let things easier:
The code should be inside session-bean, like:

Code: Select all

<subsystem xmlns="urn:jboss:domain:ejb3:2.0">
   <session-bean>
      ...
      <stateless>
         <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
      </stateless>
   </session-bean>
   ...
</subsystem>
And looking why this happen, i found the meaning of the stateless from JBoss Wildfly configuration page (https://docs.jboss.org/author/display/W ... tion+guide):
<stateless>
This element is used to configure the instance pool that is used by default for stateless session beans. If it is not present stateless session beans are not pooled, but are instead created on demand for every invocation. The instance pool can be overridden on a per deployment or per bean level using jboss-ejb3.xml or the org.jboss.ejb3.annotation.Pool annotation. The instance pools themselves are configured in the <pools> element.
Thank you again, and I hope to help anyone in the same situation.

Igor.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests