New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring @Scheduler Annotation Issues with jdk 1.8 & jdk 1.7 #157
Comments
Hello, @Sudheer786 !
|
Hi Artem, I made it as a static method as I need it running before the class gets Initialized, here are the complete details,
Server Details:
Listener Code is as below: @Configuration
@EnableScheduling
public class CSVFileProcessor {
@Scheduled(fixedRate = 10000)
public static synchronized void pollDirectory() {
System.out.println("***started Polling***");
faxFolder = Paths.get(folderPath);
try {
watchService = FileSystems.getDefault().newWatchService();
faxFolder.register(watchService,
StandardWatchEventKinds.ENTRY_CREATE);
do {
WatchKey watchKey = null;
try {
watchKey = watchService.take();
} catch (InterruptedException e) {
System.out.println("Interrupted Exception cause "
+ e.getMessage() + e);
e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception cause .. " + e.getMessage()
+ e);
}
for (WatchEvent event : watchKey.pollEvents()) {
WatchEvent.Kind kind = event.kind();
if (StandardWatchEventKinds.ENTRY_CREATE.equals(event
.kind())) {
String fileName = event.context().toString();
System.out.println("File Created:" + fileName);
String txtFileAbsPath = faxFolder.toString()
.concat("\\").concat(fileName);
System.out.println("##### Text file absolute Path .. "
+ txtFileAbsPath);
if (txtFileAbsPath.contains(".txt")) {
System.out
.println("************** calling processFile() method on file : "
+ txtFileAbsPath);
processFile(txtFileAbsPath);
}
}
}
valid = watchKey.reset();
} while (valid);
} catch (IOException e) {
System.out.println("IOException while polling Directory cause "
+ e.getMessage() + e);
e.printStackTrace();
}
}
} and the error on Server as mentioned above ,
Is there anything you suspect on the above please ? thanks In Advance . |
??? How you can make it running before class gets Initialized, if it is
So, we deal here with the bean exactly, not class. Therefore your From other side it looks like the problem is somewhere in a different place and doesn't relate to the |
yeah , I got you .. sorry below is the Exception where I am stuck ,
this might be being caused as I kept synchronized for my
|
And? Does it help you somehow to overcome issue? You have a dead lock with the |
Note: please, read about the comments syntax here on the GitHub: https://guides.github.com/features/mastering-markdown/. |
Hi Artem, we are developing this to run along with Activiti , hence it becoming a little difficult to solve the Issues . thanks a lot for your inputs which helped me to solve the Issue. |
Glad to hear! Let us know if we can close the issue or do that yourself. Comeback to us anytime, but try to post the issue in the proper place. |
Hi Artem, thanks a lot .. sure , I will make sure to post in proper place. I am closing the Issue. |
I'll give it a try then,thanks a lot ,gus |
Hi Team,
here is my piece of code,
The above Code is running perfectly with Tomcat 7 & jdk 1.8
but when I use jdk 1.7 , The Server is getting hanged while trying to initialize
Spring FrameworkServlet 'appDispatcher' .
Is there anything to do with jdk Versions ?
can you help me please ?
The text was updated successfully, but these errors were encountered: