Additional updates:
I've updated my scheduler so that instead of retrieving messages via Spring Data JPA, it now uses Spring Data Mongo:
My service scheduler has a simple method:
Code:
@Override
List<Person> persons = personService.getAll();
for (Person person : persons) {
logger.debug(person);
}
It prints out the person's info every 5 seconds. (I didn't include the declaration of the scheduler)
Now, I want to verify if the Pageable feature is really causing the issue. I want to know if this bug is related with Spring Data JPA only or not.
So I changed my code to
Code:
@Override
List<Person> persons = personService.getAll(new PageRequest(0,1));
for (Person person : persons) {
logger.debug(person);
}
By the way personService is a wrapper to the PersonRepository.
And right after I run my application, I get the same exception as with the JPA version!
Code:
[DEBUG] [scheduler-2 01:00:42] (ErrorLogAspect.java:logAround:43) Error caught...saving to db log: java.util.NoSuchElementException
[ERROR] [scheduler-2 01:00:42] (TaskUtils.java:handleError:95) Unexpected error occurred in scheduled task.
java.lang.NullPointerException
at org.krams.tutorial.aop.ErrorLogAspect.logAround(ErrorLogAspect.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy128.post(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
My initial conclusion here is that the issue is related with the spring-data-commons-core!