Re: [morphia] Error using Reference Mapping

151 views
Skip to first unread message
Message has been deleted

Justin Lee

unread,
Jun 8, 2015, 3:58:53 PM6/8/15
to mor...@googlegroups.com
Are you using at least 3.0.0 of the Java driver?

--------------------------------

name     : "Justin Lee", 
  title    : "Software Engineer",
  twitter  : "@evanchooly",
  web      : [ "10gen.com", "antwerkz.com" ],
  location : "New York, NY" }

On Mon, Jun 8, 2015 at 3:55 PM, Milson Munakami <mils...@gmail.com> wrote:
Hi there,

And when I run the Main application it shows:
Exception in thread "main" java.lang.NoSuchMethodError: com.mongodb.DBRef.<init>(Lcom/mongodb/DB;Ljava/lang/String;Ljava/lang/Object;)V
at com.google.code.morphia.mapping.Mapper.keyToRef(Mapper.java:559)
at com.google.code.morphia.mapping.ReferenceMapper.writeSingle(ReferenceMapper.java:51)
at com.google.code.morphia.mapping.ReferenceMapper.toDBObject(ReferenceMapper.java:45)
at com.google.code.morphia.mapping.Mapper.writeMappedField(Mapper.java:529)
at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:442)
at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:426)
at com.google.code.morphia.DatastoreImpl.entityToDBObj(DatastoreImpl.java:674)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:722)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:793)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:787)
at gpms.gui.MorphiaReferenceExample.main(MorphiaReferenceExample.java:81)

What can be the reason for this issue and how to solve it.

--
You received this message because you are subscribed to the Google Groups "Morphia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to morphia+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Justin Lee

unread,
Jun 8, 2015, 4:17:57 PM6/8/15
to mor...@googlegroups.com
Then are you using Morphia 1.0.0?

--------------------------------

name     : "Justin Lee", 
  title    : "Software Engineer",
  twitter  : "@evanchooly",
  web      : [ "10gen.com", "antwerkz.com" ],
  location : "New York, NY" }

On Mon, Jun 8, 2015 at 4:10 PM, Milson Munakami <mils...@gmail.com> wrote:
HI Justin,
I am using mongo-java-driver-3.0.0.jar.
Message has been deleted

Justin Lee

unread,
Jun 8, 2015, 5:09:10 PM6/8/15
to mor...@googlegroups.com
I'm pretty sure you have old versions of libraries in your classpath.  That method call doesn't exist in the code.  If you're using maven, use "mvn dependencies" to double check.  If you're seeing this in your IDE, check that it's not point to old versions of something.  Also, make sure you're doing a clean then a build and see if the error persists.

--------------------------------

name     : "Justin Lee", 
  title    : "Software Engineer",
  twitter  : "@evanchooly",
  web      : [ "10gen.com", "antwerkz.com" ],
  location : "New York, NY" }

On Mon, Jun 8, 2015 at 5:03 PM, Milson Munakami <mils...@gmail.com> wrote:

yeah I update the Maven dependency to Morphia 1.0.0 Still can't say why this mapping issue is occurring? I could not save the Family collection but the User collection is saving correctly.
The Family class is :
@Entity
public class Family {
@Id
private ObjectId id;

private String surname;

@Reference
private User dad;

@Reference
private User mom;

@Reference
private List<User> children = new ArrayList<User>();
Message has been deleted

Justin Lee

unread,
Jun 8, 2015, 5:54:06 PM6/8/15
to mor...@googlegroups.com
Any time.  Glad it's fixed.

--------------------------------

name     : "Justin Lee", 
  title    : "Software Engineer",
  twitter  : "@evanchooly",
  web      : [ "10gen.com", "antwerkz.com" ],
  location : "New York, NY" }

On Mon, Jun 8, 2015 at 5:34 PM, Milson Munakami <mils...@gmail.com> wrote:
The problem may be due to cleaning up the Maven Repo. Yes, Justin I did clean up and Project >> clean and Maven Update so it is working fine now.

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages