jFreechart not display in linux machine - java

Jsp
<img alt="" src='<%=url+"/chartDemo/servlet/ChartDemoServlet"%>'>
I have upper code inside jsp to use jfreechart. I have deployed this application inside tomcat of window machine and its work perfect. But When i copy same file inside tomcat of my linux machine all other content of jsp except chart are displayed.
Why chart are not displayed When i run web application using linux tomcat ?
When i enter servlet directly as URL i found following exception
java.lang.Error: Probable fatal error:No fonts found.
sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088)
sun.font.FontManager.initialiseDeferredFont(FontManager.java:967)
sun.font.CompositeFont.doDeferredInitialisation(CompositeFont.java:254)
sun.font.CompositeFont.getSlotFont(CompositeFont.java:334)
sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:77)
sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:358)
sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:349)
sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:301)
sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:790)
org.jfree.text.G2TextMeasurer.getStringWidth(G2TextMeasurer.java:79)
org.jfree.text.TextUtilities.nextLineBreak(TextUtilities.java:294)
org.jfree.text.TextUtilities.createTextBlock(TextUtilities.java:235)
org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:628)
org.jfree.chart.title.TextTitle.arrange(TextTitle.java:497)
org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1316)
org.jfree.chart.JFreeChart.draw(JFreeChart.java:1204)
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1404)
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1384)
org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:183)
org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:136)
com.ChartDemoServlet.doPost(ChartDemoServlet.java:170)
com.ChartDemoServlet.doGet(ChartDemoServlet.java:64)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Yes, #Tom is right; look for the used font(s). Earlier on, a Linux without desktop would also have no fonts available (so called headless environment), testable by GraphicsEnvironment.isHeadless() and System.getProperty("java.awt.headless");. You probably simply can copy the fonts and do a registerFont though.

Related

Netbeans default browser doesn't start in Netbeans?

Scenario:
OS: Linux Debian 11
Kernel: 5.1.21
Browser: Mozilla Firefox 102.8.0esr
IDE: Netbeans 16
JDK: JAVA SE 19
Tomcat 10 (configured in netbeans)
In this scenario servlets run fine on tomcat writing URL on address bar. Trying to open the same URL with Browser in Netbeans fails because Browser doesn't come-up.
I perform following steps:
Single click on left button upon tomcat icon, then a Drop list come down with my Servlets
Right click Button on a Servlet (or tomcat main page), a second drop-list come down
Selecting "open in a Browser"
Browser doesn't start
Message info come-uo "Browser cannot Run): This message appears below in IDE netbeans and after few second vanished
I have also tried to compile index.html and as usual browser is expected to run, but in my case no! compiling process return no message error.
Looking for IDE Browser Configuration (TOOL>OPTION>GENERAL>EDIT) give me this set-up:
External Browser
Others browsers showed in the image above doesn't work. More-over next image shows IDE DEFAULT BROWSER without configuration. I tried to edit blank field but data were not saved after OK button click:
IDE DEFAULT BROWSER
I tried to edit blank field but data were not saved after OK button click. I have to admit that this last trouble is my fault because I blanked them and now re-edit it again is impossible.

Java webapp produces StackOverflow exception on Linux

I have a Java-web application running on Tomcat 9. It works fine on a Windowns machine. But after deploying this app on a Debian Linux server I've encountered java.lang.StackOverflow exceptions on some particular pages. Here is the beginning of the stacktrace log:
27-Dec-2017 08:54:43.746 SEVERE [https-jsse-nio-9443-exec-3]
org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for
servlet [jsp] threw exception
java.lang.StackOverflowError
at java.io.UnixFileSystem.canonicalize0(Native Method)
at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:172)
at java.io.File.getCanonicalPath(File.java:618)
at org.apache.catalina.webresources.AbstractFileResourceSet.file(AbstractFileResourceSet.java:90)
Please, see full stacktrace here:
https://pastebin.com/0AmFDY8F
As far as I understand, the exception occurs while compiling the JSP page source by Jasper and it's somehow related to the resolving of Linux paths / directories. Could anybody please help me to figure out what the exact problem is? I didn't create any symbolic links, if the problem can be related to this.
According to your stack trace, the problem is caused by not being able to find a specific path as resolved by your Spring framework:
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
...
Caused by: java.io.IOException: JSPException including path '/struct/context/tutorials.jsp'.
The Spring framework is likely using the canonical paths to resolve the file, and it fails perhaps because there is some quirk in the framework related to the type of Unix system you are deploying to.
Please reference this in the Spring documentation:
https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html#deployment-install-supported-operating-systems
The default script supports most Linux distributions and is tested on CentOS and Ubuntu. Other platforms, such as OS X and FreeBSD, will require the use of a custom embeddedLaunchScript.
Notice that Debian was not listed. Hopefully this puts you on the right path.
If I'm chasing a red herring here, I'm sorry - but you haven't given us much to go on.
Finally I've found what caused the StackOverflow exception. I have a recursive JSP tag call to render nested options for a <select> tag. After removing the recursion, the exception disappeared. Sure, it's just a workaround, so I'm still wondering why it works fine on Windows and doesn't on Linux.

No more handles [Could not detect registered XULRunner to use]

