convertEntity, lazy loading in view rendering and ejb transaction
gcollin.gerardcollin.gmail.com Nov 20, 2009 12:22 AMHello,
I have some problems using Seam and EJB 3.0 beans in my project, and would like some help.
I have the same web application running in 2 configurations: One is running Icefaces Seam JPA Hibernate under tomcat for development purpose.
But using Maven magic, I can generate another delivery, using an ear, a war, an ejb-jar containing entities and stateless EJB 3 session beans. I then run this delivery under JBoss 4.2
The application works fine in Tomcat, using a .war only. But in JBoss, I get some pages not working.
I noticed to things using EJB configuration:
- convertEntity throws big NullpointerException. I've seen in the doc,
http://docs.jboss.org/seam/2.1.2/reference/en-US/html/controls.html#d0e28276, that I must configure the entitymanager for convertEntity to work. But with Ejb configuration, I don't have an entityManager managed by Seam, because it's the JBoss server that does the work.
=> It seems convertEntity don't work with EJBs, even 3.0 ? I can't find nowhere documentation for this.... And the EJB sample (booking), don't use convertEntity.....
- Then, I have a page where I display data that is lazy-loaded. I mean Hibernate must do some more queries to get the data for display. While this works very well under Tomcat, I get lazyinit errors using Ejb.
=> Documentation says Seam manage the lazyloading stuff for display view, and it does for jpa entities, but does it do the same for EJB ?
For info, here is my components.xml:
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:international="http://jboss.com/products/seam/international"
xmlns:ui="http://jboss.com/products/seam/ui"
xsi:schemaLocation=
"http://jboss.com/products/seam/ui http://jboss.com/products/seam/ui-2.1.xsd
http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
http://jboss.com/products/seam/international http://jboss.com/products/seam/international-2.1.xsd">
<core:init debug="false" jndi-pattern="amanda2/#{ejbName}/local" />
<core:ejb-transaction />
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="cid" />
<security:identity authenticate-method="#{loginPage.checkLogin}" />
<!-- Support for retrying the page after login -->
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.postAuthenticate">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
<!-- seam-components merge-point -->
</components>
I have some problems using Seam and EJB 3.0 beans in my project, and would like some help.
I have the same web application running in 2 configurations: One is running Icefaces Seam JPA Hibernate under tomcat for development purpose.
But using Maven magic, I can generate another delivery, using an ear, a war, an ejb-jar containing entities and stateless EJB 3 session beans. I then run this delivery under JBoss 4.2
The application works fine in Tomcat, using a .war only. But in JBoss, I get some pages not working.
I noticed to things using EJB configuration:
- convertEntity throws big NullpointerException. I've seen in the doc,
http://docs.jboss.org/seam/2.1.2/reference/en-US/html/controls.html#d0e28276, that I must configure the entitymanager for convertEntity to work. But with Ejb configuration, I don't have an entityManager managed by Seam, because it's the JBoss server that does the work.
=> It seems convertEntity don't work with EJBs, even 3.0 ? I can't find nowhere documentation for this.... And the EJB sample (booking), don't use convertEntity.....
- Then, I have a page where I display data that is lazy-loaded. I mean Hibernate must do some more queries to get the data for display. While this works very well under Tomcat, I get lazyinit errors using Ejb.
=> Documentation says Seam manage the lazyloading stuff for display view, and it does for jpa entities, but does it do the same for EJB ?
For info, here is my components.xml:
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:international="http://jboss.com/products/seam/international"
xmlns:ui="http://jboss.com/products/seam/ui"
xsi:schemaLocation=
"http://jboss.com/products/seam/ui http://jboss.com/products/seam/ui-2.1.xsd
http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
http://jboss.com/products/seam/international http://jboss.com/products/seam/international-2.1.xsd">
<core:init debug="false" jndi-pattern="amanda2/#{ejbName}/local" />
<core:ejb-transaction />
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="cid" />
<security:identity authenticate-method="#{loginPage.checkLogin}" />
<!-- Support for retrying the page after login -->
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.postAuthenticate">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
<!-- seam-components merge-point -->
</components>