Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SilentPanda

Moderator emeritus
Original poster
Oct 8, 2002
9,997
33
The Bamboo Forest
Edit: Figured out the issue finally (see bottom if you care).

I'm at the end of my rope on this... I've tried command line, NetBeans IDE, and JPad Pro (yeah I'm on Windows right now but hey it's Java right?).

I have XMLBeans 2.2.0 installed and JDK 1.5.0 (release 9 I believe).

I'm using the AddressDetails.xsd from http://www.devx.com/xml/Article/17495/1954?pf=true

scomp works fine and gives me an AddressDetails.jar file as expected.

The code I'm using is as follows:

Code:
/*
 * Main.java
 *
 * Created on October 11, 2006, 9:46 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package testapp;

import org.tempuri.addressDetails.AddressDetailsDocument;
import org.tempuri.addressDetails.AddressDetailsDocument.AddressDetails;

public class Main {
    
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        AddressDetailsDocument myDoc;
        myDoc = AddressDetailsDocument.Factory.newInstance();
        AddressDetails myDetails;
        myDetails = myDoc.addNewAddressDetails();
        
        myDetails.setName("Test Name");
        myDetails.setAddress1("My Address");
        myDetails.setAddress2("City of City, AA");
        myDetails.setEmail("user@place.com");
        myDetails.setZIP("12345");
        
        System.out.println(myDoc.toString());
    }    
}

The code compiles fine. When I run it I get the following:

Code:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
        at java.lang.Class.getMethod0(Class.java:2642)
        at java.lang.Class.getMethod(Class.java:1579)
        at org.apache.xmlbeans.XmlBeans.buildMethod(XmlBeans.java:174)
        at org.apache.xmlbeans.XmlBeans.buildNodeMethod(XmlBeans.java:195)
        at org.apache.xmlbeans.XmlBeans.buildNodeToCursorMethod(XmlBeans.java:232)
        at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:131)
        at org.tempuri.addressDetails.AddressDetailsDocument$Factory.newInstance(Unknown Source)
        at testapp.Main.main(Main.java:27)

I know this is generally a CLASSPATH issue but my CLASSPATH is set to:

Code:
CLASSPATH=.;C:\Program Files\Java\jre1.5.0_06\lib\ext\QTJava.zip;C:\xmlbeans-2.2
.0\lib\xbean.jar;C:\xmlbeans-2.2.0\lib\jsr173_1.0_api.jar

My IDE attempts to run the code using this command:

Code:
"C:\Java\jdk1.5.0_09\jre\bin\java.exe" -classpath C:\temp\TestApp\src;C:\temp\AddressDetails.jar;C:\xmlbeans-2.2.0\lib\xbean.jar testapp.Main

That looks correct to me... but I just can't... get it... to work... *cry*

Any suggestion? It's probably obvious but we've all been there I'm sure.

One thing I did note was I can't find javax.xml.stream.* in the 1.5 API. But maybe I'm not looking in the right place.

Edit: I had to add jsr173_1.0_api.jar to the project... it works now... *does the panda shimmy*
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.