Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: MarshallableObject for java 6 version

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default MarshallableObject for java 6 version

    Hi

    I do have a project which which has been using jre1.5.0_06 from the past few years. But now i would like to upgrade it to jre1.6.0_20. When i do the upgradation, i do get an error for the Class MarshallableObject ( i didnt get any error when i was using jre1.5.0_06 ).

    Now MarshallableObject class has two methods as shown below

    marshal(Marshaller m)
    unmarshal(Unmarshaller u)

    Detail usage of the above methods in my project is as below:

    public void marshal(Marshaller m) throws IOException {
    		XMLWriter w = m.writer();
    		w.start("AT");
    		w.attribute("N", _N.toString());
    		w.attribute("V", _V.toString());
    		w.end("AT");
    }
     
     
    public void unmarshal(Unmarshaller u) throws UnmarshalException {
    		XMLScanner xs = u.scanner();
    		Validator v = u.validator();
    		xs.takeStart("AT");
    		while (xs.atAttribute()) {
    			String an = xs.takeAttributeName();
    			if (an.equals("N")) {
    				if (_N != null) {
    					throw new DuplicateAttributeException(an);
    				}
    				_N = xs.takeAttributeValue();
    				continue;
    			}
    			if (an.equals("V")) {
    				if (_V != null) {
    					throw new DuplicateAttributeException(an);
    				}
    				_V = xs.takeAttributeValue();
    				continue;
    			}
    			throw new InvalidAttributeException(an);
    		}
    		xs.takeEnd("AT");
    	}

    Now the following piece of code

    1) XMLWriter w = m.writer();

    2) XMLScanner xs = u.scanner();

    3) Validator v = u.validator();

    doesnt pose a problem with jre1.5.0_06 , but when i use jre1.6.0_20, the method writer, scanner, validator doesnt seem to exists for Marshaller and UnMarshaller class.
    I checked the api documentation. The methods do exists for both the classes.

    Is it that the respective methods are not included in java 6?? Is there any replacement methods for these???Couldnt find any related matter.
    any help would be appreciated.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MarshallableObject for java 6 version

    get an error
    Please post the full text of the error message.

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MarshallableObject for java 6 version

    The error mesage that i am getting is " the method scanner is undefined for the type Unmarshaller" and similarly for others.

    In java 6, Marshaller is an interface, but i went through a site, which showed Marshaller as a class. Here the link for both

    : Class Marshaller = (Marshaller Class)

    http://java.sun.com/javase/6/docs/ap... Platform SE 6 - (Interface Marshaller)


    Heres the link for MarshallableObject which has both marshal and Unmarshal Methods

    : Class MarshallableObject : Class MarshallableObject
    Last edited by AllenK; June 30th, 2010 at 07:23 AM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MarshallableObject for java 6 version

    Which package was Marshaller in for version 1.5? I don't see it in my API doc 1.5.0
    Also don't see MarshallableObject in my API doc?

  5. #5
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: MarshallableObject for java 6 version

    Could you show us the import statements in your class, I have a feeling you're importing the wrong things and I believe that the MarshallableObject is apart of METS Java Toolkit which can be found at.

    METS Java Toolkit - Home

    // Json

  6. #6
    Junior Member
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MarshallableObject for java 6 version

    import java.io.*;
    import javax.xml.bind.*;
    import javax.xml.marshal.*;
     
    public class AT extends MarshallableObject implements Element {
     
    public void marshal(Marshaller m) throws IOException {
    		XMLWriter w = m.writer();
    		w.start("AT");
    		w.attribute("N", _N.toString());
    		w.attribute("V", _V.toString());
    		w.end("AT");
    	}
     
    public void unmarshal(Unmarshaller u) throws UnmarshalException {
    		XMLScanner xs = u.scanner();
    		Validator v = u.validator();
    		xs.takeStart("AT");
    		while (xs.atAttribute()) {
    		   String an = xs.takeAttributeName();
    		   if (an.equals("N")) {
    		       if (_N != null) {
    			throw new DuplicateAttributeException(an);
    		        }
    			_N = xs.takeAttributeValue();
    			continue;
    		     }
    		    if (an.equals("V")) {
    			if (_V != null) {
    			throw new DuplicateAttributeException(an);
    			}
    			_V = xs.takeAttributeValue();
    			continue;
    		    }
    			throw new InvalidAttributeException(an);
    		}
    		xs.takeEnd("AT");
    	}
    }

    The only thing that i dont understand is that the above code does not seem to pose problems when i use jre1.5.0_06 , but when i use jre1.6.0_20(after removing jre1.5.0_06 from my project), i get the error message. Using Eclipse for development purpose.

    @Norm
    I have given the links where i found the MarshallableObject class (where i saw the marshal and unmarshal methods used in my code) and the Marshaller Class( where i could see the write method) in my second post

    : Class Marshaller = (Marshaller Class)

    http://java.sun.com/javase/6/docs/ap... Platform SE 6 - (Interface Marshaller)


    Heres the link for MarshallableObject which has both marshal and Unmarshal Methods

    : Class MarshallableObject : Class MarshallableObject
    yes, you are write, MarshallableObject, Marshaller class are not present in neither 1.5 nor 1.6.
    But i found the details( shown in quotes above) while searching through google.

    Plus, the Marshaller interface as in java 1.6 does not have any methods which can be used to return XMLWriter. Same goes with Unmarshaller Interface, which does not have any methods which can be used to return XMLSacnner.

    The method 'marshal' used in my code is used to add additional stuffs using XMLWriter. Same goes with XMLScanner to read the contents.

  7. #7
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: MarshallableObject for java 6 version

    Eclipse sometimes tidy up the imports for you, you might just have upgraded to Java 6 and accidentally dropped the METS Java Toolkit jar from your classpath and now it assumes these objects are the ones in the Java 6 JDK.

    // Json

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MarshallableObject for java 6 version

    Using Eclipse for development purpose.
    Are there any other libraries the IDE is using?
    I don't see the package: import javax.xml.marshal in any of my API docs

  9. #9
    Junior Member
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MarshallableObject for java 6 version

    @Json

    These changes that i am currently doing(changing to jre 1.6 from jre 1.5) is in the copy of my original project( since i didnt want to create problems with the original project). I had a look at my original project. there are no METS Java Toolkit jar used.

    @Norm
    Ya, your right. couldnt find it in api. sorry, forgot to mention it.
    The other thing, i dont understand is that m not getting any error at the below mentioned line of code

    public class AT extends MarshallableObject implements Element {
    MarshallableObject class doesnt seem to exists in java 1.6 and 1.5 api, but still no error in the above line of code. and if METS Java Toolkit jar was removed by eclipse, i would have got error in the above line of code itself, which i am not.

    I hope there must be some workaround to successfully implement it..hoping for the best

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MarshallableObject for java 6 version

    m not getting any error
    Can you show the import statements and the jar files used for the compile of that statement?

  11. #11
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: MarshallableObject for java 6 version

    Try doing a project clean in Eclipse.

    // Json

  12. #12
    Junior Member
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MarshallableObject for java 6 version

    Hey guys,

    Please have a look at the link below. i am having the same problem as theirs.

    First Link :
    Java Technology & XML - Issue with JAXB.rt.1.0.ea.jar and Java 1.6

    Second Link :
    Jaxb version from 1.x to 2.1.9 (XML and Related Technologies forum at JavaRanch)

    Please have a look the message posted by Rajesh Akkiniveeranan in the second link. Having the same issue as he has while upgrading from 1.4 to 1.6.

    i am using jaxbrt10.jar in my project. Did clean my project, but faced the same issue

  13. #13
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: MarshallableObject for java 6 version

    Ah, so now we're mixing JAXB into the whole thing as well.

    The problem I guess is that JAXB 1.0 doesn't work very well with Java 6 and so therefore you should update JAXB as well, however the JAXB API might have changed between 1.0 and whatever you're upgrading to so you need to alter your code to work with the new version of JAXB.

    Sounds very simple but it all depends on how much JAXB stuff you are using. The only way to solve this then is to go through your code and try to find some way in the new JAXB to replace your old code with. Something that probably does what you want and maybe even faster.

    So in relation to your initial post, the classes/interfaces will most likely have disappeared and you need to find the new JAXB replacements. What are you using JAXB for doing? Are you just marshalling Java objects into XML and back?

    // Json

Similar Threads

  1. "java -version" doesn't display proper value.
    By goldest in forum Java Theory & Questions
    Replies: 6
    Last Post: November 1st, 2009, 03:48 PM
  2. [SOLVED] installation procedure for java 1.6 latest version on xp
    By sriraj.kundan in forum Java Theory & Questions
    Replies: 1
    Last Post: June 25th, 2009, 08:18 AM
  3. Replies: 5
    Last Post: April 20th, 2009, 06:47 AM