-
1. Re: How to use @Startup annotation?
quilleashm Jun 4, 2007 4:11 AM (in response to surajmundada)@Name( "xxx" ) @Scope( ScopeType.APPLICATION ) @Startup public class MyClass { @Create public void create() { // init stuff here } }
The key things are:
@Startup is only valid with application and session, in your case you want application scope.
Using @Create to have initialisation code run when the component creates. In this case the component is created on application startup.
HTH.
Mike. -
2. Re: How to use @Startup annotation?
surajmundada Jun 4, 2007 6:26 AM (in response to surajmundada)Thanks for the help.
But it's giving me the problem of illegal state.
Stack trace is as follow:15:40:07,610 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/qatbDatabase 15:40:07,626 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext 15:40:07,626 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces} 15:40:09,532 ERROR [STDERR] java.lang.IllegalStateException: No session context active 15:40:09,532 ERROR [STDERR] at org.jboss.seam.ScopeType.getContext(ScopeType.java:94) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.newInstance(Component.java:1311) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1263) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1246) 15:40:09,532 ERROR [STDERR] at fr.biomerieux.qatbplus.init.PopulateCommercialStripsListener.populateCommercialStrips(PopulateCommercialStripsListener.java:73) 15:40:09,532 ERROR [STDERR] at fr.biomerieux.qatbplus.init.PopulateCommercialStripsListener$$EnhancerByCGLIB$$59b5f451.CGLIB$populateCommercialStrips$0(<generated>) 15:40:09,532 ERROR [STDERR] at fr.biomerieux.qatbplus.init.PopulateCommercialStripsListener$$EnhancerByCGLIB$$59b5f451$$FastClassByCGLIB$$cc7d4081.invoke(<generated>) 15:40:09,532 ERROR [STDERR] at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.interceptors.JavaBeanInterceptor$1.proceed(JavaBeanInterceptor.java:80) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:80) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.interceptors.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:51) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.interceptors.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:39) 15:40:09,532 ERROR [STDERR] at fr.biomerieux.qatbplus.init.PopulateCommercialStripsListener$$EnhancerByCGLIB$$59b5f451.populateCommercialStrips(<generated>) 15:40:09,532 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,532 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,532 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,532 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.callComponentMethod(Component.java:1334) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.callCreateMethod(Component.java:1322) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.newInstance(Component.java:1312) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1263) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1253) 15:40:09,532 ERROR [STDERR] at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:125) 15:40:09,547 ERROR [STDERR] at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:104) 15:40:09,547 ERROR [STDERR] at org.jboss.seam.init.Initialization.init(Initialization.java:196) 15:40:09,547 ERROR [STDERR] at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:32) 15:40:09,547 ERROR [STDERR] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729) 15:40:09,547 ERROR [STDERR] at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187) 15:40:09,547 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) 15:40:09,547 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) 15:40:09,547 ERROR [STDERR] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,547 ERROR [STDERR] at org.apache.catalina.core.StandardContext.init(StandardContext.java:5116) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,547 ERROR [STDERR] at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297) 15:40:09,547 ERROR [STDERR] at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103) 15:40:09,547 ERROR [STDERR] at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371) 15:40:09,547 ERROR [STDERR] at org.jboss.web.WebModule.startModule(WebModule.java:83) 15:40:09,547 ERROR [STDERR] at org.jboss.web.WebModule.startService(WebModule.java:61) 15:40:09,547 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) 15:40:09,547 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) 15:40:09,547 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,547 ERROR [STDERR] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978) 15:40:09,547 ERROR [STDERR] at $Proxy0.start(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.system.ServiceController.start(ServiceController.java:417) 15:40:09,547 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 15:40:09,547 ERROR [STDERR] at $Proxy41.start(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97) 15:40:09,547 ERROR [STDERR] at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238) 15:40:09,547 ERROR [STDERR] at org.jboss.ws.server.WebServiceDeployer.start(WebServiceDeployer.java:117) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 15:40:09,547 ERROR [STDERR] at $Proxy42.start(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:997) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771) 15:40:09,547 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 15:40:09,547 ERROR [STDERR] at $Proxy6.deploy(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263) 15:40:09,547 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336) 15:40:09,547 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) 15:40:09,547 ERROR [STDERR] at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,547 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,547 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,563 ERROR [STDERR] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978) 15:40:09,563 ERROR [STDERR] at $Proxy0.start(Unknown Source) 15:40:09,563 ERROR [STDERR] at org.jboss.system.ServiceController.start(ServiceController.java:417) 15:40:09,563 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,563 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,563 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,563 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 15:40:09,563 ERROR [STDERR] at $Proxy4.start(Unknown Source) 15:40:09,563 ERROR [STDERR] at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302) 15:40:09,563 ERROR [STDERR] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007) 15:40:09,563 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808) 15:40:09,563 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771) 15:40:09,563 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755) 15:40:09,563 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 15:40:09,563 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 15:40:09,563 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 15:40:09,563 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 15:40:09,563 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 15:40:09,563 ERROR [STDERR] at $Proxy5.deploy(Unknown Source) 15:40:09,563 ERROR [STDERR] at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482) 15:40:09,563 ERROR [STDERR] at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362) 15:40:09,563 ERROR [STDERR] at org.jboss.Main.boot(Main.java:200) 15:40:09,563 ERROR [STDERR] at org.jboss.Main$1.run(Main.java:464) 15:40:09,563 ERROR [STDERR] at java.lang.Thread.run(Unknown Source) 15:40:09,563 ERROR [[/qatbplus]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.IllegalStateException: No session context active at org.jboss.seam.ScopeType.getContext(ScopeType.java:94) at org.jboss.seam.Component.newInstance(Component.java:1311) at org.jboss.seam.Component.getInstance(Component.java:1263)
The line at which this problem occurs is:StripDS stripDSImpl = (StripDS)Component.getInstance("stripDSImpl",true);
stripDSImpl is DAO in my application.
Regards,
Suraj -
3. Re: How to use @Startup annotation?
monkeyden Jun 4, 2007 2:18 PM (in response to surajmundada)post your code. You probably have something else which is SESSION scoped in there. Same thing happened to me when I tried to inject the Messages map into an application scoped component.
-
4. Re: How to use @Startup annotation?
surajmundada Jun 5, 2007 12:07 AM (in response to surajmundada)Thanks for the reply.
Here is the code.@Startup @Scope(ScopeType.APPLICATION) @Name("populateCommercialStripsListener") public class PopulateCommercialStripsListener { private Logger logger = Logger.getLogger(PopulateCommercialStripsListener.class); private LoggingHelper helper = LoggingHelper.getInstance(); private StripTypePE stripTypePE; @Create public void populateCommercialStrips() { try { // Initialize different modules we reuse from ATB new application. QatbApplicationControl.initQATBComponents(); // Get the complete list of commercial strips - It returns a map containing the strip names as keys and strip code as values. // We have chosen to put the strip names as keys because the calling program will get the strip description from its name. Map listOfStrips = QATBCommercialStripsManager.getInstance().getListOfStripNames(); Iterator iteratorOnStripNames = listOfStrips.keySet().iterator(); stripTypePE = new StripTypePE(MiscellaneousConstants.COMMERCIAL_STRIP_TYPE, MiscellaneousConstants.COMMERCIAL_STRIP_TYPE_NAME, MiscellaneousConstants.COMMERCIAL_STRIP_TYPE_DESCRIPTION); // Display the composition for the strips stored in the database Long id = MiscellaneousConstants.COMMERCIAL_STRIP_INITIAL_PK; StripDS stripDSImpl = (StripDS)Component.getInstance("stripDSImpl",true); while (iteratorOnStripNames.hasNext()) { String stripName = (String) iteratorOnStripNames.next(); String stripCode = (String) listOfStrips.get(stripName); ATBStripDescription strip = QATBCommercialStripsManager.getInstance().getCommercialStrip(stripCode); if(stripDSImpl.getStripPE(id) == null) { StripPE objStripPE = createCommercialStrip(strip,id); if(objStripPE != null) { populateStripInfo(strip,id,objStripPE); } } id++; } } catch () { ........ } }
StripTypePE is an EJB3 enitity with Session scope.
stripDSImpl is DAO with Session scope.@Stateless @Name("stripDSImpl") @Scope(SESSION) public class StripDSImpl implements StripDS { ........ ........ } @Entity @Table(name = "STRIP_TYPE", uniqueConstraints = { @UniqueConstraint(columnNames ={ "NAME" }) }) @Name("stripTypePE") @Scope(SESSION) public class StripTypePE implements Serializable { ........ ........ }
is the Session scope of these two classes the root of the problem of "No session context active"?
Regards,
Suraj -
5. Re: How to use @Startup annotation?
quilleashm Jun 5, 2007 10:28 AM (in response to surajmundada)You cannot use a session scoped component from within the @Create method of an application scoped component that has @Startup. If you think about it your create method is getting run as soon as the web application starts up. At this point there will never be an active session scope. The session scope is only available during a client/JSF request.
You need to have a look at your components and what purpose they have. Something is definately wrong with your scoping or component interaction.
Cheers.
Mike. -
6. Re: How to use @Startup annotation?
surajmundada Jun 6, 2007 2:16 AM (in response to surajmundada)Thanks for all the help.
Will try creating new components instead of reusing session scoped components.