我几乎没有使用内置函数DAYS(DATE1,DATE2)来计算两个日期之间的天数。
我的表达是(DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_fin_sejour}))+1).
它在Jaspersoft studio 6.4.0上运行良好且没有错误,但是当我尝试使用JasperReports 6.2.0生成相同的报告时,我有一个错误:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE_1}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_de_fin_absence}))+1
- UUID : D22C5C66-1B4F-4DF4-BD44-1E639D1F5197
com.mysoftware.core.shared.exception.SysException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE_1}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_de_fin_absence}))+1
at sun.reflect.GeneratedConstructorAccessor1706.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.instantiate(ServerSerializationStreamReader.java:1110)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:682)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readObject(ServerSerializationStreamReader.java:592)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader$ValueReader$8.readValue(ServerSerializationStreamReader.java:149)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeValue(ServerSerializationStreamReader.java:434)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:312)
at com.mysoftware.core.server.service.RemoteServiceDispatcher.processCall(RemoteServiceDispatcher.java:64)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:373)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at com.mysoftware.core.server.servlet.filter.RoutingFilter.doFilter(RoutingFilter.java:93)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
和POM.xml
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.0</version>
<exclusions>
<exclusion>
<artifactId>ecj</artifactId>
<groupId>org.eclipse.jdt.core.compiler</groupId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcmail-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-functions</artifactId>
<version>6.2.0</version>
</dependency>
我使用JAVA作为表达式的语言
该表达式如何在Jaspersoft Studio上正常运行而不在JasperReports上运行?
答案 0 :(得分:0)
感谢所有人,特别是@AlexK,他们搜索了图书馆。
问题不在于缺少jasperreports-functions libs,而是缺少jats-time库,jasperreports-functions在DAYS(),YEARS()和MONTHS()方法中使用。 添加https://github.com/JodaOrg/joda-time/releases/download/v2.9.9/joda-time-2.9.9.jar解决了我的问题。