[JBoss Seam] - Component bindings in Conversation scope
by quilleashm
I think I'm correct in saying that currently you cannot have a conversation scoped component that has UIComponent bindings.
e.g. of a minimal example
Facelet view
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:ui="http://java.sun.com/jsf/facelets">
| <head>
| <title></title>
| </head>
| <body>
| <h:form>
| <h:outputText value="Text" binding="#{testBean.outputText}"/>
|
| <h:commandButton value="Submit"/>
| </h:form>
| </body>
| </html>
|
And the bean
| @Name( "testBean" )
| @Scope( ScopeType.CONVERSATION )
| public class TestBean
| {
| private HtmlOutputText outputText;
|
| public HtmlOutputText getOutputText()
| {
| return outputText;
| }
|
| public void setOutputText( HtmlOutputText outputText )
| {
| this.outputText = outputText;
| }
| }
|
It is fine during the initial rendering of the page but if you click the button to do a postback the setOutputText() is called during the restore view phase which is before the conversation context is created by Seam (done in the afterPhase() of the restore view), so the component is unavailable.
For completeness here's the exception.
| javax.el.PropertyNotFoundException: /index.xhtml @11,68 binding="#{testBean.outputText}": Target Unreachable, identifier 'testBean' resolved to null
| at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:95)
| at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:228)
| at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:233)
| at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:233)
| at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:186)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
| at java.lang.Thread.run(Thread.java:595)
|
The short term workaround would be to put component bindings in an event scoped component and inject it into the conversation component but I'd prefer not to do this.
Is it possible via some configuration/option to allow this particular combination? I looked at the SeamPhaseListener and it would be trivial to move the conversation setup code into the beforePhase() of restore view but I have no idea what side-effects this will have and if it will work.
Is the conversation setup done after restore view for a particular reason? Would be very useful to me personally as I think I will frequently need to bind UI components to do certain types of dynamic page creation in the code. I'm willing to spend some time looking at/trying this if it's worth investigating a change.
Cheers.
Mike.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994781#3994781
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994781
19 years, 4 months
[EJB 3.0] - @manytoone left join problem
by enesterov
Hi everyone,
I have many-to-one unidirectional relationship between two objects as follows:
| @Entity
| @Table(name = "A")
| public class A implements Serializable {
|
| private Long id;
|
| private B bObject;
|
| @Id
| public Long getId() {
| return id;
| }
|
| public void setId(Long _id) {
| id = _id;
| }
|
| @ManyToOne
| @JoinColumn(name = "a_id", insertable = false, updatable = false, nullable = true)
| public B getBObject() {
| return bObject;
| }
|
| public void setBObject(B _bObject) {
| bObject = _bObject;
| }
| }
|
| @Entity
| @Table(name = "B")
| public class B implements Serializable {
|
| private Long id;
|
| private Long aId;
|
| @Id
| public Long getId() {
| return id;
| }
|
| public void setId(Long _id) {
| id = _id;
| }
|
| @Column(name="a_id")
| public Long getAId() {
| return id;
| }
|
| public void setAId(Long _aId) {
| aId = _aId;
| }
| }
|
in the session bean I am getting List as follows:
| ...
| Query query = em.createQuery("select a from A a left outer join a.bObject as b ");
| query.setFirstResult(start);
| query.setMaxResults(MSG_PER_PAGE);
| List<A> result =query.getResultList();
| ...
|
The problem is that every time there is no record in table B that corresponds to record in table A I am getting the javax.persistence.EntityNotFoundException: Unable to find B with id 123
I am running Jboss 4.0.4.
Any help is appreciated.
Ed
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994778#3994778
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994778
19 years, 4 months
[JBoss Seam] - Can I mix Session, Entity and regular Java Beans in Seam app
by PatrickMadden
Hello,
I'm very new to Seam. I Have successfully created sites using JSP and Tomcat however.
I have seam CR2 deployed with 4.0.5GA using eclipse. I would like to be able to have a standard java beans created that is used as temporary object in my application to initialize some entity beans and then commit to the database. Take for example a very simple UserName and Password combination. My database password takes a byte[] for the password (sqlserver 2000). I can't change that. When I generate my entities the User Entity bean has a public void setPassword(byte[] password) method. Therefore I want a very simple POJO similar to the Greeter example that is not backed by the DB. I want to create this object as follows:
package com.foo.web.bean;
|
| import java.io.Serializable;
|
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Out;
|
| @Name("Greeter")
| public class GreeterBean implements Serializable
| {
| /**
| *
| */
| private static final long serialVersionUID = 1L;
| private String name = "";
| private String password = "";
|
| @Out
| public String getName()
| {
| return name;
| }
|
| @Out
| public String getPassword()
| {
| return this.password;
| }
|
| @In
| public void setName(String name)
| {
| this.name = name;
| }
|
| @In
| public void setPassword(String password)
| {
| this.password = password;
| }
| }
|
And then use it in a form as follows:
<div id="sidebar">
| <fieldset>
| <div>
| <h:outputLabel for="name">Login Name</h:outputLabel>
| <h:inputText id="name" value="#{Greeter.name}" style="width: 175px;" />
| </div>
| <div>
| <h:outputLabel for="password">Password</h:outputLabel>
| <h:inputSecret id="password" value="#{Greeter.password}" style="width: 175px;" />
| </div>
| <div class="errors"><h:messages globalOnly="true"/></div>
| <div class="buttonBox"><h:commandButton action="#{Login.login}" value="Account Login" class="button" /></div>
| <div class="notes"><h:commandLink action="register">Register New User</h:commandLink></div>
| </fieldset>
| </div>
Inside my stateless LoginAction class, I have an @In Greeter variable and I will use it to extract the bytes from the password to login my user. However, when I do this I get the following error:
javax.faces.el.EvaluationException: /home.xhtml @25,77 value="#{Greeter.name}": Exception getting value of property name of base of type : com.clooster.web.ejb.session.GreeterBean$$EnhancerByCGLIB$$8988b3bf
| at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
| at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
| at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
| at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:135)
| at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
| at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
| at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
| at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
| at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
| at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
| at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: javax.faces.el.EvaluationException: Bean: com.clooster.web.ejb.session.GreeterBean$$EnhancerByCGLIB$$8988b3bf, property: name
| at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442)
| at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
| at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
| at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
| at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
| at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
| at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
| ... 36 more
| Caused by: java.lang.reflect.InvocationTargetException
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438)
| ... 42 more
| Caused by: org.jboss.seam.RequiredException: In attribute requires value for component: Greeter.password
| at org.jboss.seam.Component.getInstanceToInject(Component.java:1878)
| at org.jboss.seam.Component.injectMethods(Component.java:1322)
| at org.jboss.seam.Component.inject(Component.java:1113)
| at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:48)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:51)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
| at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
| at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
| at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
| at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:140)
| at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:75)
| at com.clooster.web.ejb.session.GreeterBean$$EnhancerByCGLIB$$8988b3bf.getName(<generated>)
| ... 47 more
So my question is is this possible - am I doing something wrong? Any help is greatly appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994772#3994772
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994772
19 years, 4 months
[EJB 3.0] - Re: The EJB3 embeddable release contains errors
by klejs
Some updates:
I created a new jar file from the old one but added the NoResultException. In this way I got rid of the ClassNotFoundExceptions but I'm getting some other strange errors now. This is the coding I'm using to start the embedded server:
EJB3StandaloneBootstrap.boot(null);
| EJB3StandaloneDeployer deployer = new EJB3StandaloneDeployer(); deployer.getArchivesByResource().add("META-INF/persistence.xml");
| // need to set the InitialContext properties that deployer will use
| // to initial EJB containers
| deployer.setJndiProperties(getInitialContextProperties());
|
| deployer.create();
| deployer.start();
An error then occurs at deployer.create(). The warnings and exceptions looks like this:
[testng] WARN 18-12 19:55:31,321 (JBossEntityResolver.java:getLocalEntityName:201) -Entity is not registered, publicId=null systemId=file:/C:/dev/project/ejb/embedded_jboss_alpha/conf/bean-deployer_1_0.xsd
| [testng] WARN 18-12 19:55:31,337 (SaxJBossXBParser.java:warning:226) -schema_reference.4: Failed to read schema document 'bean-deployer_1_0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. @ file:/C:/dev/project/ejb/embedded_jboss_alpha/conf/embedded-jboss-beans.xml[5,45]
| [testng] WARN 18-12 19:55:32,399 (JBossEntityResolver.java:getLocalEntityName:201) -Entity is not registered, publicId=null systemId=http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
| [testng] WARN 18-12 19:55:33,978 (JBossEntityResolver.java:getLocalEntityName:201) -Entity is not registered, publicId=null systemId=http://java.sun.com/xml/ns/javaee/javaee_5.xsd
| [testng] WARN 18-12 19:55:34,446 (JBossEntityResolver.java:getLocalEntityName:201) -Entity is not registered, publicId=null systemId=http://java.sun.com/xml/ns/javaee/javaee_web_services_client_1_2...
| [testng] FAILED: startEjbServer
| [testng] java.lang.NullPointerException
| [testng] at org.jboss.ejb3.Ejb3DescriptorHandler.isEjb(Ejb3DescriptorHandler.java:129)
| [testng] at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:310)
| [testng] at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:300)
| [testng] at org.jboss.ejb3.Ejb3Deployment.deployUrl(Ejb3Deployment.java:282)
| [testng] at org.jboss.ejb3.Ejb3Deployment.deploy(Ejb3Deployment.java:253)
| [testng] at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:240)
| [testng] at org.jboss.ejb3.embedded.EJB3StandaloneDeployer.create(EJB3StandaloneDeployer.java:390)
| [testng] at test.EJBLifeCycle.startEjbServer(Unknown Source)
I used the jboss embeddable alpha_5 before and there everything worked perfect and I had no problems like this. The problem with alpha_5 was that the @EntityResult annotation wasn't updated to the spec. Does anyone have an idea about what could be wrong? The application is, by the way, working when I deploy it in JBoss AS.
Thanks in advance
/klejs
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994771#3994771
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994771
19 years, 4 months