Skip to content
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

When running the build for the TotalCross bytecode, we get exception if running on a headless mode #27

Closed
otavio opened this issue May 14, 2020 · 5 comments · Fixed by #45
Labels
bug Something isn't working help wanted Extra attention is needed Linux ARM Issue related to the platform Linux ARM

Comments

@otavio
Copy link
Member

otavio commented May 14, 2020

The below exceptions is raised:

openjdk version "1.8.0_252-internal"
OpenJDK Runtime Environment (build 1.8.0_252-internal-ga)
OpenJDK 64-Bit Server VM (build 25.252-bga, mixed mode)
docker [build]$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)| Adding totalcross/res/spinner_iphone.gifException in thread "main" java.awt.AWTError: Toolkit not found: sun.awt.X11.XToolkit
|       at java.awt.Toolkit$2.run(Toolkit.java:867)
|       at java.awt.Toolkit$2.run(Toolkit.java:855)
|       at java.security.AccessController.doPrivileged(Native Method)
|       at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)
|       at java.awt.Component.getToolkitImpl(Component.java:1226)
|       at java.awt.Component.getToolkit(Component.java:1214)
|       at java.awt.Component.checkImage(Component.java:3749)
|       at java.awt.ImageMediaEntry.getStatus(MediaTracker.java:951)
|       at java.awt.MediaTracker.statusAll(MediaTracker.java:480)
|       at java.awt.MediaTracker.waitForAll(MediaTracker.java:431)
|       at java.awt.MediaTracker.waitForAll(MediaTracker.java:401)
|       at totalcross.ui.image.Image$ImageLoader.<init>(Image.java:1802)
|       at totalcross.ui.image.Image.imageLoad(Image.java:1760)
|       at totalcross.ui.image.Image.imageParse(Image.java:1468)
|       at totalcross.ui.image.Image.<init>(Image.java:314)
|       at totalcross.ui.image.Image.<init>(Image.java:283)
|       at tc.tools.converter.J2TC.processFiles(J2TC.java:959)
|       at tc.tools.converter.J2TC.process(J2TC.java:1323)
|       at tc.Deploy.<init>(Deploy.java:85)
|       at tc.Deploy.main(Deploy.java:44)
| :deployTcui FAILED

It seems to come from:

https://github.com/TotalCross/totalcross/blob/develop/TotalCrossSDK/src/main/java/totalcross/ui/Spinner.java#L75

However, it seems that it is trying to load a spinner image even on headless mode.

Is it possible to be avoided?

@ItaloYeltsin
Copy link
Contributor

ItaloYeltsin commented May 14, 2020

It seems you are using a version of Java OpenJDK8-headless that does not comes with the sun.* package required for convert all required images inside the project to png. In order to solve this we need to find another way to convert these images without using sun.* packages

@ItaloYeltsin ItaloYeltsin added the help wanted Extra attention is needed label May 14, 2020
@otavio
Copy link
Member Author

otavio commented May 14, 2020

@ItaloYeltsin if it is just a matter to convert them to PNG, this could be easily done.

@ItaloYeltsin
Copy link
Contributor

Yeap, I've just edited my answer!

@otavio
Copy link
Member Author

otavio commented May 14, 2020

A very easy way to reproduce this error is using openjdk-8-jdk-headless as the runtime for the build process.

@ItaloYeltsin ItaloYeltsin added the bug Something isn't working label May 14, 2020
@ItaloYeltsin
Copy link
Contributor

ItaloYeltsin commented May 15, 2020

this is a little bit more complicated than we thought. Actually, the the reason why we make this conversion is to make an abstraction of gif inside a png. So, what happen is that we get all frames from gif file and put it them side by side in a .png file, so its possible to play the animation on runtime. We really need to keep this process.

On the other hand, we could add a library to do this instead of using the sun libraries.

@ItaloYeltsin ItaloYeltsin added java Linux ARM Issue related to the platform Linux ARM labels May 20, 2020
@flsobral flsobral linked a pull request Jun 18, 2020 that will close this issue
flsobral added a commit that referenced this issue Jun 18, 2020
…ava headless.

Deploy uses TotalCross' Image class to convert unsupported image formats to PNG, and this process relied on classes from java.awt and Toolkit, which may not be available on headless distros.
Changed implementation of ImageLoader to perform this conversion using ImageIO instead, with some refactoring along the way for clarity. the problem with deploying totalcross java components from api to tcz when using Java Headless.

Fixes #27
flsobral added a commit that referenced this issue Jun 18, 2020
Deploy uses TotalCross' Image class to convert unsupported image
formats to PNG, and this process relied on classes from java.awt
and Toolkit, which may not be available on headless distros.

Changed implementation of ImageLoader to perform this conversion
using ImageIO instead, with some refactoring along the way for
clarity.

Fixes #27
flsobral added a commit that referenced this issue Jun 19, 2020
…#45)

Deploy uses TotalCross' Image class to convert unsupported image
formats to PNG, and this process relied on classes from java.awt
and Toolkit, which may not be available on headless distros.

Changed implementation of ImageLoader to perform this conversion
using ImageIO instead, with some refactoring along the way for
clarity.

Fixes #27

Co-authored-by: Fabio <flsobral@gmail.com>
flsobral added a commit that referenced this issue Jul 16, 2020
…#45)

Deploy uses TotalCross' Image class to convert unsupported image
formats to PNG, and this process relied on classes from java.awt
and Toolkit, which may not be available on headless distros.

Changed implementation of ImageLoader to perform this conversion
using ImageIO instead, with some refactoring along the way for
clarity.

Fixes #27

Co-authored-by: Fabio <flsobral@gmail.com>
flsobral added a commit that referenced this issue Jul 24, 2020
…#45)

Deploy uses TotalCross' Image class to convert unsupported image
formats to PNG, and this process relied on classes from java.awt
and Toolkit, which may not be available on headless distros.

Changed implementation of ImageLoader to perform this conversion
using ImageIO instead, with some refactoring along the way for
clarity.

Fixes #27

Co-authored-by: Fabio <flsobral@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed Linux ARM Issue related to the platform Linux ARM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants