Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException when using SerializationUtils.clone()

Tags:

java

org.apache.commons.lang.SerializationException: java.lang.ClassNotFoundException: com.anonymized.bean.Person
        at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:166)
        at org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:193)
        at org.apache.commons.lang.SerializationUtils.clone(SerializationUtils.java:81)
        at com.anonymized.CallingClass.handleRequestInternal(CallingClass.java:45)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: com.anonymized.bean.Person
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        Truncated. see log file for complete stacktrace

The call that's throwing the exception.

Person copy = (Person) SerializationUtils.clone(PersonHolder.getPerson(request));
  • PersonHolder.getPerson(request) DOES return a Person
  • Person implements Serializable
  • request is an HttpServletRequest which has data that is being passed to the method in which I try to clone the Person. It contains data that the getPerson method needs. I don't believe this has anything to do with my problem but I just wanted to be clear what it was doing.
  • The commons-lang-2.4.jar is included in my project.
  • I've imported org.apache.commons.lang.SerializationUtils and the Person class.

Any ideas what I may be doing wrong here?

like image 756
qbolt Avatar asked Jun 19 '26 17:06

qbolt


1 Answers

try importing org.apache.commons.lang3.SerializationUtils.

like image 91
Adamo Ferrazzo Avatar answered Jun 22 '26 07:06

Adamo Ferrazzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!