• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Duplicate threads created by @Schedule method

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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][TIER:DevClients] *** FTP job scheduled for 12/20/2016 17:52:08
606303 [LargeThreadPool-thread-121] INFO com.uline.silverpopxmlapi.ftpdata.FTPFileCheck  - [USER:Unknown][TIER:DevClients] *** 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.
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic