[JBoss Seam] - failed to lazily initialize a collection
by blabno
I have stateless bean (LocationBean) that provides access to data, and stateful action bean (CountryEditorBean) that has reference to stateless bean (Local interface). When I click a link on data table with list of entities that redirects me to page with edit form for that entity, I get exception that other aggregated entities cannot be fetched since session has been closed.
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: pl.labno.bernard.bidbull.locations.Region.towns, no session or session was closed
So I figure that LocationBean fetches list of entities, and closes session (but why?), or detatches that entities. They exist only in some seam context.
Then on editCountry.jspx there is an attempt to count number of Regions aggregated in that country entity. This causes the error, I think, since by default relations are lazy fetched.
Is my interpretation correct ?
I do not want to change fething policy, so what can I do to make things work ? Cutting LocationBean out is not an option for me.
@Stateless
| public class LocationBean implements LocationLocal {
| @PersistenceContext
| private EntityManager em;
| public void add(Country country) throws NonUniqueObjectException {
| if (em.find(Country.class, country.getId()) == null) {
| em.persist(country);
| } else {
| throw new NonUniqueObjectException(country.getId(), Country.class.getCanonicalName());
| }
| }
| public void add(Region region) {
| em.persist(region);
| }
| public void add(Town town) {
| em.persist(town);
| }
| public void update(Country country) {
| em.merge(country);
| }
| public void update(Region region) {
| em.merge(region);
| }
| public void update(Town town) {
| em.merge(town);
| }
| public void remove(Country country) {
| em.remove(country);
| }
| public void remove(Region region) {
| em.remove(region);
| }
| public void remove(Town town) {
| em.remove(town);
| }
| public List<Country> getCountries() {
| return em.createNamedQuery(Country.GET_COUNTRIES_QUERY).getResultList();
| }
| }
@Name("countryEditor")
| @Scope(ScopeType.CONVERSATION)
| @Stateful
| public class CountryEditorBean implements CountryEditorLocal {
| @In @Out
| private Country country;
| @EJB
| private LocationLocal locationBean;
| private Boolean error = false;
| @Begin(pageflow = "editCountry")
| public void editCountry() {}
| public void save() {
| locationBean.update(getCountry());
| }
| public Country getCountry() {
| return country;
| }
| public void setCountry(Country country) {
| this.country = country;
| }
| @Remove
| public void destroy() {}
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123843#4123843
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123843
18 years, 3 months
[JBoss jBPM] - Re: ajax4jsf support for JBPM
by mr.sathya
This is the complete web.xml file
| <?xml version="1.0"?>
| <web-app version="2.4"
| xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
| <!-- JbpmThreadsServlet -->
| <servlet>
| <servlet-name>JbpmThreadsServlet</servlet-name>
| <servlet-class>org.jbpm.web.JbpmThreadsServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
| <servlet-mapping>
| <servlet-name>JbpmThreadsServlet</servlet-name>
| <url-pattern>/threads</url-pattern>
| </servlet-mapping>
|
| <!-- jBPM FileServlet -->
| <servlet>
| <servlet-name>ProcessImageServlet</servlet-name>
| <servlet-class>org.jbpm.webapp.servlet.ProcessImageServlet</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>ProcessImageServlet</servlet-name>
| <url-pattern>/processimage</url-pattern>
| </servlet-mapping>
|
| <!-- jBPM DeployServlet -->
| <servlet>
| <servlet-name>DeployServlet</servlet-name>
| <servlet-class>org.jbpm.webapp.servlet.DeployServlet</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>DeployServlet</servlet-name>
| <url-pattern>/deploy</url-pattern>
| </servlet-mapping>
| <servlet>
| <servlet-name>UploadServlet</servlet-name>
| <servlet-class>org.jbpm.webapp.servlet.UploadServlet</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>UploadServlet</servlet-name>
| <url-pattern>/upload</url-pattern>
| </servlet-mapping>
|
| <!-- MyFaces JSF -->
| <listener>
| <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
| </listener>
| <servlet>
| <servlet-name>FacesServlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
| <servlet-mapping>
| <servlet-name>FacesServlet</servlet-name>
| <url-pattern>/faces/*</url-pattern>
| </servlet-mapping>
| <!--ajax implementation-->
| <context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>server</param-value>
| </context-param>
| <context-param>
| <param-name>org.ajax4jsf.SKIN</param-name>
| <param-value>classic</param-value>
| </context-param>
| <filter>
| <display-name>Ajax4jsf Filter</display-name>
| <filter-name>ajax4jsf</filter-name>
| <filter-class>org.ajax4jsf.Filter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>ajax4jsf</filter-name>
| <servlet-name>Faces Servlet</servlet-name>
| <dispatcher>REQUEST</dispatcher>
| <dispatcher>FORWARD</dispatcher>
| <dispatcher>INCLUDE</dispatcher>
| </filter-mapping>
| <!--ajax implementation-->
|
|
| <filter>
| <filter-name>LogFilter</filter-name>
| <filter-class>org.jbpm.webapp.filter.LogFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>LogFilter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <filter>
| <filter-name>JbpmContextFilter</filter-name>
| <filter-class>org.jbpm.web.JbpmContextFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>JbpmContextFilter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <filter>
| <filter-name>AuthenticationFilter</filter-name>
| <filter-class>org.jbpm.webapp.filter.AuthenticationFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>AuthenticationFilter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <!--tomahawk editings-->
| <context-param>
| <param-name>facelets.LIBRARIES</param-name>
| <param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
| </context-param>
|
| <!--<filter>
| <filter-name>extensionsFilter</filter-name>
| <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
| </filter>-->
|
| <!-- Filter Mappings -->
| <!--<filter-mapping>
| <filter-name>extensionsFilter</filter-name>
| <url-pattern>*.jsf</url-pattern>
| </filter-mapping>
| <filter-mapping>
| <filter-name>extensionsFilter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>-->
|
|
| <filter>
| <filter-name>MyFacesExtensionsFilter</filter-name>
| <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
| <init-param>
| <param-name>maxFileSize</param-name>
| <param-value>20m</param-value>
| <description>Set the size limit for uploaded files.
| Format: 10 - 10 bytes
| 10k - 10 KB
| 10m - 10 MB
| 1g - 1 GB
| </description>
| </init-param>
| </filter>
|
| <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
| <filter-mapping>
| <filter-name>MyFacesExtensionsFilter</filter-name>
| <url-pattern>*.jsp</url-pattern>
| </filter-mapping>
|
| <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
| <filter-mapping>
| <filter-name>MyFacesExtensionsFilter</filter-name>
| <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
| </filter-mapping>
|
|
|
| </web-app>
|
pls help me with proper documentation on ajax4jsf integration with jbpm..
Thanks In advance...
Regards,
Sathya,
India
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123839#4123839
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123839
18 years, 3 months
[JBoss Seam] - EJBQL question
by kesson
Hey all,
I have some entity, let's say, User, and other entity, Community, with many-to-many relationship between them. The user can be member in one, several or none communities. So, class User has a property communities, of SET type, with all appropriate getters and setters. I want to be able to make select ( by ejbql) for all users that have empty sets of communities, or, alternatively, do have non-empty set. How can I achieve it by ejbql query? On the web side, I have some radio buttons, let's say "Has communities" and "Has no community", and, of cource, I would like to link it to this restriction of ejbql.
Thanks in advance
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123838#4123838
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123838
18 years, 3 months