java.lang.IllegalArgumentException

tip

This happened when I tried to insert an empty list of elements to a MongoDB collection.


poroszdporoszd

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • While doing some load test, I got this exception from mongodb. {noformat} 2012-11-16 16:09:41.031 [WARN] org.springframework.jms.listener.DefaultMessageListenerContainer - Execution of JMS message listener failed, and no ErrorHandler has been set. java.lang.IllegalArgumentException: can't serialize class java.math.BigInteger at org.bson.BasicBSONEncoder.putNumber(BasicBSONEncoder.java:373) at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:218) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:267) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:240) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:205) at com.mongodb.DBCollection.insert(DBCollection.java:57) at com.mongodb.DBCollection.insert(DBCollection.java:100) at com.dreamworks.pam.logging.dao.mongodb.LogEntryDAOImpl.createLogEntry(LogEntryDAOImpl.java:88) at com.dreamworks.pam.logging.services.impl.LogEntryServiceImpl.createLogEntry(LogEntryServiceImpl.java:85) at com.dreamworks.pam.logging.services.jms.LogEntryMessageListener.onMessage(LogEntryMessageListener.java:67) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:326) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:264) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:965) at java.lang.Thread.run(Thread.java:619) {noformat} Our script generated the same data with different "_id", "id" and "created" and most of them were inserted into database fine. This exception only happened sporadically.
    via by Gina Chen,
  • Jackson Serialize Map to List
    via Stack Overflow by user1236874
    ,
  • save and find json string in mongodb
    via Stack Overflow by Mike Dynamite
    ,
  • Saving twitter4j Status object to MongoDB
    via Stack Overflow by popcoder
    ,
    • java.lang.IllegalArgumentException: can't serialize class java.math.BigInteger at org.bson.BasicBSONEncoder.putNumber(BasicBSONEncoder.java:373) at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:218) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:174) at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:120) at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:27) at com.mongodb.OutMessage.putObject(OutMessage.java:267) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:240) at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:205) at com.mongodb.DBCollection.insert(DBCollection.java:57) at com.mongodb.DBCollection.insert(DBCollection.java:100) at com.dreamworks.pam.logging.dao.mongodb.LogEntryDAOImpl.createLogEntry(LogEntryDAOImpl.java:88) at com.dreamworks.pam.logging.services.impl.LogEntryServiceImpl.createLogEntry(LogEntryServiceImpl.java:85) at com.dreamworks.pam.logging.services.jms.LogEntryMessageListener.onMessage(LogEntryMessageListener.java:67) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:326) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:264) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:965) at java.lang.Thread.run(Thread.java:619)

    Users with the same issue

    rprp
    1 times, last one,
    renireni
    1 times, last one,
    poroszdporoszd
    2 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    1 more bugmates