Help compiling castor ibm java example

Discussion in 'Java' started by plusGForce, Mar 4, 2008.

  1. plusGForce

    plusGForce Guest

    C:\Users\Office...\com\pstephens\xml>javac -cp %CP% MarshalTester.java
    MarshalTester.java:11: cannot find symbol

    symbol : class CD
    location: class ibm.xml.castor.MarshalTester
    CD sessions = new CD("Sessions for Robert J", "Eric Clapton");
    ^
    MarshalTester.java:11: cannot find symbol
    symbol : class CD
    location: class ibm.xml.castor.MarshalTester
    CD sessions = new CD("Sessions for Robert J", "Eric Clapton");
    ^
    2 errors

    03/03/2008 02:21 PM 2,115 CastorTest.java
    26/02/2008 01:12 PM 1,106 CD.java
    03/03/2008 01:50 PM 1,144 Customer.java
    03/03/2008 01:22 PM 183 FirstName.java
    03/03/2008 01:22 PM 182 Lastname.java
    26/02/2008 01:13 PM 584 MarshalTester.java
    03/03/2008 01:23 PM 176 MI.java
    03/03/2008 11:42 AM 877 Tester.java
    26/02/2008 01:15 PM 860 UnmarshalTester.java

    Contents of MarshalTester.java

    package ibm.xml.castor;
    import java.io.FileWriter;
    import org.exolab.castor.xml.Marshaller;
    public class MarshalTester {

    public static void main(String[] args) {
    try {
    CD sessions = new CD("Sessions for Robert J", "Eric Clapton");
    sessions.addTrack("Little Queen of Spades");
    sessions.addTrack("Terraplane Blues");

    FileWriter writer = new FileWriter("cds.xml");
    Marshaller.marshal(sessions, writer);
    } catch (Exception e) {
    System.err.println(e.getMessage());
    e.printStackTrace(System.err);
    }
    }
    }
    ------------------------------------
    Contents of CD.Java

    package ibm.xml.castor;

    import java.util.ArrayList;
    import java.util.List;

    /** A class to represent CDs */
    public class CD implements java.io.Serializable {

    /** The name of the CD */
    private String name = null;

    /** The artist of the CD */
    private String artist = null;

    /** Track listings */
    private List tracks = null;

    /** Required no-args constructor */
    public CD() {
    super();
    }

    /** Create a new CD */
    public CD(String name, String artist) {
    super();
    this.name = name;
    this.artist = artist;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getName() {
    return name;
    }

    public void setArtist(String artist) {
    this.artist = artist;
    }

    public String getArtist() {
    return artist;
    }

    public void setTracks(List tracks) {
    this.tracks = tracks;
    }

    public List getTracks() {
    return tracks;
    }

    public void addTrack(String trackName) {
    if (tracks == null) {
    tracks = new ArrayList();
    }
    tracks.add(trackName);
    }
    }

    What am I doing wrong? Thanks in advance.
    plusGForce, Mar 4, 2008
    #1
    1. Advertising

  2. plusGForce

    Jeff Higgins Guest

    plusGForce wrote:
    > C:\Users\Office...\com\pstephens\xml>javac -cp %CP% MarshalTester.java
    > MarshalTester.java:11: cannot find symbol
    >
    > symbol : class CD
    > location: class ibm.xml.castor.MarshalTester
    > CD sessions = new CD("Sessions for Robert J", "Eric Clapton");
    > ^
    > MarshalTester.java:11: cannot find symbol
    > symbol : class CD
    > location: class ibm.xml.castor.MarshalTester
    > CD sessions = new CD("Sessions for Robert J", "Eric Clapton");
    > ^
    > 2 errors
    >
    > 03/03/2008 02:21 PM 2,115 CastorTest.java
    > 26/02/2008 01:12 PM 1,106 CD.java
    > 03/03/2008 01:50 PM 1,144 Customer.java
    > 03/03/2008 01:22 PM 183 FirstName.java
    > 03/03/2008 01:22 PM 182 Lastname.java
    > 26/02/2008 01:13 PM 584 MarshalTester.java
    > 03/03/2008 01:23 PM 176 MI.java
    > 03/03/2008 11:42 AM 877 Tester.java
    > 26/02/2008 01:15 PM 860 UnmarshalTester.java
    >
    > Contents of MarshalTester.java
    >


    Why put MarshalTester class in package ibm.xml.castor?

    > package ibm.xml.castor;
    > import java.io.FileWriter;
    > import org.exolab.castor.xml.Marshaller;
    > public class MarshalTester {
    >
    > public static void main(String[] args) {
    > try {
    > CD sessions = new CD("Sessions for Robert J", "Eric Clapton");
    > sessions.addTrack("Little Queen of Spades");
    > sessions.addTrack("Terraplane Blues");
    >
    > FileWriter writer = new FileWriter("cds.xml");
    > Marshaller.marshal(sessions, writer);
    > } catch (Exception e) {
    > System.err.println(e.getMessage());
    > e.printStackTrace(System.err);
    > }
    > }
    > }
    > ------------------------------------
    > Contents of CD.Java
    >


    Why put CD class in package ibm.xml.castor?

    > package ibm.xml.castor;
    >
    > import java.util.ArrayList;
    > import java.util.List;
    >
    > /** A class to represent CDs */
    > public class CD implements java.io.Serializable {
    >
    > /** The name of the CD */
    > private String name = null;
    >
    > /** The artist of the CD */
    > private String artist = null;
    >
    > /** Track listings */
    > private List tracks = null;
    >
    > /** Required no-args constructor */
    > public CD() {
    > super();
    > }
    >
    > /** Create a new CD */
    > public CD(String name, String artist) {
    > super();
    > this.name = name;
    > this.artist = artist;
    > }
    >
    > public void setName(String name) {
    > this.name = name;
    > }
    >
    > public String getName() {
    > return name;
    > }
    >
    > public void setArtist(String artist) {
    > this.artist = artist;
    > }
    >
    > public String getArtist() {
    > return artist;
    > }
    >
    > public void setTracks(List tracks) {
    > this.tracks = tracks;
    > }
    >
    > public List getTracks() {
    > return tracks;
    > }
    >
    > public void addTrack(String trackName) {
    > if (tracks == null) {
    > tracks = new ArrayList();
    > }
    > tracks.add(trackName);
    > }
    > }
    >
    > What am I doing wrong? Thanks in advance.
    Jeff Higgins, Mar 4, 2008
    #2
    1. Advertising

  3. plusGForce

    plusGForce Guest

    On Mar 4, 10:55 am, "Jeff Higgins" <> wrote:

    Why put MarshalTester class in package ibm.xml.castor?

    Why put CD class in package ibm.xml.castor?

    ---
    Your right. putting the MarshalTester class and the CD class caused
    problems. Now it compiles, but when I run it with:

    javac -cp %CP% MarshalTester I get the error message "Failed to load
    configuration: castor.core.properties and do not have any idea how to
    debug this.

    C:\...\src\com\pstephens\xml>java -c
    p %CP% MarshalTester
    Failed to load configuration: castor.core.properties
    org.castor.core.util.ConfigurationException: Failed to load
    configuration: casto
    r.core.properties
    at
    org.castor.core.util.Configuration.loadDefaultProperties(Configuratio
    n.java:144)
    at
    org.castor.core.CoreConfiguration.<init>(CoreConfiguration.java:49)
    at
    org.castor.xml.XMLConfiguration.newInstance(XMLConfiguration.java:58)

    at
    org.castor.xml.AbstractInternalContext.<init>(AbstractInternalContext
    ..java:121)
    at
    org.castor.xml.BackwardCompatibilityContext.<init>(BackwardCompatibil
    ityContext.java:45)
    at
    org.exolab.castor.xml.MarshalFramework.<init>(MarshalFramework.java:1
    85)
    at org.exolab.castor.xml.Marshaller.<init>(Marshaller.java:
    322)
    at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:
    727)
    at MarshalTester.main(MarshalTester.java:14)
    plusGForce, Mar 4, 2008
    #3
  4. plusGForce

    Jeff Higgins Guest

    plusGForce wrote:
    > On Mar 4, 10:55 am, "Jeff Higgins" <> wrote:
    >
    > Why put MarshalTester class in package ibm.xml.castor?
    >
    > Why put CD class in package ibm.xml.castor?
    >
    > ---
    > Your right. putting the MarshalTester class and the CD class caused
    > problems. Now it compiles, but when I run it with:
    >
    > javac -cp %CP% MarshalTester I get the error message "Failed to load
    > configuration: castor.core.properties and do not have any idea how to
    > debug this.


    <http://www.castor.org/xml-faq.html#Where-does-Castor-search-for-the-castor.properties-file?>

    >
    > C:\...\src\com\pstephens\xml>java -c
    > p %CP% MarshalTester
    > Failed to load configuration: castor.core.properties
    > org.castor.core.util.ConfigurationException: Failed to load
    > configuration: casto
    > r.core.properties
    > at
    > org.castor.core.util.Configuration.loadDefaultProperties(Configuratio
    > n.java:144)
    > at
    > org.castor.core.CoreConfiguration.<init>(CoreConfiguration.java:49)
    > at
    > org.castor.xml.XMLConfiguration.newInstance(XMLConfiguration.java:58)
    >
    > at
    > org.castor.xml.AbstractInternalContext.<init>(AbstractInternalContext
    > .java:121)
    > at
    > org.castor.xml.BackwardCompatibilityContext.<init>(BackwardCompatibil
    > ityContext.java:45)
    > at
    > org.exolab.castor.xml.MarshalFramework.<init>(MarshalFramework.java:1
    > 85)
    > at org.exolab.castor.xml.Marshaller.<init>(Marshaller.java:
    > 322)
    > at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:
    > 727)
    > at MarshalTester.main(MarshalTester.java:14)
    >
    Jeff Higgins, Mar 4, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam Hwang
    Replies:
    0
    Views:
    612
    Sam Hwang
    Apr 26, 2005
  2. Jeffrae
    Replies:
    0
    Views:
    459
    Jeffrae
    Nov 30, 2006
  3. Replies:
    5
    Views:
    385
  4. Robert Wells
    Replies:
    4
    Views:
    645
    Default User
    Jun 24, 2008
  5. Qu0ll
    Replies:
    42
    Views:
    1,203
    Thufir Hawat
    Apr 13, 2009
Loading...

Share This Page