Something super weird happened: I can't find the guest user!

154 views
Skip to first unread message

Tashrif

unread,
Jan 15, 2024, 6:59:42 PMJan 15
to xnat_discussion
After deleting the guest user from Postgres backend, I am unable to restart XNAT. It produces these errors. Can someone please help me restore from this situation?


[root@hcpep-xnat logs]# vim localhost.2024-01-15.log
Jan 15, 2024 6:49:21 PM org.apache.catalina.core.ApplicationContext log
INFO: 1 Spring WebApplicationInitializers detected on classpath
Jan 15, 2024 6:49:22 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jan 15, 2024 6:50:40 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Jan 15, 2024 6:50:47 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [turbine] in context with path [] threw exception
org.nrg.framework.exceptions.NrgServiceRuntimeException: Error [Unknown]: Error [Unknown]: Something super weird happened: I can't find the guest user!
        at org.nrg.xdat.XDAT.getUserDetails(XDAT.java:210)
        at org.nrg.xnat.security.XnatExpiredPasswordFilter.doFilter(XnatExpiredPasswordFilter.java:66)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:157)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)

Rick Herrick

unread,
Jan 16, 2024, 12:19:44 PMJan 16
to xnat_di...@googlegroups.com

You need to restore your database or at least the xdat_user table. You should never delete users from that table, as the ID from that table is referenced in other tables through the database schema. If you need to remove a user’s access to your XNAT installation, you should disable the user account from the Manage Users page.

 

XNAT is fairly old and doesn’t have an idea of an anonymous user, so the guest account is used as a stand-in for anonymous access. That’s accessed pretty early on during start-up so that’s why XNAT is unable to start without that user entry being available.

 

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of Tashrif <tashri...@gmail.com>
Date: Monday, January 15, 2024 at 6:01
PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: External: [XNAT Discussion] Something super weird happened: I can't find the guest user!

You don't often get email from tashri...@gmail.com. Learn why this is important

This message comes from an external organization. Be cautious of attachments you are not expecting and wary of embedded links.

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/8a7850f8-ead2-498e-9d97-4b18f451620fn%40googlegroups.com.

Tashrif

unread,
Jan 16, 2024, 4:58:27 PMJan 16
to xnat_discussion
Hi Rick, there is no way to restore. Can you tell me how I can create a guest user now and associate with xdat_user table?

(Sorry I missed the notification of this email before)

Best,
Tashrif

Rick Herrick

unread,
Jan 16, 2024, 6:19:34 PMJan 16
to xnat_di...@googlegroups.com

Okay, you’ve run into the XNAT Prime Directive (or, if you like, the First Rule of XNAT Development Club): never ever modify the database without first dumping it so that you can restore it if you mess something up. Any time you’re planning on messing with the contents of the database directly, you should:

 

  1. Stop Tomcat
  2. Dump the database: pg_dump --hostname=xxx --username=xxx > xnat.sql
  3. Mess with database
  4. Start Tomcat

 

This way if something breaks you can restore to a known working point:

 

  1. Stop Tomcat
  2. Drop the database:* dropdb xnat
  3. Recreate the database: createdb --owner=xnat
  4. Restore from your backup: psql --hostname=xxx --username=xxx --file=xnat.sql
  5. Start Tomcat

 

As far as restoring the guest user, that’s easy enough:

 

INSERT INTO public.xdat_user (login, firstname, lastname, email, primary_password, primary_password_encrypt, quarantine_path, enabled, verified, salt, user_info, xdat_user_id, users_user_xdat_security_xdat_security_id)
VALUES ('guest', 'XNAT', 'Guest', '<email>', 'guest', 1, null, 1, 1, null, 2, 2, 1);

 

If you deleted other users, that’s not something anyone can help you with. You can try recreating with a query similar to the one above, but you’ll need the value for xdat_user_id and it’s difficult to know what that may have been without digging around in other places. Your best bets would be to look at xhbm_xdat_user_auth, which includes the user’s login name, so you can get the last time the user logged in successfully:

 

xnat=> SELECT last_successful_login FROM xhbm_xdat_user_auth WHERE xdat_username = 'xxx';

  last_successful_login

-------------------------

2024-01-03 13:53:42.785

(1 row)

 

You can use that to try to get the xdat_user_id from xdat_user_login:

 

xnat=> SELECT user_xdat_user_id

FROM xdat_user_login

WHERE login_date > '2024-01-03 13:53:42.785000'::timestamp - interval '2 seconds'

  AND login_date < '2024-01-03 13:53:42.785000'::timestamp + interval '2 seconds';

user_xdat_user_id

-------------------

                10

(1 row)

 

With that, you should be able to recreate the xdat_user row for the user with the correct xdat_user_id value.

 

* If you can’t drop the database, you can run a query to drop the schemas in the database:

 

DROP SCHEMA IF EXISTS public CASCADE;

DROP SCHEMA IF EXISTS xdat_search CASCADE;

 

CREATE SCHEMA public;

 

GRANT ALL ON SCHEMA public TO postgres;

GRANT ALL ON SCHEMA public TO xnat;

 

You won’t need to run createdb if you do it this way, just restore from your dump file.

 

Tashrif

unread,
Jan 17, 2024, 10:45:30 PMJan 17
to xnat_discussion
Thank you very much Rick, just this solved our issue:

INSERT INTO public.xdat_user (login, firstname, lastname, email, primary_password, primary_password_encrypt, quarantine_path, enabled, verified, salt, user_info, xdat_user_id, users_user_xdat_security_xdat_security_id)
VALUES ('guest', 'XNAT', 'Guest', '<email>', 'guest', 1, null, 1, 1, null, 2, 2, 1);

Best,
Tashrif

Tashrif

unread,
Mar 27, 2024, 3:20:53 PMMar 27
to xnat_discussion
Hi Rick Herrick,

I am getting this error email for the last two months. Could you comment what is wrong? Is it related to my unwarranted user deletion?

======

XSync Failed for project Project.

Daily sync failed

Encountered error Invalid Login and/or Passwordorg.nrg.xdat.security.user.exceptions.UserNotFoundException: Invalid Login and/or Password at org.nrg.xdat.security.XDATUser.(XDATUser.java:101) at org.nrg.xdat.security.XDATUserMgmtServiceImpl.getUser(XDATUserMgmtServiceImpl.java:66) at org.nrg.xdat.security.helpers.Users.getUser(Users.java:140) at org.nrg.xsync.services.local.impl.DefaultDailySyncService.syncDaily(DefaultDailySyncService.java:62) at org.nrg.xsync.services.local.impl.DailySync.run(DailySync.java:17) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750)
======

How can I resolve this?

Best,
Tashrif

Tashrif

unread,
Apr 11, 2024, 11:37:25 AMApr 11
to xnat_discussion
Hi Rick, we still need your help. Can you please see my latest issue?

> Hi Rick Herrick,
>
> I am getting this error email for the last two months. Could you comment what is wrong? Is it related to my unwarranted user deletion?


Reply all
Reply to author
Forward
0 new messages