I am using SWT 3.7 to create an RCP application. Windows is my OS and IE is set as the default SWT browser. I want to change the default browser from IE to Mozilla. I've read a few articles and learned that by adding arguments to the eclipse.ini file (-Dorg.eclipse.swt.browser.DefaultType=mozilla) one can set the default SWT browser.
But after adding it to vm arguments (because when adding to the .ini file it is not doing anything), I get the error below:
org.eclipse.swt.SWTError: No more handles [Could not detect registered XULRunner to use]
at org.eclipse.swt.SWT.error(SWT.java:4308)
at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:683)
at org.eclipse.swt.browser.Browser.<init>(Browser.java:99)
The code is breaking on line:
Browser browser = new Browser(parent, SWT.None);
I have already downloaded xulrunner, ran the register command, checked in registry (it's there), added -Dorg.eclipse.swt.browser.XULRunnerPath="C://Program Files (x86)//Mozilla XULRunner//1.9.1//xulrunner" to vmargs but I still get the same error.
Can anyone help me on this issue?
Found this in the eclipse forum:
"Found the problem. I needed to do xulrunner --register-global as administrator. Since there is no difference in the xulrunner output, the only way to tell if the registration occurred is to look in HKLM\SOFTWARE\Wow6432Node\mozilla.org\GRE"
http://www.eclipse.org/forums/index.php/mv/msg/199032/#msg_634819

Run java applet offline: Exception in thread "main" java.lang.NoClassDefFoundError

I just downloaded some java applets from this site: http://www.surendranath.org/Apps.html to run them offline on my laptop. Take for example this one: http://www.surendranath.org/Applets/Oscillations/Lissajous/Lissajous.html
By inspecting the source code I downloaded the file: wget http://www.surendranath.org/Applets/Oscillations/Lissajous/LissajousApplet.class
Then I tried it to run it on my ubuntu box via gappletviewer-4.8 -code LissayousApplet.class
However I got the following error message:
Exception in thfully qualifiedread "main" java.lang.NoClassDefFoundError: loaded class LissajousApplet was in fact named Applets.Oscillations.Lissajous.LissajousApplet
at java.lang.VMClassLoader.defineClass(libgcj.so.14)
at java.lang.ClassLoader.defineClass(libgcj.so.14)
at java.security.SecureClassLoader.defineClass(libgcj.so.14)
at java.net.URLClassLoader.findClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at gnu.classpath.tools.appletviewer.Main.createApplet(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.StandaloneAppletWindow.<init>(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.StandaloneAppletViewer.createWindows(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.StandaloneAppletViewer.<init>(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.Main.main(libgcj-tools.so.14)
So what is the correct way to run this applet offline? Running it online within my browser and the icetea plugin works. However I need a way to run it offline.
Edit
Trying the fully qualified class-name results in:
gappletviewer-4.8 -code Applets.Oscillations.Lissajous.LissajousApplet.class -codebase codebase="../../../"
WARNING: CURRENTLY GAPPLETVIEWER RUNS WITH NOSECURITY MANAGER.
THIS MEANS THAT APPLETS YOU LOAD CAN DO ANYTHING A JAVA APPLICATION
THAT YOU DOWNLOAD AND RUN CAN DO. BE *VERY* CAREFUL WHICH APPLETS YOU RUN.
DO NOT USE GAPPLETVIEWER ON YOUR SYSTEM IF YOUR SYSTEM STORES IMPORTANTDATA.
THIS DATA CAN BE DESTROYED OR STOLEN IF YOU LOAD A MALICIOUS APPLET.
[press 'c' or 'C' to continue or anything else to quit]
c
java.lang.ClassNotFoundException: Applets.Oscillations.Lissajous.LissajousApplet not found in gnu.classpath.tools.appletviewer.AppletClassLoader{urls=[file:/home/null,file:/home/], parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}
at java.net.URLClassLoader.findClass(libgcj.so.14)
at gnu.classpath.tools.appletviewer.AppletClassLoader.findClass(libgcj-tools.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at java.lang.ClassLoader.loadClass(libgcj.so.14)
at gnu.classpath.tools.appletviewer.Main.createApplet(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.StandaloneAppletWindow.<init>(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.StandaloneAppletViewer.createWindows(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.StandaloneAppletViewer.<init>(libgcj-tools.so.14)
at gnu.classpath.tools.appletviewer.Main.main(libgcj-tools.so.14)
Try using the fully qualified classname
gappletviewer-4.8 -code Applets.Oscillations.Lissajous.LissajousApplet.class -codebase codebase="http://www.surendranath.org/"
Read: gappletviewer Man page

Java - Applet Exception

I have a Java project that contains 1 JApplet.
I'm able to run the Applet in desk-top mode (adding the applet to a frame in main[] method).
It doesn't work in a browser though. Getting this error:
I already signed all the jars.
I believe its related to mysql connector jar.
Any ideas?
Exception occurred: java.lang.ExceptionInInitializerError (uncaught)"thread=AWT-
EventQueue-1", java.awt.EventDispatchThread.run(), line=156 bci=152
It runs fine if I add grant all to java.policy
You should ensure:
That your applet is signed to allow for database connections.
That your mysql connector jar is available on your 'download' path just like your applet jar file.
Running the application from a webserver solved the issue.

Categories