@AndreNF escreveu:
Tenho o seguinte código, que estou trabalhando no NETBEANS, aparentemente não está nada errado, porém não roda. O erro, depurando, está na linha do XStream:
@Override public void start(Stage stage) throws Exception { // Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml")); // // Scene scene = new Scene(root); // // stage.setScene(scene); // stage.show(); gravaEndereco(); // gravaListaEndereco(); // gravaListaCompleta(); // // lerXML(); }
private static void gravaEndereco() {
Endereco endereco = new Endereco(); endereco.setCidade("Primavera do Leste"); endereco.setRua("Rua das araras"); **XStream xStream = new XStream();** xStream.alias("endereco", Endereco.class); File arquivo = new File("endereco.xml"); FileOutputStream gravar; try { gravar = new FileOutputStream(arquivo); gravar.write(xStream.toXML(endereco).getBytes()); gravar.close(); } catch (IOException ex) { //ex.printStackTrace(); } }
Eu tenho a classe, o e também os arquivos xstream-1.4.9.redhat-2.jar e dom4j-1.6.1.jar. Aparece o seguinte erro, que para mim é ilegível:
ant -f C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3 jfxsa-run
init:
Deleting: C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\build\built-jar.properties
Compiling 1 source file to C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\build\classes
Note: C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\src\javafxapplication3\JavaFXApplication3.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
compile:
Deleting directory C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\dist\lib
Copying 2 files to C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\dist\lib
Detected JavaFX Ant API version 1.3
Launching task from C:\Program Files\Java\jdk1.8.0_111\jre..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching task from C:\Program Files\Java\jdk1.8.0_111\jre..\lib\ant-javafx.jar
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
jfx-deployment-script:
jfx-deployment:
jar:
Copying 14 files to C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\dist\run221792884
jfx-project-run:
Executing C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\dist\run221792884\JavaFXApplication3.jar using platform C:\Program Files\Java\jdk1.8.0_111\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at com.thoughtworks.xstream.XStream.(XStream.java:350)
at javafxapplication3.JavaFXApplication3.gravaEndereco(JavaFXApplication3.java:63)
at javafxapplication3.JavaFXApplication3.start(JavaFXApplication3.java:41)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
Exception running application javafxapplication3.JavaFXApplication3
Java Result: 1
Deleting directory C:\Users\André\Documents\NetBeansProjects\JavaFXApplication3\dist\run221792884
jfxsa-run:
CONSTRUÍDO COM SUCESSO (tempo total: 2 segundos)Estou dois dias empacado aqui. Se alguém puder ajudar agradeço.
Mensagens: 3
Participantes: 2