Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception trying to authenticate #2

Closed
grimace opened this issue Dec 15, 2016 · 7 comments
Closed

exception trying to authenticate #2

grimace opened this issue Dec 15, 2016 · 7 comments

Comments

@grimace
Copy link

grimace commented Dec 15, 2016

I'm new to spring-session assume I'm missing something, but I get an exception:
com.orientechnologies.orient.core.exception.OSerializationException: Linked type [class org.springframework.security.web.savedrequest.DefaultSavedRequest:DefaultSavedRequest[http://localhost:9090/login]] cannot be serialized because is not part of registered entities. To fix this error register this class
DB name="testdb"

...also I found a suggestion via google search that suggests :

'you should use the "ODatabaseDocumentTx" to open db if you want create/use
a Document database.

replace OObjectDatabaseTx with ODatabaseDocumentTx
(example ODatabaseDocumentTx db = new ODatabaseDocumentTx'

Tho I'm not quite sure that is what I'm up against.

@maseev
Copy link
Owner

maseev commented Dec 16, 2016

Can you share a code example so I'll be able to reproduce the problem? This kind of errors usually occur when you're trying to save an object which doesn't implement the java.io.Serializable interface.

@maseev
Copy link
Owner

maseev commented Dec 16, 2016

On second thought, I think it'll be a good idea to make OrientHttpSession::setAttribute throw an exception if an attribute is not serializable. Let me fix this really quick.

@maseev
Copy link
Owner

maseev commented Dec 16, 2016

@grimace Here you go. Now it should be much easier to track down where you set this attribute which apparently doesn't implement the java.io.Serializable interface.

@grimace
Copy link
Author

grimace commented Dec 17, 2016

Ok, so tried with new Serialization check, with code, then exception. Not sure I understand, is it the SecurityContextImpl that's the issue because it's not serializable?

package com.grimace;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import io.github.maseev.spring.session.orientdb.EnableOrientHttpSession;
import org.springframework.web.bind.annotation.RequestMapping;

import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@EnableOrientHttpSession
@SpringBootApplication
public class Application {

  @RequestMapping("/hello")
  public Map<String,Object> home() {
    Map<String,Object> model = new HashMap<String,Object>();
    model.put("id", UUID.randomUUID().toString());
    model.put("content", "Hello World");
    return model;
  }

  @RequestMapping("/user")
  public Principal user(Principal user) {
    return user;
  }

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }
}
2016-12-16 15:53:36.586 ERROR 48739 --- [nio-9090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : 
Servlet.service() for servlet [dispatcherServlet] in context with path [] 
 threw exception [Request processing failed; nested exception is com.orientechnologies.orient.core.exception.OSerializationException:  
   Linked type [class org.springframework.security.core.context.SecurityContextImpl:org.springframework.security.core.context.SecurityContextImpl@442b5a9f: 
   Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@442b5a9f: 
   Principal: org.springframework.security.core.userdetails.User@36ebcb: Username: user; Password: [PROTECTED]; 
   Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; 
   Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: 
   RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_USER] cannot be serialized because is not part of registered entities.
    To fix this error register this class
	DB name="testdb"] with root cause

@maseev
Copy link
Owner

maseev commented Dec 17, 2016

With the latest update this shouldn't be a problem any more.

@maseev
Copy link
Owner

maseev commented Dec 20, 2016

@grimace Did this fix solve your problem?

@grimace
Copy link
Author

grimace commented Dec 20, 2016

yes! Problem solved. Thank you!

@grimace grimace closed this as completed Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants