[EJB 3.0] - Re: Create timer -
by rruppel
First of all, thanks very much for starting helping me...
let me say what I am trying to do:
get an interval from database and use this interval to schedule my timer
but, I make this twice in the code
1. when the appplication is deployed
2. at the end of each execution I schedule it again (this is the problem!)
ok, now I will write what I did:
first I have made a mistake at my first code and when I corrected it, the error has changed to:
anonymous wrote :
| Trying to start a new tx when old is not completed
| anonymous wrote :
| |
| | well... this error is exactly what I am doing.... (I agree with the error...lol) so how can I commit the transaction and then call the other method to shedule?
| |
| | I tryed some things, and what make me confuse is:
| |
| | when the application is deployed it schedules fine the timer.... maybe because it calls the "schedule" method through a Local interface, like you suggested
| |
| | I suppose that calling the method through the Local interface completes the transactions before calling the method.... but is it right? (I think it shouldnt)
| |
| | well... like the @Timeout method is the one that has to schedule the next execution... i cant call the schedule method through a @Local interface (only if it would be possible to have an instance of the own class injected on it... I can try this... but its ugly)
| |
| | I will help any advice... thanks
| |
| |
| | ps: I havent seem oscar message before
| |
| | oscar, I thought using this solution, but I know that circular reference is a problem with jboss (at least ive never found a solution)
| |
| | thanks for trying to help
| |
| |
| |
| |
| |
| |
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139495#4139495
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139495
18 years
[EJB 3.0] - Re: Create timer -
by oskar.carlstedt
Hmm... and now you're back where you started, aren't you?
This is a pretty annoying problem. Is there a working example of doing this within an EJB? Is the following solution possible?
| @Stateless
| @Local
| public class A {
|
| @EJB
| B b;
|
| /**
| * this method is the one that is invoked by the 'user'
| **/
| public void someBusinessMethodThatHasToCreateATimer(...) {
| ...
| b.startTimer();
| }
|
|
| /**
| * this method will do the timeout job
| **/
| public void handleTimeout(Timer timer) {
| ...
| }
|
| }
|
|
| /**
| * this is a wrapper class to get a new transaction that only has to
| * deal with one data source in its own transaction.
| **/
| @Stateless
| @Local
| public class B {
|
| @Resource
| EJBContext ejbContext;
|
| @EJB
| A a;
|
| /**
| * this method is invoked by A. the result shall be
| * a created and persisted timer.
| **/
| public void startTimer() {
| ejbContext.getTimerService().createTimer(...);
| }
|
| /**
| * handles the timeout and will not do anything more
| * than just call the handleTimeout in A.
| **/
| @Timeout
| public void timeout(Timer timer) {
| a.handleTimeout(timer);
| }
|
| }
|
|
This is not a nice solution using a circular reference, but is there any other way get around this problem without reconfiguring JBoss?
Cheers
/Oskar
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139492#4139492
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139492
18 years
[Persistence, JBoss/CMP, Hibernate, Database] - Re: why nobody talks openJPA here?
by ajay662
Let me wrap up my findings for the benefit of others.
I ended up using Hibernate.
With 0.9.7 openjpa, i ran into the error that others have experienced too: org.apache.openjpa.persistence.PersistenceException: Invalid use of
| destroyed classloader, UCL destroyed at:
With 1.0 openjpa, my application came up ok but I saw all kinds of strange runtime errors.
So I gave up on openjpa and switched to hibernate.
But switching to Hibernate was not all that straight forward. It seems there are some inconsistencies between hibernate and openjpa when it comes to @IdClass. The two that I faced were :
1) Hibernate picks up the annotations from @IdClass, whereas openJPA picks up from the Entity class.
2) Hibernate needs both name and type of the id fields to be same in Entity class and IdClass, whereas OpenJPA wants type of the @ManyToOne field in the IdClass to be that of the primary key of the associated table.
Once I aligned my code to what hibernate wants, my application came up ok.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139482#4139482
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139482
18 years