voyent
SessionRenderer NullPointerException  XML
Forum Index -> JBoss Seam Integration
Author Message
classis

Joined: 29/Feb/2008 00:00:00
Messages: 5
Offline


I'm adding the current session in a session scoped Seamcomponent after the login to the session renderer:

Code:
 @Name("pushMsgReceiver")
 @Scope(SESSION)
 @BypassInterceptors
 public class PushMsgReceiver implements Serializable {
   /** Push group. */
   public static final String PUSH_GROUP_PUSH_MSG_RECEIVER = "pushMsgReceiver";
 
   /** Adds a push message receiver. */
   @Observer(value = EVENT_LOGIN_SUCCESSFUL, create = true)
   public void addPushMsgReceiver() {
     SessionRenderer.addCurrentSession(PUSH_GROUP_PUSH_MSG_RECEIVER);
   }
 
   /** Removes a push message receiver. */
   @Observer(value = EVENT_LOGGED_OUT)
   public void removePushMsgReceiver() {
     SessionRenderer.removeCurrentSession(PUSH_GROUP_PUSH_MSG_RECEIVER);
 group.");
   }
 }
 


When I call "SessionRenderer.render(PushMsgReceiver.PUSH_GROUP_PUSH_MSG_RECEIVER)" from another conversation scoped Seam component, I get the following error:


14:14:58,825 ERROR [D2DFaceletViewHandler] Problem in renderResponse: null
java.lang.NullPointerException
at com.icesoft.faces.util.DOMUtils.domDiff(DOMUtils.java:256)
at com.icesoft.faces.context.PushModeSerializer.serialize(PushModeSerializer.java:34)
at com.icesoft.faces.context.BridgeFacesContext$SaveCurrentDocument.serialize(BridgeFacesContext.java:924)
at com.icesoft.faces.context.DOMResponseWriter.endDocument(DOMResponseWriter.java:191)
at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:285)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:159)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.render(PersistentFacesState.java:176)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.executeAndRender(PersistentFacesState.java:312)
at com.icesoft.faces.async.render.RunnableRender.run(RunnableRender.java:143)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)

at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:662)
 


Context parameters:
Code:
   <context-param>
     <param-name>com.icesoft.faces.synchronousUpdate</param-name>
     <param-value>false</param-value>
   </context-param>
 
   <context-param>
     <param-name>com.icesoft.faces.concurrentDOMViews</param-name>
     <param-value>true</param-value>
   </context-param>
 


What am I doing wrong?
judy.guglielmin

Joined: 20/Feb/2007 00:00:00
Messages: 1396
Offline


I looked at this just briefly, but am thinking that bypassing the Seam intercepters while annotating with some Seam @Observer may cause some problems...did you try it without bypassing the interceptors?
Also, you may want to test in your bean's constructor that you are actually getting a reference to the SessionRenderer.

You also didn't mention which versions of these you were using (Seam, jsf, ICEfaces) ...
classis

Joined: 29/Feb/2008 00:00:00
Messages: 5
Offline


Sorry, here are my versions:

ICEfaces 1.8.2
JBoss Seam 2.2.2 Final
JBoss 5.1.0 GA

@BypassInterceptors has no effect on the @Observer anntotation. The observer methods are called correctly with and without @BypassInterceptors.

I've debugged my code and I saw, that SessionRenderer.addCurrentSession is called correctly both in my observer function and alternatively in the constructor of my Seam session component. SessionRenderer.render is called without exception too. The exception occurres in the render tread.
judy.guglielmin

Joined: 20/Feb/2007 00:00:00
Messages: 1396
Offline


You didn't post your code where you are triggering the render. (just the bean where you are adding and removing from the SessionRender). are you using an @Observer in the same bean to trigger the push after some other event has happened?
classis

Joined: 29/Feb/2008 00:00:00
Messages: 5
Offline


The @Observer methods are only used to add the current session to the session renderer after login an to remove it again after logout.

SessionRenderer.render is called in the application scoped Seam component, that stores the data for the push render request (in PushMsgManager.pushMessage):

Code:
 @Name("pushMsgManager")
 @Scope(APPLICATION)
 @AutoCreate
 @BypassInterceptors
 public class PushMsgManager implements Serializable {
   ...
 
   /** Message key. */
   private String messageKey = null;
   /** Indicates whether actions should be disabled. */
   private boolean disableActions = false;
 
   /**
    * Returns the current message, to be used in views.
    *
    * @return the current message
    */
   public String getMessageKey() {
     return messageKey;
   }
 
   /**
    * Checks if actions should be disabled.
    *
    * @return <code>true</code>, if actions should be disabled, otherwise <code>false</code>
    */
   public boolean isDisableActions() {
     return disableActions;
   }
 
   /**
    * Checks if message is available.
    *
    * @return <code>true</code>, if message is available, otherwise <code>false</code>
    */
   public boolean isMessageAvailable() {
     return !StringUtils.isEmpty(messageKey);
   }
 
   /**
    * Pushes the message with the specified key to the news receivers and optionally disables actions.
    *
    * @param messageKey the message to distribute
    * @param disableActions Indicates whether actions should be disabled
    */
   public void pushMessage(String messageKey, boolean disableActions) {
     this.messageKey = messageKey;
     this.disableActions = disableActions;
     SessionRenderer.render(PushMsgReceiver.PUSH_GROUP_PUSH_MSG_RECEIVER);
     log.info("Pushed message: \"" + messageKey + "\"");
   }
 
   /** Sets the current message to nothing. */
   public void clearMessage() {
     pushMessage(null, false);
   }
 
   ...
 }
 


PushMsgManager.pushMessage is called from a conversation scoped Seam component in an action method for an ICEfaces command button:

Code:
 @Name("administrationAction")
 @Scope(CONVERSATION)
 public class AdministrationAction implements Serializable {
   ...
 
   /** Push message manager. */
   @In
   private PushMsgManager pushMsgManager = null;
 
   ...
 
   /** Update modules. */
   public void updateModules() {
     try {
       pushMsgManager.pushMessage("grid.msg.module.import.inProgress", true);
       moduleImportBc.updateModuleDatas();
       lastModuleDataUpdate.setDate(new GregorianCalendar().getTime());
       pushMsgManager.clearMessage();
 
       statusMessages.addFromResourceBundle(INFO, "administration.msg.updateModules.successful");
     } catch (JpaException e) {
       statusMessages.addFromResourceBundle(ERROR, "administration.msg.updateModules.failed");
     } catch (CsvFileException e) {
       statusMessages.addFromResourceBundle(ERROR, "administration.msg.updateModules.failed");
     }
   }
 
   ...
 }
 


The result is the exception in my first message. My second try was to call SessionRenderer.render directly in AdministrationAction.updateModules with still the same exception as result.
judy.guglielmin

Joined: 20/Feb/2007 00:00:00
Messages: 1396
Offline


Might be tricky doing the push from the Conversation-scoped bean. Why not trigger an event (create your own) and then Observe it from either the Session or Application-scoped bean as a test to see if there is still any problem. If the conversation-scoped bean is not in the view (your conversation may not be propagated for the push) and then is not in the view which may be causing the NPE...
(just a thought).
classis

Joined: 29/Feb/2008 00:00:00
Messages: 5
Offline


I put all the render code to the AdministrationAction component and changed the scope of it to session, but I still got the same exception.

Code:
 @Name("administrationAction")
 @Scope(SESSION)
 public class AdministrationAction implements Serializable {
   ...
 
   /** Push message manager. */
   @In
   private PushMsgManager pushMsgManager = null;
 
   ...
 
   /** Constructor. */
   public AdministrationAction() {
     SessionRenderer.addCurrentSession(PushMsgReceiver.PUSH_GROUP_PUSH_MSG_RECEIVER);
     log.info("Current session added to message receiver push group.");
   }
 
   ...
 
   /** Update modules. */
   public void updateModules() {
     try {
       pushMsgManager.setMessage("grid.msg.module.import.inProgress", true);
       SessionRenderer.render(PushMsgReceiver.PUSH_GROUP_PUSH_MSG_RECEIVER);
       moduleImportBc.importInputDatas();
       moduleImportBc.updateModuleDatas();
       lastModuleDataUpdate.setDate(new GregorianCalendar().getTime());
       pushMsgManager.setMessage(null, true);
       SessionRenderer.render(PushMsgReceiver.PUSH_GROUP_PUSH_MSG_RECEIVER);
 
       statusMessages.addFromResourceBundle(INFO, "administration.msg.updateModules.successful");
     } catch (JpaException e) {
       statusMessages.addFromResourceBundle(ERROR, "administration.msg.updateModules.failed");
     } catch (CsvFileException e) {
       statusMessages.addFromResourceBundle(ERROR, "administration.msg.updateModules.failed");
     }
   }
 
   ...
 }
 


After that I tried it with @Observer methods in the application scoped PushMagManager component. Still got the exception.
judy.guglielmin

Joined: 20/Feb/2007 00:00:00
Messages: 1396
Offline


I have created a JIRA
http://jira.icesoft.org/browse/ICE-7961
if you have a few moments, please attach a simple sample which will expedite any future work on this for quick resolution.
Also, you can watch the Jira for any possible workarounds/fixes
ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline


Is it possible to use CDI with ICEfaces 3?
[Email]
 
Forum Index -> JBoss Seam Integration
Go to:   
Powered by JForum 2.1.7ice © JForum Team