Re: Localizer in a new Thread
Ale, I got a org.hibernate.HibernateException: createCriteria is not valid without active transaction because the page that I am trying to render need to get an entity using hibernate. how could I solve this situation? thanks in advance On Fri, Jul 30, 2010 at 5:38 PM, Alex Objelean alex.objel...@gmail.comwrote: Yes, the solution I've mentioned in previous post should solve your problem. Alex On 30 July 2010 22:44, Fernando Wermus-3 [via Apache Wicket] ml-node+2308410-419528218-229...@n4.nabble.comml-node%2b2308410-419528218-229...@n4.nabble.com ml-node%2b2308410-419528218-229...@n4.nabble.comml-node%252b2308410-419528218-229...@n4.nabble.com wrote: Ale, Related to what you have mentioned. I render mails with some mockHTTPrequest and mockeHTTPResponse, etc. But, I need to render mails in a different thread than wicket's one. I have another servlet that runs Blazeds (Flex) where I also need to render some mails, but I got There is no application attached to current thread According to what you mentioned, could I solve this issue? thanks in advance. On Fri, Jul 30, 2010 at 5:46 AM, Alex Objelean [hidden email] http://user/SendEmail.jtp?type=nodenode=2308410i=0wrote: There was a long discussion about this. One of the proposal was to use InheritableThreadLocal which would solve this problem, but there was a lot of concerns about this approach. The solution I have found was this: If you create the thread with ExecutorService, you could do the following: final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; and execute you thread like this: service.submit(new Runnable() { @Override public void run() { //do stuff } }); This will ensure that Application is accessible from within newly created thread. Alex -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html?by-user=t Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email] http://user/SendEmail.jtp?type=nodenode=2308410i=1 For additional commands, e-mail: [hidden email] http://user/SendEmail.jtp?type=nodenode=2308410i=2 -- Fernando Wermus. www.linkedin.com/in/fernandowermus -- View message @ http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2308410.html To unsubscribe from RE: Localizer in a new Thread, click here http://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=YWxleC5vYmplbGVhbkBnbWFpbC5jb218MjMwNzczMnwtNDA5MTE1Njc3 . -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2308459.html Sent from the Wicket - User mailing list archive at Nabble.com. -- Fernando Wermus. www.linkedin.com/in/fernandowermus
SV: Localizer in a new Thread
To clarify, I want to use Localizer#getString(...) in a thraed I create. I have seen other posts on this issue, but haven't been able to figure out the solution. The Localizer.getString() looks for its messages in Wicket's property file structure, which depends on Application, the resource-oriented classes, hierarchies and so forth. Your best bet is to pre-read the values you need into a Properties object that you pass to the thread code. - Tor Iver - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localizer in a new Thread
There was a long discussion about this. One of the proposal was to use InheritableThreadLocal which would solve this problem, but there was a lot of concerns about this approach. The solution I have found was this: If you create the thread with ExecutorService, you could do the following: final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; and execute you thread like this: service.submit(new Runnable() { @Override public void run() { //do stuff } }); This will ensure that Application is accessible from within newly created thread. Alex -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localizer in a new Thread
I am not sure how to preload the the values. I am trying this, but am not getting anywhere. myApp.getResourceSettings().getPropertiesFactory().load(ScanManTask.clas s, com.scanman.cron.task) I have a properties file named ScanManTask.properties and have added it to my app like this: getResourceSettings().addStringResourceLoader(new ClassStringResourceLoader(ScanManTask.class)); ScanManTask is not a commponent. The load method has a clazz and path argument. I am assummeing the class is the class associated with the property file and the path is the package it is in? I guess I could just load them manually, but I would like to take advantage of localization. How do I get a localized version of a Properties object with my messages in it? -Original Message- From: Wilhelmsen Tor Iver [mailto:toriv...@arrive.no] Sent: Thursday, July 29, 2010 11:19 PM To: users@wicket.apache.org Subject: SV: Localizer in a new Thread To clarify, I want to use Localizer#getString(...) in a thraed I create. I have seen other posts on this issue, but haven't been able to figure out the solution. The Localizer.getString() looks for its messages in Wicket's property file structure, which depends on Application, the resource-oriented classes, hierarchies and so forth. Your best bet is to pre-read the values you need into a Properties object that you pass to the thread code. - Tor Iver - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Localizer in a new Thread
Ale, Related to what you have mentioned. I render mails with some mockHTTPrequest and mockeHTTPResponse, etc. But, I need to render mails in a different thread than wicket's one. I have another servlet that runs Blazeds (Flex) where I also need to render some mails, but I got There is no application attached to current thread According to what you mentioned, could I solve this issue? thanks in advance. On Fri, Jul 30, 2010 at 5:46 AM, Alex Objelean alex.objel...@gmail.comwrote: There was a long discussion about this. One of the proposal was to use InheritableThreadLocal which would solve this problem, but there was a lot of concerns about this approach. The solution I have found was this: If you create the thread with ExecutorService, you could do the following: final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; and execute you thread like this: service.submit(new Runnable() { @Override public void run() { //do stuff } }); This will ensure that Application is accessible from within newly created thread. Alex -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Fernando Wermus. www.linkedin.com/in/fernandowermus
Re: Localizer in a new Thread
Yes, the solution I've mentioned in previous post should solve your problem. Alex On 30 July 2010 22:44, Fernando Wermus-3 [via Apache Wicket] ml-node+2308410-419528218-229...@n4.nabble.comml-node%2b2308410-419528218-229...@n4.nabble.com wrote: Ale, Related to what you have mentioned. I render mails with some mockHTTPrequest and mockeHTTPResponse, etc. But, I need to render mails in a different thread than wicket's one. I have another servlet that runs Blazeds (Flex) where I also need to render some mails, but I got There is no application attached to current thread According to what you mentioned, could I solve this issue? thanks in advance. On Fri, Jul 30, 2010 at 5:46 AM, Alex Objelean [hidden email]http://user/SendEmail.jtp?type=nodenode=2308410i=0wrote: There was a long discussion about this. One of the proposal was to use InheritableThreadLocal which would solve this problem, but there was a lot of concerns about this approach. The solution I have found was this: If you create the thread with ExecutorService, you could do the following: final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; and execute you thread like this: service.submit(new Runnable() { @Override public void run() { //do stuff } }); This will ensure that Application is accessible from within newly created thread. Alex -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.htmlhttp://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2307732.html?by-user=t Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2308410i=1 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2308410i=2 -- Fernando Wermus. www.linkedin.com/in/fernandowermus -- View message @ http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2308410.html To unsubscribe from RE: Localizer in a new Thread, click herehttp://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=YWxleC5vYmplbGVhbkBnbWFpbC5jb218MjMwNzczMnwtNDA5MTE1Njc3. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Localizer-in-a-new-Thread-tp2307306p2308459.html Sent from the Wicket - User mailing list archive at Nabble.com.
Localizer in a new Thread
I want to take advantage of Wicket's message localization in a new thread I have created. I am trying to pass the localizer to a thread that runs background tasks. I am geting an org.apache.wicket.WicketRuntimeException: There is no application attached to current thread I am sure I am going about this the wrong way. What's the best way to get message localization in a new thread ? Thanks, Warren mailto:don...@prosolutionssd.com
RE: Localizer in a new Thread
To clarify, I want to use Localizer#getString(...) in a thraed I create. I have seen other posts on this issue, but haven't been able to figure out the solution. Warren -Original Message- From: Warren Bell [mailto:warr...@clarksnutrition.com] Sent: Thursday, July 29, 2010 3:31 PM To: users@wicket.apache.org Subject: Localizer in a new Thread I want to take advantage of Wicket's message localization in a new thread I have created. I am trying to pass the localizer to a thread that runs background tasks. I am geting an org.apache.wicket.WicketRuntimeException: There is no application attached to current thread I am sure I am going about this the wrong way. What's the best way to get message localization in a new thread ? Thanks, Warren - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org