SecurityContext issue when running subreport

0

Hi,

since running subreports involves multithreading, I am running into an issue when producing certain reports, but not all, that include SUBREPORTS. The point is that the host platform (CUBA Platform) throws an IllegalStateException when calling Service methods from a subreport thread. I presume that for one-level reports the main thread is the same main thread running the middleware and therefore it arises no problem for subreport-less reports. However this is not 100% true, then I have one report with nested subreports which calls Service methods as well, but no problem arises.

For the affected reports, when running a subreport (presuming from a subreport thread) the following exception arises:

java.lang.SecurityException: No security context bound to the current thread
    at com.haulmont.cuba.core.sys.AppContext.getSecurityContextNN(AppContext.java:153)
    at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:85)
    at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy256.getFechaDevuelto(Unknown Source)
    at com.company.test1.service.accessory.HlpRecibo.getFechaDevuelto(HlpRecibo.java:107)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.company.test1.service.accessory.SIJRBeanDataSource.getFieldValue_(SIJRBeanDataSource.java:94)
    at com.company.test1.service.accessory.SIJRBeanDataSource.getFieldValue(SIJRBeanDataSource.java:67)
    at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1501)
    at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1402)
    at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1378)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1194)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:108)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:615)
    at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:432)
    at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:818)
    at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:61)
    at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

As I said, this doesn't happen with all reports that contain subreports, but this cause seems to be the main one. So either the report containing subreports uses only the main thread, or the failure is due to any other reason.

Is there the possibility to some how include a couple of lines of code in the thread to apply a securitycontext provided by the host platform? Additionally, is there another besides setting Jasperreports to single-threaded mode, to prevent from multithreading? Or something in the report I can somehow tweak? I have inspected reports (all including subreports) both working and failing, and at first sight nothing seems to affect the usage of a separate thread.

Deactivating multithreading is not an option then in parallel I have read performance degrades substantially.

Many thanks for your time and attention.

Regards,

Carlos Conti.

carloscz25's picture
Joined: Mar 31 2010 - 8:56am
Last seen: 1 month 4 weeks ago

0 Answers:

No answers yet
Feedback
randomness