[JBOSS AS 7.02] @OneToOne differents comportements AS 5.1 /AS7.02
jadtn Sep 27, 2011 10:34 AMHi,
I'm currently migrating AS 5.1 to AS 7 my environements are:
- Env AS 5.1 : JSF2.1.3 Richfaces 4.0.1M2 el-api 2.2
- Env AS 7.02 : JSF2.1.3 Richfaces 4.0.1M2 el-api 2.2
My problem is that relation OneToOne works well in AS5.1 and no in AS 7.0.2, when I try to get the AccPrefMailingEJB in Fetch.Lazy from account in JBOSS7 I get:
- account.getPrefsMailing()== OKItsWorks if fetch=FetchType.EAGER
- 'LazyInitializationException : could not initialize proxy - no Session' if fetch=FetchType.LAZY
When I try to get directly AccPrefMailingEJB like em.find(AccPrefMailingEJB.class,'userid') It's work fine
If I connect the same code from JBOSS 5.1 it's works.
EJB Part
{code}public class AccountEJB implements Serializable {
@Id
@Column(columnDefinition = "VARCHAR(25)", length = 25, nullable = false, updatable = false,unique=true)
String userId;
@OneToOne(cascade=CascadeType.ALL ,fetch=FetchType.EAGER)
@PrimaryKeyJoinColumn
AccPrefMailingEJB prefsMailing;
.....
}
@Entity
@Local
public class AccPrefMailingEJB implements Serializable {
@Id |
@Column(nullable=false,updatable=false,columnDefinition="VARCHAR(25)",length=25)
String uid;
boolean mailOnNewMail;
boolean mailOnFlash;
@Column(nullable=false)
@Enumerated(EnumType.ORDINAL)
MatchingPrefsEnum matching;
}{code}
And the code form my jsf backbean (request/view/session change nothing) is
{code}@PersistenceContext
protected EntityManager em;
AccountEJB acc
public AccountEJB getAcc() {
if(acc==null){
acc = em.find(AccountEJB.class, UtilJSF.getRemoteUser());
AccPrefMailingEJB p= acc.getPrefsMailing(); -->exception(1) in Fetch.LAZY with JBOSS 7.02
log.info("resul="+p);
}
return acc;
}
{code}
Exception :
{code}16:25:00,997 ERROR [stderr] (http--127.0.0.1-80-5) org.hibernate.LazyInitializationException: could not initialize proxy - no Session
16:25:00,997 ERROR [stderr] (http--127.0.0.1-80-5) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:149)
16:25:00,997 ERROR [stderr] (http--127.0.0.1-80-5) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:195)
16:25:00,997 ERROR [stderr] (http--127.0.0.1-80-5) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:180)
16:25:00,998 ERROR [stderr] (http--127.0.0.1-80-5) at com.horizon.server.ejb.AccPrefMailingEJB_$$_javassist_324.toString(AccPrefMailingEJB_$$_javassist_324.java)
16:25:00,998 ERROR [stderr] (http--127.0.0.1-80-5) at java.lang.String.valueOf(String.java:2826)
16:25:00,998 ERROR [stderr] (http--127.0.0.1-80-5) at java.lang.StringBuilder.append(StringBuilder.java:115)
16:25:00,998 ERROR [stderr] (http--127.0.0.1-80-5) at com.horizon.web.jsf.adv.CtrlPrefsMailing.getAcc(CtrlPrefsMailing.java:82)
16:25:00,998 ERROR [stderr] (http--127.0.0.1-80-5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:25:00,998 ERROR [stderr] (http--127.0.0.1-80-5) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:25:00,999 ERROR [stderr] (http--127.0.0.1-80-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:25:00,999 ERROR [stderr] (http--127.0.0.1-80-5) at java.lang.reflect.Method.invoke(Method.java:597)
16:25:00,999 ERROR [stderr] (http--127.0.0.1-80-5) at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
16:25:00,999 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
16:25:00,999 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
16:25:00,999 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
16:25:01,000 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
16:25:01,000 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
16:25:01,000 ERROR [stderr] (http--127.0.0.1-80-5) at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55)
16:25:01,000 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
16:25:01,000 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
16:25:01,000 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
16:25:01,001 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
16:25:01,001 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
16:25:01,001 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
16:25:01,001 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
16:25:01,001 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
16:25:01,002 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
16:25:01,002 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
16:25:01,002 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
16:25:01,002 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
16:25:01,002 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
16:25:01,002 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
16:25:01,003 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
16:25:01,003 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
16:25:01,003 ERROR [stderr] (http--127.0.0.1-80-5) at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:276)
16:25:01,003 ERROR [stderr] (http--127.0.0.1-80-5) at org.richfaces.renderkit.html.PanelRenderer.encodeEnd(PanelRenderer.java:181)
16:25:01,003 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
16:25:01,003 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
16:25:01,004 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
16:25:01,004 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
16:25:01,004 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
16:25:01,004 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
16:25:01,004 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
16:25:01,004 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
16:25:01,005 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
16:25:01,005 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
16:25:01,005 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
16:25:01,005 ERROR [stderr] (http--127.0.0.1-80-5) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
16:25:01,005 ERROR [stderr] (http--127.0.0.1-80-5) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
16:25:01,006 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
16:25:01,006 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
16:25:01,006 ERROR [stderr] (http--127.0.0.1-80-5) at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
16:25:01,006 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
16:25:01,007 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
16:25:01,007 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
16:25:01,007 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
16:25:01,007 ERROR [stderr] (http--127.0.0.1-80-5) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)
16:25:01,007 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:480)
16:25:01,008 ERROR [stderr] (http--127.0.0.1-80-5) at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
16:25:01,010 ERROR [stderr] (http--127.0.0.1-80-5) at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)
16:25:01,010 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
16:25:01,010 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
16:25:01,010 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
16:25:01,010 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
16:25:01,011 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
16:25:01,011 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
16:25:01,011 ERROR [stderr] (http--127.0.0.1-80-5) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
16:25:01,013 ERROR [stderr] (http--127.0.0.1-80-5) at java.lang.Thread.run(Thread.java:662)
{code}
Any body have an idea if there a change between jboss 5 and 7 about oneToOne relation?
Thanks