[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-25 Thread baz
We have a similar problem. We have to initialize a Catalog seam component from 
database when seam is started.
Our solution:
Catalog is application scoped. Our users must login before they can use the app.
So we put this statement in our authorization bean:
@In(create = true)
  | private Catalog catalog;
  | 
The first login initializes the component.
It is only a workaround and does not work with apps when there is no need to 
login.
Ciao,
baz

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4040430#4040430

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4040430
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-25 Thread baz
Forget my post. i haven't read the second page of this thread before posting:-(

I will try org.jboss.seam.postInitialization event but i must find time:-(

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4040431#4040431

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4040431
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-24 Thread petemuir
Sammy, you can use the org.jboss.seam.postInitialization event in CVS - it runs 
last so all Seam components should be available by then.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4040373#4040373

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4040373
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread Sammy8306
Bumping this one since I'd really like to make this work... thanks!

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039790#4039790

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039790
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread petemuir
You can't/shouldn't access an EntityManager during @Startup.

My suggestion is to schedule your method to execute at a later date using 
@Asynchronous

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039792#4039792

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039792
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread denis.diggin
Try @Startup(depends=org.jboss.seam.core.ejb)

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039907#4039907

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039907
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread Sammy8306
That looked promising, but same problem unfortunately... hm, anything else it 
could depend upon? Or should I just heed petemuir's advice ;-) ? 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039927#4039927

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039927
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread CptnKirk
You might be able to use an observer on a seam contextual event.  Unfortunately 
I don't see a seam fully initialized event.  Maybe postCreate, or if your app 
requires authentication, preAuthenticate.  I'm just looking at the docs, there 
may be additional events that have been added.  It shouldn't be hard to add 
that fully initialized event so other components can kick off startup tasks 
without worrying about what resources are available and what aren't.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039934#4039934

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039934
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread petemuir
org.jboss.seam.core.ejb is the EJB microcontainer - nothing to do with the 
entitymanager.

I've added an org.jboss.seam.postInitialization event to CVS, consider this an 
experimental feature for now that may be removed.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039974#4039974

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039974
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread Sammy8306
I solved my problem, kind of obvious now I know Seam a bit better:

1) created an application scope component that does the DB initialization in an 
@Create component (do not use @Startup for this component)
2) Inject this into the first component (using @In(create=true) that gets 
called in the application - the application scope ensures that the component 
only is created once... right?

Looks like its working anyway. Thanks all!

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039976#4039976

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039976
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread Sammy8306
of course this doesn't work well when the entry point of the application is not 
a single well-defined point, so I think I will look at the eventlistener 
solution as well.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039977#4039977

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039977
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread petemuir
Yes this works, but it's not the neatest :(

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039978#4039978

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039978
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread petemuir
I need to get Gavin to review that change to check he is happy with it hence 
the note about it being experimental.  I'll post back here if it's not ok.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039979#4039979

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039979
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread CptnKirk
Hmm, PMs don't seem to be activated.  Anyway, please take a look at the placing 
of the Events.instance().raiseEvent(org.jboss.seam.postInitialization); line. 
 I'm guessing that this should come at the end of the method, or at least after 
the  Lifecycle.endInitialization(); since endInitialization resets all the 
contexts.

After the done initializing seam logging seems appropriate since once the 
event is raised Seam will synchronously execute any observers which may have 
logging of their own.  All of this should happen after seam has finish 
initializing.

Sry for the forum post.  Didn't know of a better way to send this.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039981#4039981

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039981
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-23 Thread petemuir
This forum install is a pile of  ;) You can always send an email if you 
like :)

So, the point at which Seam has finished init is just before 
Lifecycle.endInitialization() - that just cleans up the temporary contexts and 
runs startup.  It won't work after Lifecycle.endInitialization() as there are 
no contexts active (as you say ;) I suppose it could go in lifecycle after 
startup.

9:59:19,594 ERROR [[/seam-discs]] Exception sending context initialized event 
to listener instance of class org.jboss.seam.servlet.SeamListener
  | java.lang.IllegalStateException: No application context active
  | at org.jboss.seam.Component.forName(Component.java:1581)
  | at org.jboss.seam.Component.getInstance(Component.java:1631)
  | at org.jboss.seam.Component.getInstance(Component.java:1626)
  | at org.jboss.seam.Component.getInstance(Component.java:1603)
  | at org.jboss.seam.Component.getInstance(Component.java:1598)
  | at org.jboss.seam.core.Events.instance(Events.java:138)
  | at org.jboss.seam.init.Initialization.init(Initialization.java:501)
  | at 
org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
  | at 
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
  | at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
  | at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
  | at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
  | at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
  | at 
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
 Source)
  | at 
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
 Source)
  | at 
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
  | at 
org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
  | at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  | at 
org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
  | at 
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
 Source)
  | at 
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
 Source)
  | at 
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
  | at 
org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
  | at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  | at 
org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:300)
  | at 
org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
  | 19:59:19,594 ERROR [StandardContext] Error listenerStart

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4039982#4039982

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4039982
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-13 Thread petemuir
Create an Application scoped component annotated with @Startup and with a 
@Create method

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4036985#4036985

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4036985
___
jboss-user mailing list
[EMAIL PROTECTED]
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-13 Thread Sammy8306
Thanks! One problem though


  | @Startup
  | public class PopulateDB
  | {
  |@In
  |private EntityManager em;
  | 
  |@Create
  |public void populateDB(){
  |   em.beginTransaction();
  |   CreateTestData.createData(em);
  |}
  | }
  | 

Leads to this exception: javax.persistence.TransactionRequiredException: no 
transaction is in progress

I can't start a transaction from the EntityManager either: using 
getTransaction().begin() gives this exception: java.lang.IllegalStateException: 
JTA EntityManager cannot access a transactions

And yes, I am aware of the import.sql mechanism, however doing it 
programmatically would help me tremendously in my setting. Any ideas?

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4036994#4036994

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4036994
___
jboss-user mailing list
[EMAIL PROTECTED]
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Initialization code

2007-04-13 Thread Sammy8306
Oops, the em.beginTransaction() should not be there in the code block above 
(why can't I edit my posts?)

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4036998#4036998

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4036998
___
jboss-user mailing list
[EMAIL PROTECTED]
https://lists.jboss.org/mailman/listinfo/jboss-user