This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Castor NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Castor NullPointerException" Watch "Castor NullPointerException" New topic
Author

Castor NullPointerException

Benjamin Hundley
Ranch Hand

Joined: Mar 06, 2006
Posts: 53
I am playing with Castor mapping and I'm getting a NullPointerException. Can anyone help.

My mapping file.

[i]<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.org/mapping.dtd">


<mapping>
<class name="Dog" verify-constructable="false">

<map-to xml="MyDog"/>

<field name="name" type="string">
<bind-xml name="DogName" node="element"/>
</field>
</class>
</mapping>


The Dog Class:[/i]


public class Dog {
private String name;
private String breed;
private String color;
private String size;
public String getName() {
return name;
}

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

public String getBreed() {
return breed;
}

public void setBreed(String breed) {
this.breed = breed;
}

public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public String getSize() {
return size;
}

public void setSize(String size) {
this.size = size;
}

public Dog(String name, String breed, String color, String size){
this.name = name;
this.breed = breed;
this.color = color;
this.size = size;
}

}


When I run I get this:

Dec 29, 2010 12:55:59 PM org.exolab.castor.xml.Marshaller staticMarshal
INFO: Marshaller called using one of the *static* marshal(Object, *) methods. This will ignore any mapping files as specified. Please consider switching to using Marshaller instances and calling one of the marshal(*) methods.
Dec 29, 2010 12:55:59 PM org.exolab.castor.mapping.Mapping setBaseURL
INFO: dog_mapping.xml is not a URL, trying to convert it to a file URL
Dec 29, 2010 12:55:59 PM org.exolab.castor.mapping.Mapping loadMapping
INFO: Loading mapping descriptors from dog_mapping.xml
java.lang.NullPointerException
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:907)
at XMLGenerator.generateXML(XMLGenerator.java:32)
at XMLGeratorTest.main(XMLGeratorTest.java:5)
 
Don't get me started about those stupid light bulbs.
 
subject: Castor NullPointerException
 
Similar Threads
problem when using castor framework
Problem with System.out.print
about error code
[Solved]Need some clarification about <jsp:useBean/> standard action.
Problem in Serialisation