Want to add phone field to TenantUser.class

I want to add phone field to User.class
I’m using multitenancy-addon. When i start the project i’m getting error

20:28:34.515 ERROR c.h.c.c.s.AbstractWebAppContextLoader   - Error initializing application
java.lang.RuntimeException: Unable to create anonymous session. It is required for system to start
	at com.haulmont.cuba.security.auth.AnonymousSessionHolder.initializeAnonymousSession(AnonymousSessionHolder.java:77) ~[cuba-core-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.security.auth.AnonymousSessionHolder.applicationStarted(AnonymousSessionHolder.java:45) ~[cuba-core-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.core.sys.AppContext.startContext(AppContext.java:239) ~[cuba-global-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.core.sys.AppContext$Internals.startContext(AppContext.java:302) ~[cuba-global-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextInitialized(AbstractWebAppContextLoader.java:86) ~[cuba-global-7.1.1.jar:7.1.1]
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4682) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695) ~[catalina.jar:9.0.19]
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1133) ~[catalina.jar:9.0.19]
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1867) ~[catalina.jar:9.0.19]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-util.jar:9.0.19]
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118) ~[na:na]
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1045) ~[catalina.jar:9.0.19]
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:429) ~[catalina.jar:9.0.19]
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576) ~[catalina.jar:9.0.19]
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367) ~[catalina.jar:9.0.19]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-util.jar:9.0.19]
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.19]
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) ~[catalina.jar:9.0.19]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[catalina.jar:9.0.19]
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633) ~[catalina.jar:9.0.19]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350) ~[bootstrap.jar:9.0.19]
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492) ~[bootstrap.jar:9.0.19]
Caused by: com.haulmont.cuba.security.global.LoginException: Неверный логин или пароль 'anonymous'
	at com.haulmont.cuba.security.auth.providers.AnonymousAuthenticationProvider.authenticate(AnonymousAuthenticationProvider.java:63) ~[cuba-core-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.security.auth.AuthenticationManagerBean.authenticateInternal(AuthenticationManagerBean.java:252) ~[cuba-core-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.security.auth.AuthenticationManagerBean.login(AuthenticationManagerBean.java:117) ~[cuba-core-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.security.auth.AnonymousSessionHolder.loginAnonymous(AnonymousSessionHolder.java:82) ~[cuba-core-7.1.1.jar:7.1.1]
	at com.haulmont.cuba.security.auth.AnonymousSessionHolder.initializeAnonymousSession(AnonymousSessionHolder.java:72) ~[cuba-core-7.1.1.jar:7.1.1]
	... 45 common frames omitted

My ExtTenantUser code is here:

@DiscriminatorValue("EXT")
@Extends(TenantUser.class)
@NamePattern("#getCaption|login,name,tenantId")
@Entity(name = "recruit_ExtTenantUser")
public class ExtTenantUser extends TenantUser {
    private static final long serialVersionUID = -4854677216794376085L;

    @Column(name = "PHONE")
    protected String phone;

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}

it worked on 7.0.11 version of cuba. But i started new project on 7.1. Now i’m getting this error.
Can you advice me, what i’m doing wrong.

Thanks
Nurmuhammad

Hello @nurmuhammad.abdurashidov,

Look for a value in the column DTYPE in the table SEC_USER. If the column contains the value recruit_ExtTenantUser, then remove the annotation @DiscriminatorValue("EXT").

Or you can save the annotation, but you need to update the column DTYPE to the value EXT.

Regards,
Nikita

Hi,
Thanks for your response Nikita @shchienko ,
It worked now, after changing all DTYPE column to ‘EXT’ in SEC_USER table.

Thanks,
Nurmuhammad