Multitenancy add-on problem with MySQL

I created a new project to test the Multitenancy add-on

tenantDemo.zip (78.6 KB)

tenantDemo 20181031 1355.sql.txt (52.9 KB)

I added com.haulmont.addon.sdbmt: sdbmt-global: 1.2.0 in custom components

using hsqldb there are no problems.

instead, using MySql I have this error

13:37:12.128 INFO  c.h.cuba.core.sys.MetadataImpl          - Initializing metadata
13:37:12.237 INFO  c.h.cuba.core.sys.MetadataImpl          - Metadata initialized in 109 ms
13:37:12.519 INFO  c.h.c.c.sys.dbupdate.DbUpdaterEngine    - Updating database...
13:37:12.675 INFO  c.h.c.c.sys.dbupdate.DbUpdaterEngine    - Database is up-to-date
13:37:13.128 INFO  c.h.cuba.core.app.ConfigStorage         - Loading DB-stored app properties cache
13:37:13.534 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-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.security.auth.AnonymousSessionHolder.applicationStarted(AnonymousSessionHolder.java:45) ~[cuba-core-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.core.sys.AppContext.startContext(AppContext.java:239) ~[cuba-global-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.core.sys.AppContext$Internals.startContext(AppContext.java:302) ~[cuba-global-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextInitialized(AbstractWebAppContextLoader.java:85) ~[cuba-global-6.10.2.jar:6.10.2]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792) [catalina.jar:8.5.33]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256) [catalina.jar:8.5.33]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.33]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) [catalina.jar:8.5.33]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) [catalina.jar:8.5.33]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.33]
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1140) [catalina.jar:8.5.33]
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875) [catalina.jar:8.5.33]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_111]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
Caused by: com.haulmont.cuba.security.global.InternalAuthenticationException: Exception is thrown by authentication provider
        at com.haulmont.cuba.security.auth.AuthenticationManagerBean.authenticateInternal(AuthenticationManagerBean.java:277) ~[cuba-core-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.security.auth.AuthenticationManagerBean.login(AuthenticationManagerBean.java:118) ~[cuba-core-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.security.auth.AnonymousSessionHolder.loginAnonymous(AnonymousSessionHolder.java:82) ~[cuba-core-6.10.2.jar:6.10.2]
        at com.haulmont.cuba.security.auth.AnonymousSessionHolder.initializeAnonymousSession(AnonymousSessionHolder.java:72) ~[cuba-core-6.10.2.jar:6.10.2]
        ... 17 common frames omitted
13:37:13.550 INFO  c.h.c.c.s.CubaCoreApplicationContext    - Closing com.haulmont.cuba.core.sys.CubaCoreApplicationContext@4530e4ff: startup date [Wed Oct 31 13:37:06 CET 2018]; root of context hierarchy
13:37:13.550 INFO  c.h.c.c.s.CubaThreadPoolTaskScheduler   - Shutting down ExecutorService 'scheduler'
ott 31, 2018 1:37:13 PM org.apache.catalina.core.StandardContext startInternal
GRAVE: One or more listeners failed to start. Full details will be found in the appropriate container log file
ott 31, 2018 1:37:13 PM org.apache.catalina.core.StandardContext startInternal
GRAVE: Context [/app-core] startup failed due to previous errors
ott 31, 2018 1:37:13 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
AVVERTENZA: The web application [app-core] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.util.TimerThread.mainLoop(Timer.java:552)
 java.util.TimerThread.run(Timer.java:505)
ott 31, 2018 1:37:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMAZIONI: Deployment of web application directory [C:\Users\Mauro\studio-projects\tenantDemo\deploy\tomcat\webapps\app-core] has finished in [7,498] ms
ott 31, 2018 1:37:13 PM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["http-nio-8080"]
ott 31, 2018 1:37:13 PM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["ajp-nio-8009"]
ott 31, 2018 1:37:13 PM org.apache.catalina.startup.Catalina start
INFORMAZIONI: Server startup in 16061 ms
ott 31, 2018 1:37:42 PM org.apache.catalina.loader.WebappClassLoaderBase checkStateForResourceLoading
INFORMAZIONI: Illegal access: this web application instance has been stopped already. Could not load [com.haulmont.cuba.core.sys.persistence.MysqlDbTypeConverter]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [com.haulmont.cuba.core.sys.persistence.MysqlDbTypeConverter]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1329)
        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1317)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1176)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137)
        at com.haulmont.bali.util.ReflectionHelper.loadClass(ReflectionHelper.java:62)
        at com.haulmont.cuba.core.sys.persistence.DbmsSpecificFactory.create(DbmsSpecificFactory.java:76)
        at com.haulmont.cuba.core.sys.persistence.DbmsSpecificFactory.create(DbmsSpecificFactory.java:66)
        at com.haulmont.cuba.core.sys.persistence.DbmsSpecificFactory.getDbTypeConverter(DbmsSpecificFactory.java:54)
        at com.haulmont.cuba.core.sys.PersistenceImpl.getDbTypeConverter(PersistenceImpl.java:96)
        at com.haulmont.cuba.core.app.ServerInfo.updateCurrentServer(ServerInfo.java:170)
        at com.haulmont.cuba.core.app.ServerInfo$1.run(ServerInfo.java:130)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)

Hi,

which values are in DTYPE column in SEC_GROUP and SEC_USER tables in your application?

Hi,

I checked the values… :thinking::fearful:

Changing database in Mysql I noticed that the columns DTYPE and TENANT_ID are not created.
Creation scripts are not the same.
I proceeded manually but I’m not sure I did the right thing.
Here are the differences between hsql and mysql

Cattura1

Cattura2

and in MySql these inserts are not added.

Cattura3