B4J Question NextReport9.1 error generated during runtime

wangondu

Member
Licensed User
Longtime User
what could be the reason behind this error generated by the attached code
B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
   
    'This jar file must be present in the B4J Additional Libraries folder
    #AdditionalJar:    nextreports-engine-9.1
   
    'Don't forget to add jNxtReportsB4J in the B4J IDE Libraries tab
    #AdditionalJar: jNxtReportsB4J
    'Download these jar files to the B4J Libraries folder
    #AdditionalJar:commons-jexl-2.1.1
    #AdditionalJar:commons-logging-1.1.1
    #AdditionalJar:itext-2.1.7
    #AdditionalJar:itext-rtf-2.1.7
    #AdditionalJar:itextpdf-5.0.6
    #AdditionalJar:xstream-1.3.1
   #AdditionalJar:xstream-1.4.7
    #AdditionalJar:poi-3.7
    'replace this by your applicable database jar file
    #AdditionalJar: postgresql-42.1.4
       
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
   
    'File separator character is set, according to the OS detected.
    Dim os As String = GetSystemProperty("os.name", "").ToLowerCase
    Dim filesep As String
    If os.Contains("win") Then   
          filesep="\"
    Else If os.Contains("mac") Then
          filesep="/"
    End If   
   
    Dim inputlist As List
    Dim inlocation,repin, repout, reptype, driverclass, url As String
    Dim repexec As jNxtReportsB4J
   
    'Location of the *.report file and any necessary images
    inlocation=File.DirApp & filesep & "reports" 'For this demo the report is stored in the Objects/reports directory. You can specify any other directory.
    'name of report created by NextReports.
    repin="animals" ' Report specified: PHILTESTGR.report
   
    'Output file specification
    repout="animals" 'name of output report
    reptype="txt"  ' Available options: CSV, TXT, XLS, XML, PDF, HTML or RTF. File type must be in CAPITALS.
    'Output file will be MYOUTPUT.RTF. Output file (and any necessary images) will be stored in your application directory
   
   
    'replace this by your database driver class name
    driverclass="org.postgresql.Driver"

    'I use IP instead of server name. For some reason, in my tests with SQL SERVER, when I used server name, it would not not work on MACs
    url="jdbc:postgresql://172.16.10.130:5432/test"

    'Initialize input list and add necessary arguments in the order shown below
    inputlist.initialize
    inputlist.Add(inlocation)
    inputlist.add(repin)
    inputlist.add(repout)
    inputlist.add(reptype)
    inputlist.add(driverclass)
    inputlist.add(url)
   
    'Now add your parameters - if any
    'First, the parameter name - as it was defined in NextReports
    inputlist.add("Animals Population") 'The parameter name is IdParam
    'Then, your parameter value
    inputlist.add("id")
    inputlist.add("sC{id}")
    inputlist.add("name")
    inputlist.add("sC{name}")
    'You can add as many parameters as necessary


    'Run the report and export the output report file
    repexec.reportPrepAndRun(inputlist)

    'Show the output report file
    fx.ShowExternalDocument(File.GetUri(File.DIRAPP, repout & "." & reptype))
   
   
End Sub



error is

java.io.FileNotFoundException:
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
at ro.nextreports.integration.ReportExec.runReport(ReportExec.java:61)
at ro.nextreports.integration.ReportExec.reportPrepAndRun(ReportExec.java:90)
at b4j.example.main._appstart(main.java:164)
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 anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748)
 

Harris

Expert
Licensed User
Longtime User
I often get this when running in debug mode, particularly after changing something in the next reports parameters.
I then run in release and the issue goes away.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
reptype="txt" ' Available options: CSV, TXT, XLS, XML, PDF, HTML or RTF. File type must be in CAPITALS.
'Output file will be MYOUTPUT.RTF. Output file (and any necessary images) will be stored in your application directory

File type must be in CAPITALS - not the case here... ("txt") - should be "TXT"

Also,
'Don't forget to add jNxtReportsB4J in the B4J IDE Libraries tab
----> this is not required here, but checked off in libraries tab.... #AdditionalJar: jNxtReportsB4J

Where is the data coming from for the report?

If no report was generated - you will get error - File not found.

try:
if file.exists( File.dirapp,repout & "." & reptype) then
'Show the output report file
fx.ShowExternalDocument(File.GetUri(File.DIRAPP, repout & "." & reptype))
else
Log(" File not found: "&(repout & "." & reptype) )
end if
 
Upvote 0
Top