Skip to content

Report only compiles on Console #211

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

Open
Siwakhile opened this issue Mar 9, 2020 · 9 comments
Open

Report only compiles on Console #211

Siwakhile opened this issue Mar 9, 2020 · 9 comments

Comments

@Siwakhile
Copy link

Im only able to compile on linux shell,

on browser/apache I get

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 /var/www/html/Siphile/admin/vendor/geekcom/phpjasper/src/PHPJasper.php:236 Stack trace: #0 /var/www/html/Siphile/admin/reporttest.php(9): PHPJasper\PHPJasper->execute() #1 {main} thrown in /var/www/html/Siphile/admin/vendor/geekcom/phpjasper/src/PHPJasper.php on line 23

@geekcom
Copy link
Member

geekcom commented Mar 13, 2020

Hi @Siwakhile please try to output the command using the function output(); and run it manually in the console.

@josevillasmil
Copy link

josevillasmil commented Mar 22, 2020

Usually this happens because the jasperstarter in linux needs execution setup.
Do this sudo chmod +777 jasperstarter and sudo chmod +x jasperstarter

@drjoju
Copy link

drjoju commented Apr 17, 2020

Hello,

I have the same problem. I see what's happening.

My console output its like:

./jasperstarter process "/var/www/html/....

If I execute in the command line I need to remove the innitial dot slash to execute the commnad.

Debugging the code at line 87 in PHPJasper file of the package I see this function:

private function checkServer()
{
        return $this->command = $this->windows ? $this->executable : './' . $this->executable;
}

If I remove './' . the next code works well

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

Why the dot slash is necessary or not? Depends on the linux flavor?

@josevillasmil
Copy link

Why the dot slash is necessary or not? Depends on the linux flavor?
On linux it´s mandatory ./ (dot slash) to execute de jasperstarter command. On windows japerstarter.exe ...... to execute

@drjoju
Copy link

drjoju commented Apr 18, 2020

Hi, but I'm on a Linux Docker and it's not working with the dot-slash. Any ideas why?

@josevillasmil
Copy link

josevillasmil commented Apr 18, 2020 via email

@drjoju
Copy link

drjoju commented Apr 19, 2020

Hi, I found the problem and a solution.

I make an in depth debugging and catch the stderror and I get this error

Exception in thread "main" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap') at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:75) at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:65) at de.cenote.tools.classpath.ApplicationClasspath.addJars(ApplicationClasspath.java:134) at de.cenote.tools.classpath.ApplicationClasspath.addJarsRelative(ApplicationClasspath.java:151) at de.cenote.jasperstarter.App.processReport(App.java:178) at de.cenote.jasperstarter.App.main(App.java:109)

I found that this is an error reported before in
#152

I have installed openjdk 11. Following the suggestions from some users I change java to version 1.8 following this steps.

I download the jdk following the instructions in this link

https://lv.binarybabel.org/catalog/java/jdk8

I execute in my home root

wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' '
http://download.oracle.com/otn-pub/java/jdk/8u251-b08/3d5a2bb8f8d4428bbe94aed7ec7ae784/jdk-8u251-linux-x64.tar.gz'

Or download from
https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

After download execute this commands adapting these commands to your server or installation:

mkdir -p /usr/java

mv jdk-8u251-linux-x64.tar.gz /usr/java

cd /usr/java

tar zxvf  jdk-8u251-linux-x64.tar.gz

rm jdk-8u251-linux-x64.tar.gz

cd /usr/java/jdk1.8.0_251/bin

 ./java -version

After that the java version installed in this directory must be:

java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)

Now configure this new Java package as the default one following the instructions on this link

https://www.javahelps.com/2015/03/install-oracle-jdk-in-ubuntu.html

So I add to the /etc/environment

nano /etc/environment

this lines

PATH=$PATH:/usr/java/jdk1.8.0_251/bin:/usr/java/jdk1.8.0_251/db/bin:/usr/java/jdk1.8.0_251/jre/bin
J2SDKDIR="/usr/java/jdk1.8.0_251/bin"
J2REDIR="/usr/java/jdk1.8.0_251/db/bin"
JAVA_HOME="/usr/java/jdk1.8.0_251/jre/bin"

and configure the new installed java jdk executing this commands

 update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.8.0_251/bin/java" 0

 update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk1.8.0_251/bin/javac" 0

 update-alternatives --set java /usr/java/jdk1.8.0_251/bin/java

 update-alternatives --set javac /usr/java/jdk1.8.0_251/bin/javac

After this you can see the new configured java jdk executing:

update-alternatives --list java

update-alternatives --list javac

After that, all is working well.

Best regards

@josevillasmil
Copy link

josevillasmil commented Apr 19, 2020 via email

@madhumda
Copy link

Hello,

I need to migrate our legacy application from java8 to java17. While running the application, I encountered the following exception with OpenJDK 17. This worked fine with Java 8, but the new class loader mechanism under the module system is causing issues. What should be the solution for this?
java -version
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)

Exception in thread "main" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
at sentinel.command.SentinelBoot.addToClassPath(SentinelBoot.java:194)
at sentinel.command.SentinelBoot.initClassPath(SentinelBoot.java:63)
at sentinel.command.SentinelStarter.initStarter(SentinelStarter.java:54)
at sentinel.command.TrkServer.main(TrkServer.java:48)

Sharing few code snippets for reference:
URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
Class sysclass = URLClassLoader.class;
Method method = sysclass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(sysloader, new Object[]{u});

I am stuck for so many days, nowhere getting any solutions. Please guide me. Thanks in advance!

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