mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

Deserialization problems, Windows decoration with XML styling #628

Closed UltraBurstXD closed 4 years ago

UltraBurstXD commented 4 years ago

Hello Mgarin,

I'm having some problems (crashes) when my program tries those deserialization methods mentioned in the wiki-website for windows decoration.: https://github.com/mgarin/weblaf/wiki/Window-decoration.

But I'm not having success so far. And below behold the report:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.alee.utils.ReflectUtils (file:/home/mysteryxy/My%20Apps/WebLaf%20(Look%20and%20Feel)/weblaf-core-1.2.12.jar) to method sun.awt.UNIXToolkit.isNativeGTKAvailable()
WARNING: Please consider reporting this to the maintainers of com.alee.utils.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
**Security framework of XStream not initialized, XStream is probably vulnerable.**
Exception in thread "AWT-EventQueue-0" com.thoughtworks.xstream.io.StreamException: 
    at com.thoughtworks.xstream.io.xml.StaxDriver.createReader(StaxDriver.java:102)
    at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:437)
    at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:399)
    at com.alee.managers.style.XmlSkinExtension.getMetaData(XmlSkinExtension.java:124)
    at com.alee.managers.style.XmlSkinExtension.<init>(XmlSkinExtension.java:64)
    at web.SimpleDecoration$1.run(SimpleDecoration.java:43)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: javax.xml.stream.XMLStreamException: java.net.MalformedURLException
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.java:240)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.<init>(XMLStreamReaderImpl.java:210)
    at java.xml/com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:277)
    at java.xml/com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:129)
    at com.thoughtworks.xstream.io.xml.StaxDriver.createParser(StaxDriver.java:230)
    at com.thoughtworks.xstream.io.xml.StaxDriver.createReader(StaxDriver.java:100)
    ... 18 more
Caused by: java.net.MalformedURLException
    at java.base/java.net.URL.<init>(URL.java:706)
    at java.base/java.net.URL.<init>(URL.java:568)
    at java.base/java.net.URL.<init>(URL.java:515)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:649)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1398)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:1349)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:256)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.java:225)
    ... 23 more
Caused by: java.lang.NullPointerException
    at java.base/java.net.URL.<init>(URL.java:612)
    ... 30 more

The first 5 lines warning, always appear when I initialize the l&f, but it doesn't matter. The bold line shows that XStream wasn't initialized, but i've already given it all permissions and initialized it.

P.S.: By the way, I've already added required jars to my project classpath

Screenshot from 2020-05-19 19-29-10

The code is the same as in the website and I've added the XML file inside my project location (folder).

mgarin commented 4 years ago

According to the error - your extension is missing the XML resource. It either did not make it into your JAR file, placed in the wrong package or cannot be read for some other reason.

UltraBurstXD commented 4 years ago

I've made sure to place the XML in my project folder and used the following code to read it: StyleManager.addExtensions ( new XmlSkinExtension ( new ClassResource ( SimpleDecoration.class, "SimpleExtension.xml") ) ); My project has only one package, and I'm using Ant build.

mgarin commented 4 years ago

With that definition:

new ClassResource ( SimpleDecoration.class, "SimpleExtension.xml" )

Your SimpleExtension.xml needs to be in the same package as SimpleDecoration class, not just anywhere in the project - resource finding is always strict. You also need to make sure that it actually made it into JAR as well and also located near that class there, if you're getting the error when running your app from the JAR.

UltraBurstXD commented 4 years ago

Got it right! It's working! Thanks.

Screenshot from 2020-05-20 11-04-41