Skip to content

Your report has an error and couldn't be processed! Try to output the command using the function output(); and run it manually in the console. #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erick-chali opened this issue Nov 21, 2016 · 37 comments

Comments

@erick-chali
Copy link

I am trying to make the report to work but for some reason I can't get it done,

  • I install Jasperstarter and set up the environment variable.
  • I'm using the example of hello_world.jrxml
  • I'm using laravel 5.3 project.

my code:

use JasperPHP\JasperPHP;
public function partida_provisiones_get_data(Request $request)
{
     $input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jrxml';
     $jasper = new JasperPHP;
     $jasper = \JasperPHP::compile($input)->execute();
}

But for some reason I'm getting this error:
screenshot 174

Can you tell me if there is any missing step.

@erick-chali erick-chali changed the title Your report has an error and couldn 't be processed! Your report has an error and couldn't be processed! Try to output the command using the function output(); and run it manually in the console. Nov 21, 2016
@jadsonbr
Copy link
Contributor

Make sure you have java installed with the command below.

java -version

@erick-chali
Copy link
Author

It is
version 1.8
jre also is installed

@jadsonbr
Copy link
Contributor

Substitua o código abaixo

$jasper = \JasperPHP::compile($input)->execute();

per

$jasper = \JasperPHP::compile($input)->output();

And the result runs in the terminal

@jadsonbr
Copy link
Contributor

Do not forget to grant permission 777 for the directory /vendor/geekcom/phpjasper/src/JasperStarter/bin and the file binary jasperstarter

@erick-chali
Copy link
Author

Here is the output as you request.
screenshot 179

And the folder was granted with permissions

@jadsonbr
Copy link
Contributor

It was set at pull request #16
Now it's just you roll
composer update

@erick-chali
Copy link
Author

well I think I'm halfway to solve this, thanks for the fix before, now I was able to compile, however when I tried to process, it didn't create any pdf, so I decided to print_r($jasper) and I got the command that was being executed and I found a Java error, now do you have any idea of what can this be, I'm looking on my own, but if you have any idea... thanks...
screenshot 180

@jadsonbr
Copy link
Contributor

In calling the process function just after the connection parameter you entered
True, true, 'en-US' as in the example below.
Being that in the parameter of LOCALE you inform your language.

For more languages

$jasper->process(
        $input,
        $output,
        array("pdf"),
        array(),
        $this->conn, 
        true, 
        true, 
        'en-US' //LOCALE
)->execute();

@erick-chali
Copy link
Author

screenshot 182
Well I place the code as you placed it, but I'm still getting the same freetype error of java, is there any configuration of libraries that I need to setup..?

@jadsonbr
Copy link
Contributor

jadsonbr commented Nov 23, 2016

Did you run the command from the "C: \ Users \ Erick" folder the jasperstarter binary is there?

Shows the code you are making

@erick-chali
Copy link
Author

well, I set up the jasperstarter on the PATH variable pointing to the \bin directory, so I can run the command from there

@jadsonbr
Copy link
Contributor

Shows the code you are doing to generate the reports

@erick-chali
Copy link
Author

    $input = storage_path().'\templates\hello_world.jasper';
    $output = storage_path();

    $jasper = new JasperPHP;

    $jasper->process(
        $input,
        $output,
        array("pdf"),
        array(),
        array(),
        true,
        true,
        "en_US"
    )->output();
    echo "<pre>";
    print_r($jasper) ;
    echo "<pre>";

@jadsonbr
Copy link
Contributor

Are you using which version of Laravel?

@erick-chali
Copy link
Author

5.3

@jadsonbr
Copy link
Contributor

And what version of JDK?

@erick-chali
Copy link
Author

screenshot 189

@jadsonbr
Copy link
Contributor

javac -version

To install on windows visit the link-> JDK and look for the most appropriate version for your system.

@erick-chali
Copy link
Author

javac -version
javac 1.8.0_51

@jadsonbr
Copy link
Contributor

The path of Java Home is pointed to which directory?

@erick-chali
Copy link
Author

I added a variable JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_51"
then in the PATH I added = %JAVA_HOME%\bin

@jadsonbr
Copy link
Contributor

Uninstall Java and install again

Java SE Development Kit 8u111

@erick-chali
Copy link
Author

Well first of all thank you very much for the time taken to help with this issue, ass you suggest by performing the re-installation of JDK, now I was able to compile and generate, now
what driver should I use if I want to use SQL Server?
I was checking the documentation and if I want to use that database I should place driver as generic, so my code seems like this:

$jasper->process(
            $input,
            $output,
            array("pdf"),
            array(),
            [
                'driver' => 'generic',
                'host' => env('DB_HOST', 'localhost'),
                'port' => env('DB_PORT', '1433'),
                'database' => env('DB_DATABASE', 'forge'),
                'username' => env('DB_USERNAME', 'forge'),
                'password' => env('DB_PASSWORD', '')
            ]
        )->execute();

however this is generating an error, because the output command that is generated is:

``` jasperstarter process "C:\laragon\www\reportes\storage\report_templates\reporte.jasper" -o
 "C:\laragon\www\reportes\storage\report_templates" -f pdf -t generic -u sa -p SOLUCIONES -H
localhost -n NM_HN_INV_EMCO --db-port 1433```

even the official drivers from the Microsoft link are in the correct folder, this command will not generate the pdf, instead this command does generate the pdf using a sql server database connection:

     jasperstarter process "C:\laragon\www\reportes\storage\report_templates\reporte.jasper" -o
     "C:\laragon\www\reportes\storage\report_templates" -f pdf -t generic --db-url
     jdbc:sqlserver://localhost:1433 -n NM_HN_INV_EMCO -u sa -p SOLUCIONES --db-driver
     com.microsoft.sqlserver.jdbc.SQLServerDriver````

@jadsonbr
Copy link
Contributor

The --db-url parameter must be complete.
Example: jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;

@erick-chali
Copy link
Author

Is that setup automatically by this library? or do I need any additional set up steps?

@jadsonbr
Copy link
Contributor

I did not understand what you meant. Could you rephrase the question, please?

You need to add the corresponding JDBC library to the bank you want to connect to in the /vendor/geekcom/src/JasperStarter/jdbc/

And pass the parameters according to the documentation.

The more detailed documentation you find at this link below.
Documentation Params JasperStarter

@erick-chali
Copy link
Author

Sure, I will try to explain better,
In my case, I was trying to use SQLServer to generate my report, and my code to do it looks like this:

 $jasper->process(
        $input,
        $output,
        array("pdf"),
        array(),
        [
            'driver' => 'generic',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', '')
        ]
    )->execute();

however this is generating me the common error: "Your report has an error and couldn't be processed! Try to output the command using the function output(); and run it manually in the console."

so I output the error and I got this:

JasperPHP\JasperPHP Object
(
    [executable:protected] => jasperstarter
    [path_executable:protected] => C:\laragon\www\reportes\vendor\geekcom\phpjasper\src\JasperPHP/../JasperStarter/bin
    [the_command:protected] => jasperstarter process "C:\laragon\www\reportes\storage\report_templates\reporte.jasper" -o "C:\laragon\www\reportes\storage\report_templates" -f pdf -t generic -u sa -p SOLUCIONES -H localhost -n NM_HN_INV_EMCO --db-port 1433
    [redirect_output:protected] => 1
    [background:protected] => 1
    [windows:protected] => 1
    [formats:protected] => Array
        (
            [0] => pdf
            [1] => rtf
            [2] => xls
            [3] => xlsx
            [4] => docx
            [5] => odt
            [6] => ods
            [7] => pptx
            [8] => csv
            [9] => html
            [10] => xhtml
            [11] => xml
            [12] => jrprint
        )

    [resource_directory:protected] => C:\laragon\www\reportes\vendor\geekcom\phpjasper\src\JasperPHP/../../../vendor/geekcom/jasperphp/src/JasperStarter/bin
)

If I grab, the_command parameter and execute it manually in the console:
screenshot 191

so, what I understand is that if use driver "generic", since is the one I have to use because is SQLServer, the --db-url is not being generated in the command, does that means I cannot use SQLServer with your library? or is there any other setup needed when using "generic" driver?

@jadsonbr
Copy link
Contributor

jadsonbr commented Nov 28, 2016

To use SQLServer or any other database other than MySQL, PostgreSQL or Oracle, just have the corresponding library and put it in /vendor/geekcom/src/JasperStarter/jdbc/ and setting it up correctly will succeed.
In the last message I sent I sent you the documentation link and looking carefully you will see that to use datasource type generics some items are mandatory type the ones below.

--db-port <port> database port
--db-driver <name> jdbc driver class name for use with type: generic
--db-url <jdbcUrl> jdbc url without user, passwd with type: generic
- jdbc-dir <dir> directory where jdbc driver jars are located

Soon your command should look something like the one below.

 $jasper->process(
        $input,
        $output,
        array("pdf"),
        array(),
        [
            'driver' => 'generic',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
            'jdbc_url' => 'jdbc:sqlserver://'.env('DB_HOST', 'localhost').':'.env('DB_PORT', '1433').';databaseName='.env('DB_DATABASE', 'forge'),
            'jdbc_dir' => __DIR__ . '/vendor/geekcom/phpjasper/src/JasperStarter/jdbc/'

        ]
    )->execute();

@erick-chali
Copy link
Author

erick-chali commented Nov 29, 2016

Thank you!!
These lines were missing,

  'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
  'jdbc_url' => 'jdbc:sqlserver://'.env('DB_HOST', 'localhost').':'.env('DB_PORT', '1433').';databaseName='.env('DB_DATABASE', 'forge'),
  'jdbc_dir' => '/vendor/geekcom/src/JasperStarter/jdbc/'

Right now Is working well I guess thats it for now.

@geekcom
Copy link
Member

geekcom commented Dec 1, 2016

hey @erick-chali, can i close this issue?

@erick-chali
Copy link
Author

yea sure, thanks for the help... 💯

@ashrulkhair
Copy link

well I think I'm halfway to solve this, thanks for the fix before, now I was able to compile, however when I tried to process, it didn't create any pdf, so I decided to print_r($jasper) and I got the command that was being executed and I found a Java error, now do you have any idea of what can this be, I'm looking on my own, but if you have any idea... thanks...
screenshot 180

Well first of all thank you very much for the time taken to help with this issue, ass you suggest by performing the re-installation of JDK, now I was able to compile and generate, now
what driver should I use if I want to use SQL Server?
I was checking the documentation and if I want to use that database I should place driver as generic, so my code seems like this:

$jasper->process(
            $input,
            $output,
            array("pdf"),
            array(),
            [
                'driver' => 'generic',
                'host' => env('DB_HOST', 'localhost'),
                'port' => env('DB_PORT', '1433'),
                'database' => env('DB_DATABASE', 'forge'),
                'username' => env('DB_USERNAME', 'forge'),
                'password' => env('DB_PASSWORD', '')
            ]
        )->execute();

however this is generating an error, because the output command that is generated is:

``` jasperstarter process "C:\laragon\www\reportes\storage\report_templates\reporte.jasper" -o
 "C:\laragon\www\reportes\storage\report_templates" -f pdf -t generic -u sa -p SOLUCIONES -H
localhost -n NM_HN_INV_EMCO --db-port 1433```

even the official drivers from the Microsoft link are in the correct folder, this command will not generate the pdf, instead this command does generate the pdf using a sql server database connection:

     jasperstarter process "C:\laragon\www\reportes\storage\report_templates\reporte.jasper" -o
     "C:\laragon\www\reportes\storage\report_templates" -f pdf -t generic --db-url
     jdbc:sqlserver://localhost:1433 -n NM_HN_INV_EMCO -u sa -p SOLUCIONES --db-driver
     com.microsoft.sqlserver.jdbc.SQLServerDriver````

erick, i can compile but i cant to generate any format output. whats wrong with me, btw i m using php>7 and jdk 1.8.xx . please help me bro.

@ashrulkhair
Copy link

my error messages:

Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: Your report has an error and couldn 't be processed!\ Try to output the command using the function output(); and run it manually in the console. in C:\xampp\htdocs\jasper\vendor\geekcom\phpjasper\src\PHPJasper.php:219 Stack trace: #0 C:\xampp\htdocs\jasper\test.php(47): PHPJasper\PHPJasper->execute() #1 {main} thrown in C:\xampp\htdocs\jasper\vendor\geekcom\phpjasper\src\PHPJasper.php on line 219

@geekcom
Copy link
Member

geekcom commented Sep 25, 2019

Hi @ashrulkhair, thanks for your comments, please see full example below.

Using MSSQL DataBase

require __DIR__ . '/vendor/autoload.php';

use PHPJasper\PHPJasper;

$input = '/your_input_path/your_report.jasper or .jrxml';   
$output = '/your_output_path';
$jdbc_dir = __DIR__ . '/vendor/geekcom/phpjasper/bin/jaspertarter/jdbc';
$options = [
    'format' => ['pdf'],
    'locale' => 'en',
    'params' => [],
    'db_connection' => [
        'driver' => 'generic',
        'host' => '127.0.0.1',
        'port' => '1433',
        'database' => 'DataBaseName',
        'username' => 'UserName',
        'password' => 'password',
        'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
        'jdbc_url' => 'jdbc:sqlserver://127.0.0.1:1433;databaseName=Teste',
        'jdbc_dir' => $jdbc_dir
    ]
];

$jasper = new PHPJasper;

$jasper->process(
        $input,
        $output,
        $options
    )->execute();

@ashrulkhair
Copy link

ashrulkhair commented Sep 26, 2019 via email

@aldo-oliveira
Copy link

aldo-oliveira commented May 6, 2024

Error using MSSQL DataBase

Hello friends!

I'm with this problem when execute the statement.

Error filling reportError executing SQL statement for:

select [dbo].[users].[name], [dbo].[users].[email] from [dbo].[users] where [dbo].[users].[id] < 10

But the same code jrxml works in jasperstudio.

@aldo-oliveira
Copy link

We'd fixed with change by api integrations, tks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants