Note that there are some explanatory texts on larger screens.

plurals
  1. POSession Objects when using Spring Webflow
    primarykey
    data
    text
    <p>I have few variables which need to be stored in the session as they should be available until the page closes. </p> <p>I came up with session object, that can store the values, so that i can refer them to any class by injecting whenever necessary.</p> <pre><code>@Component @Scope("session") public class SessionObjects { /** * Boradcaster id of the atmosphere */ private String broadCasterId; /** * Atmosphere Resource Id of specific session */ private String senderId; public String getBroadCasterId() { return broadCasterId; } public void setBroadCasterId(String broadCasterId) { this.broadCasterId = broadCasterId; } public String getSenderId() { return senderId; } public void setSenderId(String senderId) { this.senderId = senderId; } } </code></pre> <p>But when i start the application server, it fails with this error.</p> <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wb': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.emyed.whiteboard.controller.SessionObjects com.emyed.whiteboard.defaults.wb.baseMB; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) ~[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434) [catalina.jar:7.0.42] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.42] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.42] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.42] at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976) [catalina.jar:7.0.42] at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653) [catalina.jar:7.0.42] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_25] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_25] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_25] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_25] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_25] at java.lang.Thread.run(Thread.java:662) [na:1.6.0_25] Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.emyed.whiteboard.controller.SessionObjects com.emyed.whiteboard.defaults.wb.baseMB; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] ... 27 common frames omitted Caused by: java.lang.NullPointerException: null at org.springframework.web.context.request.SessionScope.get(SessionScope.java:91) ~[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:329) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE] </code></pre> <p>Sample wb class</p> <pre><code>@Named public class Wb implements Serializable{ @Autowired private SessionObjects sessionObj; /** * Creates a new whiteboard * * @return string outcome for navigation */ public WhiteboardIdentifiers create() { String senderId = UUID.randomUUID().toString(); String whiteboardID = UUID.randomUUID().toString(); UserData creator = new UserData(senderId, getCreator(),null); return createWhiteboard.create( senderId, whiteboardID, creator); } public DisplayWhiteboard setDisplayWhiteboard(WhiteboardIdentifiers wbIdentifiers){ ........ // set the id's in the baseMB sessionObj.setBroadCasterId(whiteboardId); //Chat Controller ...... sessionObj.setSenderId(senderId); whiteboard.getUserController().activateUser(senderId); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload