Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 907715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:35:51+00:00 2026-05-15T16:35:51+00:00

Hi everyone i was working with memcache, and when i compiled this code i

  • 0

Hi everyone i was working with memcache, and when i compiled this code i got following errors.

2010-07-09 10:35:53.499 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2010-07-09 10:35:53.520 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@7fdcde
Exception in thread "main" java.lang.IllegalArgumentException: Non-serializable object
 at net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(BaseSerializingTranscoder.java:86)
 at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:135)
 at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:301)
 at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:691)
 at def.Tweet.main(Tweet.java:23)
Caused by: java.io.NotSerializableException: def.User
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1173)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:343)
 at net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(BaseSerializingTranscoder.java:81)
 ... 4 more

I managed to fix it with converting User class toString but ı dont want to use toString method.I just want to use my class to add and get mwethods. How can i fix this problem?
Here is the code i am using.

package def;

import java.io.IOException;
import java.io.Serializable;
import java.net.InetSocketAddress;

import net.spy.memcached.MemcachedClient;

public class Tweet {
  private static User user;
  private static Message message;
  private static Followers follower;

public static void main(String[] args) throws Exception {
 try{
     user = new User(1,"Mehmet Özer","asd","127.0.0.1","True","Onine");
  //String deneme = user.toString();
  MemcachedClient c=new MemcachedClient(new InetSocketAddress("localhost", 11211));


  // Store a value (async) for one hour

  c.set(user.userKey, 3600, user);
  System.out.println(c.get(user.userKey));

    }
  catch(IOException ex) {
        ex.printStackTrace();
    }
}
}

Sorry , i forgot the User class, I am also giving you the User class to help me better.

public class User {
    public static String userKey = "UserDB";
    public static int userID ;
    public static String userName;
    public static String password;
    public static String ipAddress;
    public static String isOnline;
    public static String lastActive;

    public User(int userID, String userName, String password, String ipAddress,String isOnline,String lastActive)
    {
        this.userID = userID;
        this.userName = userName;
        this.password = password;
        this.ipAddress = ipAddress;
        this.isOnline = isOnline;
        this.lastActive = lastActive;

    }
    @Override
    public String toString() {
        System.out.println(this.userID);
        System.out.println(this.userName);
        System.out.println(this.password);
        System.out.println(this.ipAddress);
        System.out.println(this.isOnline);
        System.out.println(this.lastActive);

        return super.toString();
    }


    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:35:52+00:00Added an answer on May 15, 2026 at 4:35 pm

    Memcache doesn’t know how to serialize your objects. You’ll need to implement Serializable to have Java handle the serialization, or Externalizable if you need more control over the (de)serialization process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.