[JBoss Seam] - Problem with entity in session scope and JSF inputText
by amitdk
I've spent too much time on this so far and am wondering if conceptually I am doing something wrong. I would imagine this to be a fairly common use case for folks, so here's the issue:
Here's a snippet of my xhtml page -
| <s:decorate template="layout/edit.xhtml">
| <ui:define name="label">Timeline</ui:define>
| <h:selectOneMenu id="timeline" value="#{task.selectedTimeline}" required="false"
| immediate="true">
| <f:valueChangeListener type="com.edwardjones.statusreporting.view.TimelineChangeListener" />
| <s:selectItems id="timelinelst" value="#{timelineList}"
| var="timeline" label="#{timeline.description}" />
| <s:convertEntity />
| <a:support event="onchange" reRender="dt"/>
| </h:selectOneMenu>
| </s:decorate>
|
| <h:inputText id="dt"
| value="#{selectedTimeline.startDate}">
| <f:convertDateTime pattern="MM/dd/yyyy"/>
| </h:inputText>
|
| <jp:popupCalendar id="date_popup"
| for="date"
| format="MM/dd/yyyy"
| rendered="#{!disabled and rendered != false}">
| <h:graphicImage url="img/calendar.gif"
| title="Click here to select date"/>
| </jp:popupCalendar>
|
The TimelineChangeListener is as follows:
| @Name("timelinechange")
| public class TimelineChangeListener implements ValueChangeListener
| {
| @Out(value="selectedTimeline", required = false, scope = SESSION)
| Timeline timeline;
|
| public void processValueChange(ValueChangeEvent arg0)
| throws AbortProcessingException {
| timeline = (Timeline) arg0.getNewValue();
|
| // TODO Auto-generated method stub
| System.out.println("timeline selection");
| }
| }
|
The Timeline entity looks as follows:
| /**
| * Timeline generated by hbm2java
| */
| @Entity
| @Name("timeline")
| @Role(name="selectedTimeline", scope=SESSION)
| @Table(name = "timeline", catalog = "statreport", uniqueConstraints = @UniqueConstraint(columnNames = "description"))
| public class Timeline implements java.io.Serializable
| {
| private int id;
|
| private String description;
|
| public Timeline()
| {
| }
|
| public Timeline(int id, String description)
| {
| this.id = id;
| this.description = description;
| }
|
| @Id
| @Column(name = "id", unique = true, nullable = false)
| @NotNull
| public int getId()
| {
| return this.id;
| }
|
| public void setId(int id)
| {
| this.id = id;
| }
|
| @Column(name = "description", unique = true, nullable = false, length = 20)
| @NotNull
| @Length(max = 20)
| public String getDescription()
| {
| return this.description;
| }
|
| public void setDescription(String description)
| {
| this.description = description;
| }
|
| @Transient
| public Date getStartDate()
| {
| Calendar startCal = Calendar.getInstance();
| // Determine start of week
| if (getDescription() == null || getDescription().equals("Weekly"))
| {
| System.out.println("Weekly timeline");
| }
| else if ( getDescription().equals("Monthly"))
| {
| System.out.println("Monthly timeline");
| }
| // Convert calender to date
| Date startDate = startCal.getTime();
| return startDate;
| }
|
| @Transient
| public Date getEndDate()
| {
| Calendar startCal = Calendar.getInstance();
| if (getDescription() == null || getDescription().equals("Weekly"))
| {
| ...........
| }
| return endDate;
| }
| }
|
|
The ajax support tag calls the timelinechangelistener which sets the selected timeline and puts it into a session scope. Since the rendered element calls the selected timeline getStartDate method, I expected the selected timeline to get passed in, however the timeline on which the getStartDate is called is never selectedTimeline. Hopefully, made things clear as to what I am trying to accomplish. In short, based on the selected timeline, I would like to change the start date/end date logic.
Any help is appreciated....
Thanks
Amit Karandikar
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057166#4057166
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057166
18Â years, 10Â months
[JBoss Seam] - entityManager null exception on CVS20070623
by gus888
Hi all,
I just downloaded the new CVS and tested it, but I got entityManager null exception in Authenticator. Thank you in advance.
In Authenticator: @In(create = true)
| private EntityManager entityManager;
In components.xml <core:managed-persistence-context name="entityManager" auto-create="true"
| persistence-unit-jndi-name="java:/plifarEntityManagerFactory"/>
The exceptions:20:52:21,343 ERROR [SeamLoginModule] Error invoking login method
| javax.el.ELException: org.jboss.seam.RequiredException: In attribute requires non-null value: authenticator.entityManager
| at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
| at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:338)
| at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
| at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
| at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
| at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:177)
| at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:104)
| 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 javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
| at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
| at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
| at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
| at org.jboss.seam.security.Identity.authenticate(Identity.java:321)
| at org.jboss.seam.security.Identity.authenticate(Identity.java:311)
| at org.jboss.seam.security.Identity.login(Identity.java:227)
| 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.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:325)
| at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:338)
| at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
| at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
| at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
| at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
| at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
| at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
| at javax.faces.component.UICommand.broadcast(UICommand.java:383)
| at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
| at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
| at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:57)
| at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:45)
| at com.icesoft.faces.webapp.http.core.IDVerifier.service(IDVerifier.java:19)
| at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
| at com.icesoft.faces.webapp.http.servlet.ViewBoundAdaptingServlet.service(ViewBoundAdaptingServlet.java:30)
| at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
| at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
| at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:89)
| at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
| at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
| at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
| at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:65)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| 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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:687)
| at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
| at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:364)
| at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
| at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:54)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:62)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: authenticator.entityManager
| at org.jboss.seam.Component.getValueToInject(Component.java:2063)
| at org.jboss.seam.Component.injectAttributes(Component.java:1502)
| at org.jboss.seam.Component.inject(Component.java:1323)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:44)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:29)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
| at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
| at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
| at com.my.controller.security.Authenticator_$$_javassist_133.authenticate(Authenticator_$$_javassist_133.java)
| 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.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:325)
| ... 78 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057165#4057165
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057165
18Â years, 10Â months
[JNDI/Naming/Network] - Re: JBoss 4.2 ejb not bound
by _steph
Thank you for your reply Jaikiran.
Configuration files and lookup code are generated with Xdoclet 1.2.3.
Bean Xdoclet tags:
* @ejb.bean name="Calc" description="An EJB named Calc" display-name="Calc"
* view-type="both" jndi-name="CalcHome" local-jndi-name =
* "CalcLocalHome" type="Stateless" transaction-type="Container"
*
*
* @ejb.util generate="logical"
*
* @ejb.home package="calc.interfaces"
*
*
generated ejb-jar.xml file:
<display-name>Calc</display-name>
<enterprise-beans>
<!-- Session Beans -->
<![CDATA[An EJB named Calc]]>
<display-name>Calc</display-name>
<ejb-name>Calc</ejb-name>
calc.interfaces.CalcHome
calc.ejb.Calc
<local-home>calc.interfaces.CalcLocalHome</local-home>
calc.ejb.CalcLocal
<ejb-class>calc.ejb.CalcSession</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
...
</ejb-jar>
jboss.xml specific generated file:
<enterprise-beans>
<ejb-name>Calc</ejb-name>
<jndi-name>CalcHome</jndi-name>
<local-jndi-name>CalcLocalHome</local-jndi-name>
<method-attributes>
</method-attributes>
Server log when I deploy the app:
02:52:21,796 INFO [EARDeployer] Init J2EE application: file:/D:/jboss-4.2.0/server/default/deploy/CalcEAR.ear
02:52:22,015 INFO [EjbModule] Deploying Calc
02:52:22,390 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Calc' to jndi 'CalcLocalHome'
02:52:22,406 INFO [ProxyFactory] Bound EJB Home 'Calc' to jndi 'CalcHome'
02:52:22,406 INFO [EJBDeployer] Deployed: file:/D:/jboss-4.2.0/server/default/tmp/deploy/tmp27268CalcEAR.ear-contents/Calc.jar
02:52:22,421 INFO [TomcatDeployer] deploy, ctxPath=/CalcWeb, warUrl=.../tmp/deploy/tmp27268CalcEAR.ear-contents/CalcWeb-exp.war/
02:52:22,515 INFO [EARDeployer] Started J2EE application: file:/D:/jboss-4.2.0/server/default/deploy/CalcEAR.ear
So the session bean is supposed to be bound to jndi his names.
But in the JNDIView.list() result there is no Calc bean. It's not deployed
...
Ejb Module: Calc.jar
java:comp namespace of the Calc bean:
+- env (class: org.jnp.interfaces.NamingContext)
...
For me it's a jboss bug and the jboss log is erroneous. The lookup code generated by Xdoclet too, I tried your sample lookup code with same result.
Stephane.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057161#4057161
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057161
18Â years, 10Â months
[JBoss Seam] - Re: Seam performance concerns
by stu2
"mgrouch" wrote : Use factories for stateless objects such as DAOs (so they are created once and not repeteadly created/destroyed).
|
| ...
| Do not forget to cache JNDI lookups.
|
Again, you can certainly spend time doing this kind of stuff on the off chance that it will improve performance. More likely you'll find that in modern JVMs, object creation for short lived objects is essentially free, and JNDI lookups (btw, you're using Seam, right? Where are you directly interacting with JNDI anyway?) aren't going to be significant.
Spend some time with a profiler an find out what's going on. It's irrefutable, and will show you where you should spend effort optimizing. You may find that there are performance issues with Seam. You'll also find that if you can clearly show the issue, the Seam team will be extremely responsive in addressing these.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057157#4057157
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057157
18Â years, 10Â months