Question

I have this weird problem that throws not really useful errors. I'm trying to display data from Entity Bean in Primefaces table. I have two projects, one for front end, other one for backend. Thing is, the Entity Bean has @OneToMany and @ManyToOne relation, and they seem to cause the problems, because if I null them no errors happen, but I need that data so it's not a solution.

BACKEND:

Key parts of entity:

    @Entity
    @Table(name = "business_process_tasks")
    public class BusinessProcessTasks implements java.io.Serializable {
    ....
        @ManyToOne(fetch=FetchType.EAGER)
        @JoinColumn(name="process")
        public Process getProcess() {
        return process;
        }

        public void setProcess(Process process) {
            this.process = process;
        }

        @OneToMany(mappedBy = "processTask")
        public List<BusinessProcessTasksMeta> getMeta() {
            return meta;
        }

        public void setMeta(List<BusinessProcessTasksMeta> meta) {
            this.meta = meta;
        }
    }

Key parts of EJB:

@Override
public List<BusinessProcessTasks> getList(int processId) {
    EntityManager em = emf.createEntityManager();

    String q = "SELECT t from " + BusinessProcessTasks.class.getName() + " t where process="+processId;
    Query query = em.createQuery(q);
    List<BusinessProcessTasks> items = query.getResultList();

    for(int i = 0;i<items.size();i++){
        BusinessProcessTasks t = (BusinessProcessTasks) items.get(i);
                    //IF I SET THESE TO NULL NO ERRORS SHOW
        t.setProcess(null);
        t.setMeta(null);
    }

    em.close();
    return items;
}

FRONTEND:

Key parts of @ManagedBean:

@ManagedBean(name = "processTasksTableBean")
@ViewScoped
public class ProcessTasksTableBean {
    .....
    @PostConstruct
    void initialiseSession() {
        System.out.println("Bean running");

        FacesContext.getCurrentInstance().getExternalContext().getSession(true);
            //GETTING ID FROM URL
        HttpServletRequest request = (HttpServletRequest) FacesContext
                .getCurrentInstance().getExternalContext().getRequest();
        pageProcessId = Integer.parseInt(request.getParameter("id"));

        processTasksBeanRemote = doLookup();
        //ONLY PLACE IN PROJECT WHERE ERROR IS REFERENCED IN CONSOLE IS HERE
        processTasksList = processTasksBeanRemote.getList(pageProcessId);
    }
.....
}

Eclipse console - log is very long, if required I will post it all, now just key parts:

09:34:58,377 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-localhost-127.0.0.1-8189-3) Error Rendering View[/ProcessTasks.xhtml]: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters
Caused by: java.lang.ClassNotFoundException: org.hibernate.collection.internal.PersistentBag from [Module "deployment.bpmweb.war:main" from Service Module Loader]
09:34:58,403 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/bpmweb].[Faces Servlet]] (http-localhost-127.0.0.1-8189-3) Servlet.service() for servlet Faces Servlet threw exception: java.lang.ClassNotFoundException: org.hibernate.collection.internal.PersistentBag from [Module "deployment.bpmweb.war:main" from Service Module Loader]
Was it helpful?

Solution

Issue resolved, I downloaded latest Hibernate core from http://mvnrepository.com/artifact/org.hibernate/hibernate-core/4.3.4.Final and all seems fine. Quite wierd, since I add my Jboss runtime libs to each project through build path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top