I am trying to combine Jaspersoft Studio with DeployR script. I am using this tutorial from Microsoft here which is in fact for iReport (the former solution of Jaspersoft Studio). I have added the necessary jar files as in tutorial to the class path, and deployed the R script in DeployR.
After running the report in Jasper there comes nothing on the report with no errors given. But I have a warning which says: No query executer factory class registered for deployrScript queries. So I guess the problem is that Jaspersoft Studio can not find the class for deployrScript, although this class jRQueryExecuter2 is in the class path!
In jrxml you can see the declaration:
<queryString language="deployrScript">
<![CDATA[<deployr url="http://127.0.0.1:8000/deployr">
<script filename="Cluster_Demo_Jasperserver.R" directory="root" author="testuser"/>
</deployr>]]>
</queryString>
The whole jrxml is:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="deployrSample" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5a314889-9cd2-4943-ad5f-13ef1bd6ca74">
<parameter name="RRP_plotwidth" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[555]]></defaultValueExpression>
</parameter>
<parameter name="RRP_plotheight" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[555]]></defaultValueExpression>
</parameter>
<parameter name="RRP_dataset" class="java.lang.String">
<defaultValueExpression><![CDATA["iris"]]></defaultValueExpression>
</parameter>
<parameter name="RRP_clusters" class="java.lang.Integer">
<defaultValueExpression><![CDATA[3]]></defaultValueExpression>
</parameter>
<parameter name="RRP_clustering_type" class="java.lang.String">
<defaultValueExpression><![CDATA["hclust"]]></defaultValueExpression>
</parameter>
<queryString language="deployrScript">
<![CDATA[<deployr url="http://127.0.0.1:8000/deployr">
<script filename="Cluster_Demo_Jasperserver.R" directory="root" author="testuser"/>
</deployr>]]>
</queryString>
<field name="REPORT1" class="java.lang.String">
<fieldDescription><![CDATA[file:cluster_output.png]]></fieldDescription>
</field>
<pageHeader>
<band height="63" splitType="Stretch">
<image>
<reportElement x="30" y="10" width="50" height="37" uuid="4ce16c2b-5680-48b6-86e8-ce992c543a40"/>
<imageExpression><![CDATA["C:/Users/aort.png"]]></imageExpression>
</image>
</band>
</pageHeader>
<detail>
<band height="600" splitType="Stretch">
<image scaleImage="RetainShape" hAlign="Center">
<reportElement positionType="Float" x="100" y="40" width="353" height="218" uuid="f2294c37-5751-41f9-a3b4-fcfe80b69fec"/>
<imageExpression><![CDATA[$F{REPORT1}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
and the R script:
library(cluster)
#uncomment these lines to test in standalone mode
dataset <- "mtcars"
clusters <- 4
clustering_type <- 'hclust'
plotwidth<-555
plotheight<-555
if (dataset == 'iris') {
data <- iris[,1:4]
df <-data.frame(data$Sepal.Length, data$Sepal.Width)
} else if (dataset == 'mtcars') {
data <- mtcars
df <-data.frame(data$drat, data$disp)
} else {
stop("Enter a valid dataset")
}
if (clustering_type == 'kmeans') {
fit <- kmeans(df, clusters)
png("cluster_output.png", width=plotwidth, height=plotheight);
clusplot(df, fit$cluster, color=TRUE, shade=TRUE, labels=0, lines=0, main = dataset)
dev.off()
} else if (clustering_type == "hclust") {
d <- dist(as.matrix(df))
fit <-hclust(d)
png("cluster_output.png", width=plotwidth, height=plotheight);
plot(fit, main = dataset)
dev.off()
} else {
stop ("enter a valid clustering type")
}
The DeployR code:
library(cluster)
#uncomment these lines to test in standalone mode
#dataset <- "iris"
#clusters <- 4
#clustering_type <- 'hclust'
#plotwidth<-555
#plotheight<-555
if (dataset == 'iris') {
data <- iris[,1:4]
df <-data.frame(data$Sepal.Length, data$Sepal.Width)
} else if (dataset == 'mtcars') {
data <- mtcars
df <-data.frame(data$drat, data$disp)
} else {
stop("Enter a valid dataset")
}
if (clustering_type == 'kmeans') {
fit <- kmeans(df, clusters)
png("cluster_output.png", width=plotwidth, height=plotheight);
clusplot(df, fit$cluster, color=TRUE, shade=TRUE, labels=0, lines=0, main = dataset)
dev.off()
} else if (clustering_type == "hclust") {
d <- dist(as.matrix(df))
fit <-hclust(d)
png("cluster_output.png", width=plotwidth, height=plotheight);
plot(fit, main = dataset)
dev.off()
} else {
stop ("enter a valid clustering type")
}
I have added net.sf.jasperreports.query.executer.factory.deployrScript=com.revo.deployr.client.jasper.factory.RQueryExecuterFactory to properties as suggested by Narcis, but still the REPORT1 field is empty and I get nothing in report.
My question is how can I add DeployR to Jaspersoft Studio?