• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

serialiazation- run time exceptions

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi when ever i am running any serialization based prgm i getting the followng error at run time, compilation is fine,

please advice where am i going wrong.



at run time i am getting the following error,

// Exception in thread "main" java.lang.NoSuchMethodError: Dog.<init>(ILjava/lang/String;)V
// at SuperNotSerial.main(SuperNotSerial.java:7)



 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Compiles and runs with no exceptions for me...

Henry
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
works fine for me too.

I could reproduce your error, though, if I compiled another class named Dog after compiling SuperNotSerial. The new Dog will replace the one SuperNotSerial is expecting. As the Error implies, the underlying Dog class somehow changed after you compiled SuperNotSerial. Any ideas on how this happened?
 
Mohd Abrar Khan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys

thanks for your time,

Tim, i have no idea how the Dog class is changing,

i have tried running the same programme in Netbeans IDE, its giving correct output there,

problem is comming while running through JVM,

i am still unable to sort out the exception.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Delete your class files. Delete your .ser file. Recompile everything. And try again.

Henry
 
Mohd Abrar Khan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Henry thanks i have done that it was giving the same error,

now i have moved the file to a different location and ran it from there its working fine now,

just had a doubt say for eg: if i have another class file which contains a dog Subclass, i have executed this file and its ok,

and currently if i am running this programme which also has a dog class , so does this cause a problem in execution of my current programme

both the files are in same directory location,
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that although serialization is very interesting and useful it's not the the exam for SCJP 6.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohd Abrar Khan wrote:

i have another class file which contains a dog Subclass, i have executed this file and its ok,
and currently if i am running this programme which also has a dog class , so does this cause a problem in execution of my current programme

both the files are in same directory location,



Yes sir. This is what I was asking about. the other class file's Dog subclass will replace your other Dog.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A NoSuchMethodError indicates that you have an old class file somewhere in which the indicated method is missing (in your case, it's complaining about a missing constructor in class Dog that takes an int and a String). You have an old version of Dog.class that gets picked up.

Mohd Abrar Khan wrote:Henry thanks i have done that it was giving the same error,

now i have moved the file to a different location and ran it from there its working fine now,


You must have missed something, in the old location or somewhere in your classpath was probably still an old version of Dog.class.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic