Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Duplicate threads created by @Schedule method  RSS feed

 
Joe Richard
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method that uses the @Schedule annotation.  It is suppose to create and execute one thread but two threads are getting created.



The messages that are created in the console.log are;
606225 [LargeThreadPool-thread-107] INFO com.uline.silverpopxmlapi.ftpdata.FTPFileCheck  - [USER:Unknown][TIERevClients] *** FTP job scheduled for 12/20/2016 17:52:08
606303 [LargeThreadPool-thread-121] INFO com.uline.silverpopxmlapi.ftpdata.FTPFileCheck  - [USER:Unknown][TIERevClients] *** FTP job scheduled for 12/20/2016 17:52:08

How do I keep the second thread from being created?

I am running on Liberty server.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2920
205
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method that uses the @Schedule annotation

Is this method on a Stateless Session Bean?

It is suppose to create and execute one thread but two threads are getting created.

This is typical behaviour when your application runs in a cluster. In that case you need to configure a persistent timer (persistent=true) in your Liberty server.
 
Joe Richard
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this method on a Stateless Session Bean?

The method is on a @Singleton Bean.

It is suppose to create and execute one thread but two threads are getting created.

I get the error on my local machine doing unit testing also.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2920
205
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method is on a @Singleton Bean.

Yeah, I have seen this happening also with the @PostConstruct method of a Singleton. You might want to try a Stateless Session Bean.

Are you sure that the two threads are running? It might just be the Logger logging twice.
 
Joe Richard
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the two threads are running? It might just be the Logger logging twice.


It is not the logger, the application sends emails of its progress; I am getting duplicate emails from the application also.
I am not sure what the container does when it creates the timer and the timer times out.

I will give the @Stateless @Session bean a try.
 
Joe Richard
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried a @Stateless @Session bean and I get the same duplicate thread being created.



Still getting duplicate threads from Websphere Liberty.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2920
205
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still getting duplicate threads from Websphere Liberty.

Sounds like a bug to me.

I don't know if you are deploying locally from the Eclipse-WAS-liberty plugin but that has given me unexpected results more than once. If so, try to deploy the ejb-jar or ear manually through the admin console.

Another thing I would check is the ejb-jar.xml: you don't have the same EJB declared in the ejb-jar.xml and by annotations, do you?
 
Joe Richard
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thing I would check is the ejb-jar.xml: you don't have the same EJB declared in the ejb-jar.xml and by annotations, do you?


I do not,  my ejb-jar file is empty.

Here are the EJB annotations I am using:

RunSilverpopReportBean


SilverpopTimer


My method is annotated using the @Schedule annotation:


Still submits a duplicate job.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!