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 9232177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:15:06+00:00 2026-06-18T06:15:06+00:00

i try to deserialize class from the server , but in the client im

  • 0

i try to deserialize class from the server , but in the client im getting :

java.lang.ClassNotFoundException: com.server.core.StateFilesStruct

where in my client the StateFilesStruct class with this package name:

com.client.core.StateFilesStruct

here is my class’s :

public  Object deserialize(byte[] bytes)   {
        ByteArrayInputStream b = new ByteArrayInputStream(bytes);
        ObjectInputStream o = null;
        try {
            o = new ObjectInputStream(b);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            return o.readObject();
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return o;
}

the class im sending this is in the server :

package com.server.core;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;

 public class StateFilesStruct implements Serializable {
    private static final long serialVersionUID = 988633010151085730L;
    private Hashtable<String,String> Repository;
    public Hashtable<String, String> getRepository() {
        return Repository;
    }
    public void setRepository(Hashtable<String, String> repository) {
        Repository = repository;
    }
    public StateFilesStruct()
    {
        Repository = new Hashtable<String,String>();
    }
}

the class i keep in the client the same as the server one but with different packge name:

package com.client.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;

 public class StateFilesStruct implements Serializable {
    private static final long serialVersionUID = 988633010151085730L;
    private Hashtable<String,String> Repository;
    public Hashtable<String, String> getRepository() {
        return Repository;
    }
    public void setRepository(Hashtable<String, String> repository) {
        Repository = repository;
    }
    public StateFilesStruct()
    {
        Repository = new Hashtable<String,String>();
    }
}

and the way im trying to resolve the class in the client is :
receiving from tcpip socket using ZeroMQ

 byte[] byteFileStruct = m_pNetworkManager.getSocket().recv(0); 
 StateFilesStruct stateFilesStruct = (StateFilesStruct)deserialize(byteFileStruct);

getting this exception as you can see its looking fro the server class :

java.lang.ClassNotFoundException: com.server.core.StateFilesStruct
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
  • 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-06-18T06:15:08+00:00Added an answer on June 18, 2026 at 6:15 am

    In java, the package name is part of the class name. As far as the JVM is concerned these are 2 completely different classes, so you need to have the same class you’re deserializing in your classpath.

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

Sidebar

Related Questions

Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
i try to send Image Object as serialized File from Client to Server by
So I'm getting an object back from a server that looks like this: {
Try this piece of code - public class WhitespaceTest { public static void main(String[]
I'm using JSON.Net to try and deserialize some survey responses from SurveyGizmo. Here's a
I have a class that inherits from ApiController. It has a Put-method like this:
im trying to deserialize the JSON data Ive retrieved from facebook but c# wont
This is my first try to deserialize a JSON string returned by Facebook. I
I try to use gson library to deserialize a flow of objects sent to
try: html = urlopen('http://glbse.com/api/asset/' + asset.name) except: print 'error while updating the price of

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.