Jump to content
We've recently updated our Privacy Statement, available here ×

SecurityContext issue when running subreport


carloscz25

Recommended Posts

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)[/code]

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.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...