liviu.vasile
-
Posts
6 -
Joined
-
Last visited
Content Type
Profiles
Forum
Events
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Security Advisories
Downloads
Posts posted by liviu.vasile
-
-
Hello everyone,
I have two question about the Diagnostic Report.
1) Is the report available in CE for Jasper Server?
2) If yes, where can I find the jrxml for it?
Many thanks,
Liviu Vasile
-
I have the same need, I want to schedule about 2500 jobs, and I really don't want to use REST in a loop - most of the requests will be dropped.
Have you found a solution? I might insert the jobs directly into Jasper data base, but this is more of a workaround than a real solution.
Thanks!
-
I was able to produce a gradient using this code. My modifications are in red.
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Dimension2D;import net.sf.jasperreports.renderers.AbstractRenderToImageDataRenderer;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReportsContext;/**
* Draws a colored, circular gradient background used in the report.
*/
public class CircularGradientImageRenderer extends AbstractRenderToImageDataRenderer {
/**
* The gradient color.
*/
private String rgb;
private int width;
private int height;/**
* Create a circular gradient image in a bounded square.
*
* @param rgb The gradient color.
*/
public CircularGradientImageRenderer(String rgb) {
this.rgb = rgb;
}/**
* Pull out a substring without returning null.
*
* @param value The value.
* @param begin The beginning index.
* @param end The ending index.
* @return The substring.
*/
private static String safeSubstring(String value, int begin, int end) {
String sub = "";if (value != null) {
if (value.length() > begin) {
end = Math.min(end, value.length() - 1);
sub = value.substring(begin, end + 1);
}
}return sub;
}/**
* Parse a hex value without throwing an exception.
*
* @param value The value to convert.
* @return The integer value.
*/
private static int safeHexParse(String value) {
try {
return Integer.parseInt(value, 16);
} catch (NumberFormatException e) {
return 0;
}
}/**
* Convert a string hex color into a Java Color object.
*
* @param rgb The string value.
* @return The Color object.
*/
public static Color stringToRGB(String rgb) {
int r = 0;
int g = 0;
int b = 0;if (rgb != null && rgb.startsWith("#")) {
r = safeHexParse(safeSubstring(rgb, 1, 2));
g = safeHexParse(safeSubstring(rgb, 3, 4));
b = safeHexParse(safeSubstring(rgb, 5, 6));
}return new Color(r, g, b);
}public void render(JasperReportsContext jasperReportsContext
,Graphics2D g2d
,Rectangle2D rect) throws JRException {
// Save the Graphics2D affine transform
AffineTransform savedTrans = g2d.getTransform();float radius = (float) (Math.max(rect.getHeight(), rect.getWidth()) / 2);
float[] fractions = {0.0f, 0.3f, 1.0f};
Color[] colors = {Color.WHITE, Color.WHITE, stringToRGB(rgb)};// Paint a nice background...
g2d.setPaint(new RadialGradientPaint((float) rect.getCenterX(), (float) rect.getCenterY(), radius, fractions, colors));
this.width = (int) rect.getWidth();
this.height = (int) rect.getHeight();
g2d.fillRect((int) rect.getX(), (int) rect.getY(), this.width, this.height);
g2d.draw(rect);// Restore the Graphics2D affine transform
g2d.setTransform(savedTrans);
}
public Dimension2D getDimension(JasperReportsContext jasperReportsContext) throws JRException
{
return new Dimension(this.height,this.width);
}}
-
New idea
After writing the post I got an idea: what if my data adapter created on server is of wrong type? (I know, the interface says clearly "JSON Data Source"... but still).
So I compared the xml for my local data adapter:
<?xml version="1.0" encoding="UTF-8" ?><jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl"> <name>mydata</name> <dataFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="repositoryDataLocation"> <location>C:jsondatamydata.json</location> </dataFile> <language>json</language> <useConnection>true</useConnection> <timeZone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">Europe/Paris</timeZone> <locale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">en_US</locale> <selectExpression/></jsonDataAdapter>[/code]
With the one on the server:
<?xml version="1.0" encoding="UTF-8"?><customDataSource exportedWithPermissions="true"> <folder>/datasources</folder> <name>mydata</name> <version>0</version> <label>mydata</label> <creationDate>2019-03-28T12:10:10.000Z</creationDate> <updateDate>2019-03-28T12:10:10.000Z</updateDate> <serviceClass>com.jaspersoft.jasperserver.api.metadata.jasperreports.service.ReportDataAdapterService</serviceClass> <property> <key>fileName</key> <value>/jsondata/mydata.json</value> </property> <property> <key>language</key> <value>JSON</value> </property> <property> <key>_cds_name</key> <value>jsonDataSource2</value> </property> <property> <key>selectExpression</key> <value><![CDATA[Data]]></value> </property></customDataSource>[/code]
So we can see that the server created a "custom data source".
Solution (workaround)
I edited my local data adapter file to this (I just changed the "location" field)
<?xml version="1.0" encoding="UTF-8" ?><jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl"> <name>mydata</name> <dataFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="repositoryDataLocation">[/code]
<location>/jsondata/mydata.json</location></dataFile> <language>json</language> <useConnection>true</useConnection> <timeZone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">Europe/Paris</timeZone> <locale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:java="http://java.sun.com" xsi:type="java:java.lang.String">en_US</locale> <selectExpression/></jsonDataAdapter>[/code]
Then I uploaded it via the server's interface as a simple XML file (see this wiki).Then I added a property to my report:
<property name="net.sf.jasperreports.data.adapter" value="repo:/datasources/jsondata.xml"/>[/code]
Then I uploaded the report.
Now it works!
Real solution
Still waiting for one. That is, creating a JSON data source that works via interface.
Best regards,
Liviu Vasile
-
Hello,I've been trying to solve this problem for days now, and I'm running out of ideas.
com.jaspersoft.jasperserver.api.common.virtualdatasourcequery.VirtualDataSourceException: Teiid Virtual Data Source Query Service - unsupported data source: mydata[/code]
On my local machine (everything works)
I have a basic json file "mydata.json"
{"Data": {"Param1" :"Hello"}}[/code]
I have a data adapter pointing to it.
I have a very simple report that display the "Param1" field.
<queryString language="json"> <![CDATA[Data]]></queryString> [...]<field name="Param1" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="Param1"/> <fieldDescription><![CDATA[Param1]]></fieldDescription></field> [...]<textField> <reportElement x="0" y="0" width="100" height="30" uuid="8c01d597-ab0f-4282-9ecd-2c5f76a7ccb4"/> <textFieldExpression><![CDATA[$F{Param1}]]></textFieldExpression></textField>[/code]
The report works fine from Jasper Studio.On the server (Product Version: 7.1.0 Build: 20180504_1307)
I have a folder named /jasondata. The server has access to it.
I have a JSON data source named "mydata".
I publish my report to the server and use this data source.
When I try to run the report, I have this error:
Error MessageThere was an error on the server. Try again or contact site administrators. (Error UID: b2327bce-7cd9-4784-ba36-eb3415023c26)[/code]
The entire error message, from jasperserver.log
2019-03-28 12:16:54,089 DEBUG VirtualDataSourceQueryService,pool-6-thread-6:253 - ********* getConnectionFactory [bEGIN] *********************2019-03-28 12:16:54,092 DEBUG VirtualDataSourceQueryService,pool-6-thread-6:253 - Add sub data source - -4070346232019-03-28 12:16:54,107 ERROR ErrorPageHandlerAction,http-nio-8080-exec-10:115 - Error UID a8f718ab-73e5-4d22-934e-acb7b9f06206com.jaspersoft.jasperserver.api.JSExceptionWrapper:com.jaspersoft.jasperserver.api.common.virtualdatasourcequery.VirtualDataSourceException: Teiid Virtual Data Source Query Service - unsupported data source: mydata at com.jaspersoft.jasperserver.api.engine.common.virtualdatasourcequery.impl.TeiidVirtualDataSourceQueryServiceImpl.getDataSource(TeiidVirtualDataSourceQueryServiceImpl.java:739) at com.jaspersoft.jasperserver.api.engine.common.virtualdatasourcequery.impl.TeiidVirtualDataSourceQueryServiceImpl.getConnectionFactory(TeiidVirtualDataSourceQueryServiceImpl.java:717) at com.jaspersoft.jasperserver.api.engine.common.virtualdatasourcequery.impl.TeiidVirtualDataSourceQueryServiceImpl.addSubDataSource(TeiidVirtualDataSourceQueryServiceImpl.java:481) at com.jaspersoft.jasperserver.api.engine.common.virtualdatasourcequery.impl.AbstractVirtualDataSourceQueryServiceImpl.addOrMarkSubDataSource(AbstractVirtualDataSourceQueryServiceImpl.java:156) at com.jaspersoft.jasperserver.api.engine.common.virtualdatasourcequery.impl.AbstractVirtualDataSourceQueryServiceImpl.getConnectionFactory(AbstractVirtualDataSourceQueryServiceImpl.java:80) at com.jaspersoft.jasperserver.api.engine.common.virtualdatasourcequery.VirtualDataSourceHandler.getSqlDataSource(VirtualDataSourceHandler.java:148) at com.jaspersoft.jasperserver.api.engine.jasperreports.util.CustomJDBCReportDataSourceServiceFactory.createService(CustomJDBCReportDataSourceServiceFactory.java:80) 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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:91) at com.jaspersoft.jasperserver.api.metadata.user.service.impl.ProfileAttributesResolverAspect.resolveDataSourceAttributes(ProfileAttributesResolverAspect.java:47) 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 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.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy54.createService(Unknown Source) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.CustomReportDataSourceServiceFactory.createService(CustomReportDataSourceServiceFactory.java:103) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.CustomReportDataSourceServiceFactory$$FastClassBySpringCGLIB$$597fa680.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:91) at com.jaspersoft.jasperserver.api.metadata.user.service.impl.ProfileAttributesResolverAspect.resolveDataSourceAttributes(ProfileAttributesResolverAspect.java:47) 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 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.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.CustomReportDataSourceServiceFactory$$EnhancerBySpringCGLIB$$8bce4df3.createService(<generated>) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.CustomReportDataSourceServiceFactory$$FastClassBySpringCGLIB$$597fa680.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.CustomReportDataSourceServiceFactory$$EnhancerBySpringCGLIB$$a0c54208.createService(<generated>) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.createDataSourceService(EngineServiceImpl.java:2017) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1822) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runWithDataSource(EngineServiceImpl.java:1159) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runReport(EngineServiceImpl.java:1088) at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportRunnable.run(EngineServiceImpl.java:983) 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]
I have no clue, not even where to start.For instance, I don't understand why my Json data source is a "Virtual Data Source"...
Any help would be greatly appreciated!
Did someone successfuly used a JSON file that is local to the server? Or even uploaded to the server, by using "repo:/{path to file}"?
Thanks,
Liviu Vasile
Docker install 7.5 failing at create-ks interactive prompt
in Products
Posted
I was able to go past that point and install my docker by adding to my Dockerfile this line
ENV BUILDOMATIC_MODE=script
"script" was my choice, you can put anything there, as long as it's different from "interactive". There is only one IF in the script.xml, specifically for create-ks.
<if>
<and>
<isset property="env.BUILDOMATIC_MODE"/>
<equals arg1="${env.BUILDOMATIC_MODE}" arg2="interactive" />
</and>
<then>
<create-ks ks="${ks}" ksp="${ksp}" propsFile="${masterPropsSource}"
confirmArg="y"
confirmMessage="A new encryption key and a new keystore are about to be created. Any previously created key and keystore will become invalid and the corresponding passwords unusable. If you think this JasperReports Server instance already has a keystore configured by another OS user, stop this process and configure the path in keystore.init.properties file, then run this command again. See the JasperReports Server Security Guide for details. Do you want to continue? (%s/N)"/>
</then>
<else>
<echo message=""/>
<create-ks ks="${ks}" ksp="${ksp}" propsFile="${masterPropsSource}"
warningMessage="WARNING: A new encryption key and a new keystore are about to be created."/>
</else>
</if>