我想为JasperReport运行示例演示,所以我下载了该文件但是当我在Windows 7命令行according to the Jasperreport documentation中输入以下内容时:
C:\jasperreports-4.7.0\demo\samples\barbecue>ant run
我收到以下错误:
“烧烤”项目中不存在目标“运行”。
那么可能是什么问题?
::修订::
在我的CMD中输入ant –p
后,我得到以下内容: -
C:\jasperreports-4.7.0\demo\samples\barbecue>ant -p
Buildfile: C:\jasperreports-4.7.0\demo\samples\barbecue\build.xml
Shows how barcodes could be included in reports using the Barbecue component.
Main targets:
clean Deletes all the generated files.
compile Compiles the XML report design and produces the .jasper file.
csv Generates a CSV version of the report by converting the .jrprint
file.
decompile Decompiles a .jasper file into a .jrxml file.
docx Generates a DOCX version of the report by converting the .jrprin
t file.
fill Fills the compiled report design with data and produces the .jrp
rint file.
html Generates an HTML version of the report by converting the .jrpri
nt file.
javac Compiles the java source files of the test application.
jxl Generates an XLS version of the report by converting the .jrprin
t file using the JExcelApi library.
ods Generates an ODS version of the report by converting the .jrprin
t file.
odt Generates an ODT version of the report by converting the .jrprin
t file.
pdf Generates a PDF version of the report by converting the .jrprint
file.
pptx Generates a PPTX version of the report by converting the .jrprin
t file.
print Sends the report in the .jrprint file to the printer.
rtf Generates an RTF version of the report by converting the .jrprin
t file.
test Runs the sample.
view Launches the report viewer to preview the report stored in the .
jrprint file.
viewDesign Launches the design viewer to preview the compiled report design
.
viewDesignXml Launches the design viewer to preview the XML report design.
viewXml Launches the report viewer to preview the generated report store
d in an XML file.
writeApi Generates a .java version of the report by converting the .jrxml
file.
writeApiXml Generates a .jrxml version of the report by executing the API ve
rsion of the report design.
xhtml Generates an XHTML version of the report by converting the .jrpr
int file.
xls Generates an XLS version of the report by converting the .jrprin
t file using the POI library.
xlsx Generates an XLSX version of the report by converting the .jrpri
nt file.
xml Generates an XML version of the report by converting the .jrprin
t file.
xmlEmbed Generates an XML version of the report by converting the .jrprin
t file.
Default target: test
::::: UPDATED2 :::::
我为图表演示输入ant test
,但问题仍然存在: -
C:\jasperreports-4.7.0\demo\samples\charts>ant test
Buildfile: C:\jasperreports-4.7.0\demo\samples\charts\build.xml
test:
[echo] ===================================
[echo] Charts Sample
[echo] ===================================
clean:
clean-sample:
javac:
javac:
[mkdir] Created dir: C:\jasperreports-4.7.0\demo\samples\charts\build\classe
s
[javac] C:\jasperreports-4.7.0\demo\samples\build.xml:41: warning: 'includea
ntruntime' was not set, defaulting to build.sysclasspath=last; set to false for
repeatable builds
[javac] Compiling 2 source files to C:\jasperreports-4.7.0\demo\samples\char
ts\build\classes
[javac] warning: [options] bootstrap class path not set in conjunction with
-source 1.6
[javac] Note: C:\jasperreports-4.7.0\demo\samples\charts\src\ChartsApp.java
uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 warning
[copy] Copied 5 empty directories to 5 empty directories under C:\jasperrep
orts-4.7.0\demo\samples\charts\build\classes
compile:
compile:
[mkdir] Created dir: C:\jasperreports-4.7.0\demo\samples\charts\build\report
s
[jrc] Compiling 24 report design files.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\MultipleAx
isChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\XYBarChart
TimePeriodReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\XYAreaChar
tReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\Pie3DChart
Report.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\StackedBar
3DChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\MeterChart
Report.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\XYBarChart
Report.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\StackedAre
aChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\Candlestic
kChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\HighLowCha
rtReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\XYLineChar
tReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\BubbleChar
tReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\Thermomete
rChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\StackedBar
ChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\ScatterCha
rtReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\TimeSeries
ChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\SubDataset
ChartReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\AreaChartR
eport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\LineChartR
eport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\XYBarChart
TimeSeriesReport.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\GanttChart
Report.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\PieChartRe
port.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\Bar3DChart
Report.jrxml ... OK.
[jrc] File : C:\jasperreports-4.7.0\demo\samples\charts\reports\BarChartRe
port.jrxml ... OK.
test:
[java] net.sf.jasperreports.engine.JRException: java.sql.SQLException: sock
et creation error
[java] at net.sf.jasperreports.engine.util.AbstractSampleApp.getDemoHsq
ldbConnection(AbstractSampleApp.java:158)
[java] at ChartsApp.fill(ChartsApp.java:83)
[java] at ChartsApp.test(ChartsApp.java:63)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:57)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at net.sf.jasperreports.engine.util.AbstractSampleApp.executeTas
k(AbstractSampleApp.java:94)
[java] at net.sf.jasperreports.engine.util.AbstractSampleApp.main(Abstr
actSampleApp.java:179)
[java] at ChartsApp.main(ChartsApp.java:54)
[java] Caused by: java.sql.SQLException: socket creation error
[java] at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
[java] at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
[java] at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
[java] at org.hsqldb.jdbcDriver.connect(Unknown Source)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:579)
[java] at java.sql.DriverManager.getConnection(DriverManager.java:221)
[java] at net.sf.jasperreports.engine.util.AbstractSampleApp.getDemoHsq
ldbConnection(AbstractSampleApp.java:150)
[java] ... 9 more
BUILD SUCCESSFUL
Total time: 8 seconds
C:\jasperreports-4.7.0\demo\samples\charts>ant run
Buildfile: C:\jasperreports-4.7.0\demo\samples\charts\build.xml
BUILD FAILED
Target "run" does not exist in the project "charts".
Total time: 0 seconds
答案 0 :(得分:3)
Java错误就像车祸。一辆汽车撞到另一辆汽车,导致第一辆汽车照亮路灯。路灯翻倒并撞上一辆爆炸的汽油卡车。
最后,你有毁灭,火灾和死亡。然而,整个事情开始是因为司机太忙了发短信并且没有停在停车标志处。
你有一长串的错误信息,但最重要的是那些最重要的信息:
net.sf.jasperreports.engine.JRException: java.sql.SQLException: socket creation error
[java] at net.sf.jasperreports.engine.util.AbstractSampleApp.getDemoHsqldbConnection(AbstractSampleApp.java:158)
这是套接字创建错误。
此错误似乎指出您无法连接到服务器或数据库。
而且,这就是我可以得到的。我真的不认识贾斯帕,但我找到了this。这对你有帮助吗?
您应该运行服务器,还是需要连接到未创建的数据库?您是否有阻止连接到服务器/数据库的防火墙。 (我倾向于数据库问题,因为我确实在您的错误消息中看到了关于 hsqldb 和 sql 的内容。
我认为你不是Java开发人员,因为你似乎对Ant和它的 build.xml 文件感到困惑。有人可以帮助你吗?如果可以,请查看 build.xml 并查看目标 test 正在执行的操作。它正在运行Java命令,您可以尝试在Ant之外运行该命令。有时,这会给你更多信息。
答案 1 :(得分:2)
您应该运行 ant test
命令来运行示例(清理,编译和生成所有格式的报告:xls,pdf等)。
要查看 JRViewer 中的报告,您应该运行 ant view
命令。
ant test
的结果(输出)将为:
d:\java\jasperreports-4.5.1\demo\samples\barbecue>ant test
Buildfile: d:\java\jasperreports-4.5.1\demo\samples\barbecue\build.xml
test:
[echo] ===================================
[echo] Barbecue Sample
[echo] ===================================
clean:
clean-sample:
javac:
javac:
[mkdir] Created dir: d:\java\jasperreports-4.5.1\demo\samples\barbecue\build
\classes
[javac] d:\java\jasperreports-4.5.1\demo\samples\build.xml:41: warning: 'inc
ludeantruntime' was not set, defaulting to build.sysclasspath=last; set to false
for repeatable builds
[javac] Compiling 1 source file to d:\java\jasperreports-4.5.1\demo\samples\
barbecue\build\classes
compile:
compile:
[mkdir] Created dir: d:\java\jasperreports-4.5.1\demo\samples\barbecue\build
\reports
[jrc] Compiling 1 report design files.
[jrc] File : d:\java\jasperreports-4.5.1\demo\samples\barbecue\reports\Bar
becueReport.jrxml ... OK.
test:
[java] Filling time : 3198
[java] PDF creation time : 993
[java] XML creation time : 224
[java] XML creation time : 44
[java] HTML creation time : 109
[java] RTF creation time : 98
[java] XLS creation time : 364
[java] XLS creation time : 248
[java] CSV creation time : 6
[java] ODT creation time : 95
[java] ODS creation time : 12
[java] DOCX creation time : 183
[java] XLSX creation time : 103
[java] PPTX creation time : 74
[java] XHTML creation time : 56
BUILD SUCCESSFUL
Total time: 13 seconds
对net.sf.jasperreports.engine.JRException: java.sql.SQLException: sock
et creation error
例外的反应:
您尝试启动的示例是使用与 HSQLDB 服务器的连接。要启动数据库,您应该从 ant runServer
文件夹中运行 demo/hsqldb
命令。
有关如何运行示例的详细信息,请阅读this post