Unable to obtain anonymous session exception

Hi,

I tried to implement the user avatar sample into my application. I extended the sec$User entity with UserExt and added the image field. I created the screens under gui/user and registered them in screens.xml. I also created the views for browse and edit of the user inside the views.xml. Basically I followed the sample by the book. All’s well and it compiles and fires the tomcat. The problem is at the login page where it tells me “Unexpected error. Please contact system administrator”. Looking inside the app log I found that it all stems from the anonymous user login. This is the stacktrace of the exception:

 2018-01-17 16:29:01.834 ERROR [http-nio-8080-exec-3] com.haulmont.cuba.web.AppUI - Unable to init ui
com.haulmont.cuba.security.global.LoginException: Unable to obtain anonymous session
    at com.haulmont.cuba.web.DefaultConnection.loginAnonymous(DefaultConnection.java:65) ~[cuba-web-6.7.8.jar:6.7.8]
    at com.haulmont.cuba.web.AppUI.setupUI(AppUI.java:262) ~[cuba-web-6.7.8.jar:6.7.8]
    at com.haulmont.cuba.web.AppUI.init(AppUI.java:202) ~[cuba-web-6.7.8.jar:6.7.8]
    at com.vaadin.ui.UI.doInit(UI.java:693) [vaadin-server-7.7.13.cuba.0.jar:7.7.13.cuba.0]
    at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222) [vaadin-server-7.7.13.cuba.0.jar:7.7.13.cuba.0]
    at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74) [vaadin-server-7.7.13.cuba.0.jar:7.7.13.cuba.0]
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) [vaadin-server-7.7.13.cuba.0.jar:7.7.13.cuba.0]
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1435) [vaadin-server-7.7.13.cuba.0.jar:7.7.13.cuba.0]
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:361) [vaadin-server-7.7.13.cuba.0.jar:7.7.13.cuba.0]
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:301) [cuba-web-6.7.8.jar:6.7.8]
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:192) [cuba-web-6.7.8.jar:6.7.8]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [servlet-api.jar:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.21]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.21]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.21]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.21]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.21]
    at com.haulmont.cuba.web.sys.CubaHttpFilter.handleNotFiltered(CubaHttpFilter.java:116) [cuba-web-6.7.8.jar:6.7.8]
    at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:103) [cuba-web-6.7.8.jar:6.7.8]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.21]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.21]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.21]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.21]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.21]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.21]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.21]
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) [catalina.jar:8.5.21]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.21]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.21]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) [tomcat-coyote.jar:8.5.21]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.21]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.21]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-coyote.jar:8.5.21]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.21]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_152]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_152]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.21]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_152]

Note: I’m running on Cuba Platform 6.7.8

Hi,

Could you please attach your deploy/tomcat/logs/app.log file?

I am getting the same issue on 6.7.8. Brand new project.

app.log.zip (6.8 KB)

It seems that you have removed anonymous user:

com.haulmont.cuba.security.global.LoginException: Unknown login name or bad password: anonymous

I haven’t removed the anonymous user. I just upgraded to the latest platform version as soon as it was available.
I double checked with the database to make sure the anonymous user record was still there and it was but to no avail. The login error was happening all the same.

I think it’s the same issue as this one: https://youtrack.cuba-platform.com/issue/PL-8950

I’d recommend that you debug the application from this point: com/haulmont/cuba/security/auth/providers/AnonymousAuthenticationProvider.java:61 There you will see the DB query that loads anonymous user. In your case it is not found.

The issue you attached is not related to this because since release 6.7 all the authentication mechanisms have changed.

Problem solved.
I had deleted all the classes and views / screens for the user avatar feature since it was not a must-have for me. Nonetheless I kept a backup in case the problem was solved by the platform devs in the meantime.
Today I restored the backups. I honestly can’t tell what’s different since I haven’t changed anything and now everything works as it should without exceptions.

Another thing I noticed, the breakpoint on

com/haulmont/cuba/security/auth/providers/AnonymousAuthenticationProvider.java:61

was skipped entirely during the login process.

Thanks for your help.

This code is executed only once during server start up, then the anonymous session gets cached, so you should restart the application and connect debugger right after the start of the tomcat instance to enable a breakpoint.

If it still matter, check values of “DTYPE” field of SEC_USER table and if it’s not equal to value of @Entity annotation in your USER extending entity, update it to that.

As i understood when you use @Extends(User.class) it’s pass value of @Entity to DTYPE field of SEC_USER table for query.