0

I started trying out Apache Pivot as I want to create java GUI's with XML.

I followed their Hello BXML tutorial using a maven project on their web site.

These are the files that I'm using:

HelloBXML.java

package za.co.iriesoft;

import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Window;

public class HelloBXML implements Application {
    private Window window = null;

    public void startup(Display display, Map<String, String> properties) throws Exception {
        BXMLSerializer bxmlSerializer = new BXMLSerializer();
        window = (Window) bxmlSerializer.readObject(HelloBXML.class, "hello.bxml");
        window.open(display);
    }

    public boolean shutdown(boolean optional) {
        if (window != null) {
            window.close();
        }

        return false;
    }

    public void suspend() {
    }

    public void resume() {
    }
}

hello.bxml

<?xml version="1.0" encoding="UTF-8"?>
<Window title="Hello BXML!" maximized="true"
    xmlns:bxml="http://pivot.apache.org/bxml"
    xmlns="org.apache.pivot.wtk">
    <Label text="Hello BXML!"
        styles="{font:'Arial bold 24', color:'#ff0000',
            horizontalAlignment:'center', verticalAlignment:'center'}"/>
</Window>

App.java

package za.co.iriesoft;

import org.apache.pivot.wtk.DesktopApplicationContext;

public class App {

    public static void main(String[] args) {

        DesktopApplicationContext.main(HelloBXML.class, args);

    }
}

When I run the application I get an exception:

Exception: An error occurred at line number 4 in file /C:/Apps/java/java-ws-client/target/classes/za/co/iriesoft/hello.bxml:
org.apache.pivot.serialization.SerializationException: An error occurred at line number 4 in file /C:/Apps/java/java-ws-client/target/classes/za/co/iriesoft/hello.bxml:
    at org.apache.pivot.beans.BXMLSerializer.logException(BXMLSerializer.java:1516)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:514)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:684)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:639)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:600)
    at za.co.iriesoft.HelloBXML.startup(HelloBXML.java:14)
    at org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:666)
    at org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1690)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    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)
Caused by: org.apache.pivot.serialization.SerializationException: java.lang.ExceptionInInitializerError
    at org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:829)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:493)
    ... 20 more
Caused by: java.lang.ExceptionInInitializerError
    at org.apache.pivot.wtk.Component.installSkin(Component.java:807)
    at org.apache.pivot.wtk.Window.<init>(Window.java:472)
    at org.apache.pivot.wtk.Window.<init>(Window.java:467)
    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 org.apache.pivot.beans.BXMLSerializer.newTypedObject(BXMLSerializer.java:1697)
    at org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:827)
    ... 21 more
Caused by: org.apache.pivot.wtk.ThemeNotFoundException: A theme could not be located.
    at org.apache.pivot.wtk.Theme.<clinit>(Theme.java:77)
    ... 31 more
org.apache.pivot.serialization.SerializationException: java.lang.ExceptionInInitializerError
    at org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:829)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:493)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:684)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:639)
    at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:600)
    at za.co.iriesoft.HelloBXML.startup(HelloBXML.java:14)
    at org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:666)
    at org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1690)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    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)
Caused by: java.lang.ExceptionInInitializerError
    at org.apache.pivot.wtk.Component.installSkin(Component.java:807)
    at org.apache.pivot.wtk.Window.<init>(Window.java:472)
    at org.apache.pivot.wtk.Window.<init>(Window.java:467)
    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 org.apache.pivot.beans.BXMLSerializer.newTypedObject(BXMLSerializer.java:1697)
    at org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:827)
    ... 21 more
Caused by: org.apache.pivot.wtk.ThemeNotFoundException: A theme could not be located.
    at org.apache.pivot.wtk.Theme.<clinit>(Theme.java:77)
    ... 31 more
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class org.apache.pivot.wtk.Theme
    at org.apache.pivot.wtk.Component.installSkin(Component.java:807)
    at org.apache.pivot.wtk.TextArea.<init>(TextArea.java:603)
    at org.apache.pivot.wtk.ApplicationContext.defaultUncaughtExceptionHandler(ApplicationContext.java:2134)
    at org.apache.pivot.wtk.ApplicationContext.handleUncaughtException(ApplicationContext.java:2155)
    at org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:669)
    at org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1690)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    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)

Does any one know what could be the problem? I been struggling the whole day trying different IDE's and searching Google and their bug database for an answer, but to no avail.

I am running on Windows 10, Java SDK 1.8.0_152

tno2007
  • 1,993
  • 25
  • 16
  • I just want to add, in addition to @rwhitcomb answer below. The way I went wrong was to copy and paste the first Pivot maven dependency ` org.apache.pivot pivot 2.0.5 pom ` So just changed the artifactId's for the others (pivot-charts, pivot-core, pivot-wtk-terra). With this I left the *pom* attribute on all of them, and this caused maven not to read/include these additional dependencies. So for the other dependencies, do leave out the 'type' attributes. – tno2007 Mar 29 '18 at 09:14

1 Answers1

2

I'm guessing you don't have the "pivot-wtk-terra...jar" file in your classpath. The underlying error seems to be "A theme could not be located." That theme is this "...terra...jar" file.

rwhitcomb
  • 106
  • 2
  • The other thing I should point out is that the code in "main" in your "App" class can (and should) be moved into the "HelloBXML" class. If you look into the other examples this is the way Pivot applications normally work. – rwhitcomb Mar 20 '18 at 16:06