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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:03:35+00:00 2026-05-27T19:03:35+00:00

I’m using MyBatis with playframework and everything works nicely except: When I’ve attempted to

  • 0

I’m using MyBatis with playframework and everything works nicely except:

When I’ve attempted to use the default cache built in MyBatis (<cache/> tag in xml mapper files), upon retrieving a cached select statement I get this stacktrace.

If I run the same statements in a unit test (or another application without playframework involved) everything works fine.

So, my guess it has something to do the way playframework loads/compiles the classes some sort of classloader issue.

The directory layout of my project looks something like this (relevant bits):

app
  controllers
  data // xml mapping files and java interfaces for ibatis
       // & a class that returns a SqlSessionFactory
    domain // Pojos for SQL results (e.g. User.java)
  models
  views
lib // here is myibatis jar file
(...) // the rest of the standard play framework project

The model method that throws the exception is this:

  public static UserAuthentication findAuthenticatonIdentity(UserId userId){
    SqlSessionFactory sessionFactory = IbatisSessionFactory.getSqlMapper();
    SqlSession session = sessionFactory.openSession();
    AuthMapper authMapper = session.getMapper(AuthMapper.class);

    UserAuthentication ua = authMapper.selectByUserId(userId); // line 162
    session.close();
    return ua;
  }

And UserAuthentication implements Serializable!

And here is the stacktrace:

Execution exception (In /app/models/UserModel.java around line 162)
PersistenceException occured : 
 ### Error querying database.  Cause: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication
 ### Cause: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication

play.exceptions.JavaExecutionException: 
### Error querying database.  Cause: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication
### Cause: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231)
    at Invocation.HTTP Request(Play!)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication
### Cause: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:94)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:58)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
    at $Proxy8.selectByUserId(Unknown Source)
    at models.UserModel.findAuthenticatonIdentity(UserModel.java:162)
    at controllers.securesocial.MySecureSocial.checkAccess(MySecureSocial.java:97)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:504)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
    at play.mvc.ActionInvoker.handleBefores(ActionInvoker.java:322)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:142)
    ... 1 more
Caused by: org.apache.ibatis.cache.CacheException: Error deserializing object.  Cause: java.lang.ClassNotFoundException: data.domain.UserAuthentication
    at org.apache.ibatis.cache.decorators.SerializedCache.deserialize(SerializedCache.java:94)
    at org.apache.ibatis.cache.decorators.SerializedCache.getObject(SerializedCache.java:50)
    at org.apache.ibatis.cache.decorators.LoggingCache.getObject(LoggingCache.java:50)
    at org.apache.ibatis.cache.decorators.SynchronizedCache.getObject(SynchronizedCache.java:55)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:100)
    ... 13 more
Caused by: java.lang.ClassNotFoundException: data.domain.UserAuthentication
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
    at java.util.ArrayList.readObject(ArrayList.java:593)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
    at org.apache.ibatis.cache.decorators.SerializedCache.deserialize(SerializedCache.java:91)
    ... 18 more

UserAuthentication.java

public class UserAuthentication implements Serializable {

  private int id;
  private String authId;
  private String secret;
  private String token; // Oauth1 token
  private String accessToken; // Oauth2 request token
  private String displayName;
  private String authMethod;
  private String provider;
  private String email;
  private String avatarUrl;
  private Date lastAccess;
  private String password;
  private boolean emailVerified;
  private int userId;
  private String activationUuid;
  private Date activationExpiry;

  // + getters & setters
}

UserId.java

public class UserId implements java.io.Serializable {
    /**
     * The id the user has in a external service.
     */
    public String id;

    /**
     * The provider this user belongs to.
     */
    public ProviderType provider; // simple enum
}
  • 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-27T19:03:36+00:00Added an answer on May 27, 2026 at 7:03 pm

    Sorry, I think I was wrong – this is not a name collision but rather a classloader problem.

    Play uses a dynamic classloading mechanism to detect changes to the source code and enhance methods through bytecode injection. http://groups.google.com/group/play-framework/browse_frm/thread/359736394ae27902/98445c557833036c

    I think the problem may be that MyBatis is using the regular class loader – so can’t find the classes that are loaded via Play’s mechanism. When you put the source into the Play directory, MyBatis is then using the Play classloader.

    Here are some options:

    1) Compile your domain objects into a JAR file. Include that jar in your project: http://groups.google.com/group/play-framework/browse_thread/thread/b54e4e25ae49161b

    2) Force MyBatis to use the Play classloader – somewhere before any mybatis calls

    Thread.currentThread().setContextClassLoader(Play.classloader); 
    

    http://groups.google.com/group/play-framework/browse_thread/thread/f4789ee5c20609af/d1412a914dc06851?#d1412a914dc06851

    Still seems like a hack, but perhaps it keeps your application source size down.

    3) Ensure your classes are loaded before the calls to MyBatis. So, in this case.

    Class.forName("data.domain.UserAuthentication");
    Class.forName("data.domain.UserId");
    

    Which seems far worse of a hack.

    I hope one of those options works for you.

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.