O pacote Snap para o aplicativo Java (Swing e AWT) falha quando é executado

7

Estou tentando criar um pacote de snap para um aplicativo Java (Swing e AWT). Permite baixar (e gerenciar) papéis de parede automaticamente da Internet e os armazena localmente. Este é o arquivo snapcraft.yaml :

name: wallpaperdownloader
version: 2.0
summary: Download and manage your favorite wallpapers fron the Internet
description:
  Wallpaperdownloader is a simple java based application for downloading wallpapers from the Internet
confinement: strict
apps:
  wallpaperdownloader:
    command: java -jar $SNAP/jar/wallpaperdownloader.jar
    plugs: [x11, network-bind]
parts:
  wallpaperdownloader:
    plugin: maven
    source: https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader.git
    source-type: git

Eu criei sem nenhum problema (usando o plugin Maven) e o pacote snap foi criado. Então, eu o instalo usando o sinalizador - devmode para contornar o confinamento (apenas para fins de teste), mas não funciona. Ele cria uma pasta .wallpaperdownloader dentro de / home / user com todas as coisas e configurações necessárias para executar, mas falha antes que qualquer GUI apareça. Esta é a exceção lançada:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
    at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
    at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
    at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
    at sun.font.SunFontManager.run(SunFontManager.java:431)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.SunFontManager.<init>(SunFontManager.java:376)
    at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
    at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at sun.font.FontManagerFactory.run(FontManagerFactory.java:83)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
    at sun.font.SunFontManager.getInstance(SunFontManager.java:250)
    at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:264)
    at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1113)
    at javax.swing.JComponent.getFontMetrics(JComponent.java:1626)
    at javax.swing.text.PlainView.calculateLongestLine(PlainView.java:639)
    at javax.swing.text.PlainView.updateMetrics(PlainView.java:209)
    at javax.swing.text.PlainView.updateDamage(PlainView.java:527)
    at javax.swing.text.PlainView.insertUpdate(PlainView.java:451)
    at javax.swing.text.FieldView.insertUpdate(FieldView.java:293)
    at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:1610)
    at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.java:1869)
    at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:201)
    at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:748)
    at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
    at javax.swing.text.PlainDocument.insertString(PlainDocument.java:130)
    at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:669)
    at javax.swing.text.JTextComponent.setText(JTextComponent.java:1669)
    at javax.swing.JFormattedTextField$AbstractFormatter.install(JFormattedTextField.java:948)
    at javax.swing.text.DefaultFormatter.install(DefaultFormatter.java:125)
    at javax.swing.text.InternationalFormatter.install(InternationalFormatter.java:285)
    at javax.swing.JFormattedTextField.setFormatter(JFormattedTextField.java:464)
    at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:788)
    at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:501)
    at es.estoes.wallpaperDownloader.window.WallpaperDownloader.initializeGUI(WallpaperDownloader.java:814)
    at es.estoes.wallpaperDownloader.window.WallpaperDownloader.initialize(WallpaperDownloader.java:426)
    at es.estoes.wallpaperDownloader.window.WallpaperDownloader.<init>(WallpaperDownloader.java:160)
    at es.estoes.wallpaperDownloader.window.WallpaperDownloader.run(WallpaperDownloader.java:149)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access0(EventQueue.java:97)
    at java.awt.EventQueue.run(EventQueue.java:709)
    at java.awt.EventQueue.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Muito obrigado pela sua ajuda.

    
por Eloy García Almadén 27.06.2016 / 09:43

1 resposta

6

Substituir comando:

java -jar $SNAP/jar/wallpaperdownloader.jar

com run.sh .

Aqui está o run.sh :

#!/bin/sh
# Not good, needed for fontconfig
export XDG_DATA_HOME=$SNAP/usr/share
# Font Config
export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
export HOME=$SNAP_USER_DATA
java -jar -Duser.home=$SNAP_USER_DATA $SNAP/jar/wallpaperdownloader.jar

"-Duser.home=$SNAP_USER_DATA" resolveu meu problema.

Atualização: Veja um exemplo completo no Playpen Snappy usando um lançador personalizado para start-up.

    
por Василий Алексеенко 27.06.2016 / 11:32

Tags