Exception when using an non existence Tenant ID


#1

When the multi tenant is enabled, if the user key in an non existence Tenant ID, the following exception would be thrown,

ERROR rendering error page [/control/error], but here is the error text: org.ofbiz.widget.renderer.ScreenRenderException: Error rendering screen [component://commonext/widget/CommonScreens.xml#ApplicationDecorator]: java.lang.IllegalArgumentException: Error doing entity query by condition: org.ofbiz.base.util.GeneralException: Error finding entity value by primary key with entity-one: org.ofbiz.entity.GenericEntityException: org.ofbiz.entity.GenericDataSourceException: Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool) (Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool)) (org.ofbiz.entity.GenericDataSourceException: Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool) (Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool))) (Error doing entity query by condition: org.ofbiz.base.util.GeneralException: Error finding entity value by primary key with entity-one: org.ofbiz.entity.GenericEntityException: org.ofbiz.entity.GenericDataSourceException: Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool) (Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool)) (org.ofbiz.entity.GenericDataSourceException: Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool) (Unable to esablish a connection with the database. (Unable to acquire a new connection from the pool))))


#2

Taken from the error you are posting, it seems as if the database connection is causing the error. Just to be sure, before we dig any deeper: have you checked your db configuration if tenancy is setup correctly?

Go to framework/entity/config/entityengine.xml and check for

    <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
    <group-map group-name="org.ofbiz" datasource-name="localderby"/>
    <group-map group-name="org.ofbiz.olap" datasource-name="localderbyolap"/>
    <group-map group-name="org.ofbiz.tenant" datasource-name="localderbytenant"/>
</delegator>

The group-map group-name=“org.ofbiz.tenant” is the one that is being of interest here (including the datasource configuration you added later in the same file).


#3

[INFO]|2016-07-18 18:16:03,706 |delegator-startup-10 |DelegatorFactoryImpl |I| Creating new delegator [default#DEMO2] (delegator-startup-10)
[INFO]|2016-07-18 18:16:03,708 |delegator-startup-10 |GenericDelegator |I| Doing entity definition check…
[INFO]|2016-07-18 18:16:03,708 |delegator-startup-10 |ModelEntityChecker |I| [initReservedWords] array length = 1025
[INFO]|2016-07-18 18:16:03,725 |OFBiz-batch-5 |GenericDelegator |I| Can’t access entity of entityGroup = org.ofbiz.tenant using tenant delegator default#DEMO2, use base delegator instead
[INFO]|2016-07-18 18:16:03,725 |OFBiz-batch-5 |GenericDelegator |I| Delegator “default#DEMO2” NOT initializing helper for entity group “org.ofbiz.tenant” because the group is not associated to this delegator.
[INFO]|2016-07-18 18:16:03,726 |OFBiz-batch-6 |GenericDelegator |I| Delegator “default#DEMO2” initializing helper “localpostgres” for entity group “org.ofbiz”.
[INFO]|2016-07-18 18:16:03,726 |OFBiz-batch-6 |GenericDelegator |I| Doing database check as requested in entityengine.xml with addMissing=true
[ERROR]|2016-07-18 18:16:03,729 |OFBiz-batch-6 |DatabaseUtil |E| Unable to establish a connection with the database for helperName [localpostgres#DEMO2]… Error was: java.sql.SQLException: Unable to acquire a new connection from the pool
[ERROR]|2016-07-18 18:16:03,729 |OFBiz-batch-6 |DatabaseUtil |E| Unable to establish a connection with the database, no additional information available.
[ERROR]|2016-07-18 18:16:03,729 |OFBiz-batch-6 |DatabaseUtil |E| Could not get table name information from the database, aborting.


#4

DEMO2 tenant ID was an non existence ID. It is trying to use that as a delegator, and got stuck in there.


#5

Derek, I am assuming that your error isstill existent then, is that correct?

If so, then it would be great if you could provide us with further information on how to reproduce the error.


#6

Hi

You can enable multi-tenant, and use “create-tenant” to create DEMO1, and after login successfully into DEMO1, logout and try, using DEMO2 (non existence), and you get that error,


#7

Alright, sounds like an problem with the Demo Seed Data then. I will notify the others to take a look at this. Thanks for reporting the issue.


#8

i didn’t modify the TenantDemoData.xml file, and I am using Postgresql instead of derby.


#9

On second thought though: can you send us a screenshot of the error you get?

Because the error itself is somewhat correct, considering that the tenant is non-existent at that point.


#10

I am not allowed to upload images.


#11

That is odd - what’s the file type you are trying to upload? We accept png, jpeg/jpg & gif.


#12

It prompts me “Sorry, new users can not upload images.”


#13

Changed the settings. Give it another try please


#14

So we checked the data again (by loading it into a fresh derby database) and we cannot reproduce your error. So this gives me reason to believe that my initial thought of your problem being database related may be correct.

My assumption is that each tenant may use up some of your connections, so I would ask you to increase your postgres connection pool on the database side (try doubling the poolsize for now). I think that should fix your problem.

Otherwise you will have to check your max-poolsize within the entityengine.xml for your postnewtenant config.


#15

Ok, can you try this, going to get different error.

  1. Enable Multi-tenant, and using the default derby database
  2. Run install.bat, selecting the first option
  3. Run start.bat
  4. Login using admin/scipio/DEMO3, DEMO3 is an non existence tenant ID.

#16

Hi Derek,

okay, i was able to reproduce. Looks like the error isn’t caught correctly. I am forwarding this internally, so that we can come up with a solution.


#17

We developed a bugfix, that we are going to push to our repository later today. There are still some errors remaining in the logs, which can be ignored for now. The reason is that there are some underlying issues with the delegator generation for non-existent tenants. There are no further effects that come from this, however and we may work on this some more in the future.

The bugfix itself allows the error to be correctly passed to the screen & also fixes the login forms, so this should fix the issue for you :slight_smile:


#18

Thank you! That’s fast!


#19

The Scipio git repo has been updated with the aforementioned changes.