Only one tenant works in Multitenant environment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Only one tenant works in Multitenant environment

Deepak Agarwal-2
Hello,

ContextFilter sets the delegator in ServletContext and therefore whichever
tenant gets login first, remains the boss and all of the other tenants gets
that delegator only.

Should delegator, security and authz not be set at session level only?

--
Thanks,
Deepak Agarwal,

Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Pierre Smits
Deepak,

I experience no problem at all with OOTB multi-tenant functionality, exept
regarding following issues:
https://issues.apache.org/jira/browse/OFBIZ-4130
https://issues.apache.org/jira/browse/OFBIZ-5319

Regards

Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Xiangqian Liu
In reply to this post by Deepak Agarwal-2
It also works fine on myside using different tabs in chrome.
2013-12-24 上午3:05于 "Deepak Agarwal" <[hidden email]>写道:

> Hello,
>
> ContextFilter sets the delegator in ServletContext and therefore whichever
> tenant gets login first, remains the boss and all of the other tenants gets
> that delegator only.
>
> Should delegator, security and authz not be set at session level only?
>
> --
> Thanks,
> Deepak Agarwal,
>
> Mobile: +91 9501190044
>
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Deepak Agarwal
Try following steps:
1) Create 2 tenant T1 and T2
2) Map T1 with t1.xyz.com
3) Map T2 with t2.xyz.com
4) Have an entry of t1.xyz.com and t2.xyz.com in your hosts file to point
to your ofbiz instance
5) open t1.xyz.com/webtools
6) Login
7) Now open t2.xyz.com/webtools from either different browser or same
browser
8) It picks up the T1 delegator because it was set in the ServletContext
which is application wide.


On Tue, Dec 24, 2013 at 6:25 AM, Lawrence Liu <[hidden email]> wrote:

> It also works fine on myside using different tabs in chrome.
> 2013-12-24 上午3:05于 "Deepak Agarwal" <[hidden email]>写道:
>
> > Hello,
> >
> > ContextFilter sets the delegator in ServletContext and therefore
> whichever
> > tenant gets login first, remains the boss and all of the other tenants
> gets
> > that delegator only.
> >
> > Should delegator, security and authz not be set at session level only?
> >
> > --
> > Thanks,
> > Deepak Agarwal,
> >
> > Mobile: +91 9501190044
> >
>



--
Thanks,
Deepak Agarwal,

Paxcel Technologies Pvt Ltd.
Hartron Complex, Sector 18, Gurgaon, India.
E-Mail: [hidden email]
Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Pierre Smits
Deepak,

Where does this mapping as described in point 2 and 3 take place in OFBiz?

Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Deepak Agarwal
It's in tenant table
TENANT_ID    TENANT_NAME    DOMAIN_NAME    INITIAL_PATH    DISABLED
-----------------
T1                      T1                     t1.xyz.com


On Tue, Dec 24, 2013 at 2:35 PM, Pierre Smits <[hidden email]>wrote:

> Deepak,
>
> Where does this mapping as described in point 2 and 3 take place in OFBiz?
>
> Pierre Smits
>
> *ORRTIZ.COM <http://www.orrtiz.com>*
> Services & Solutions for Cloud-
> Based Manufacturing, Professional
> Services and Retail & Trade
> http://www.orrtiz.com
>



--
Thanks,
Deepak Agarwal,

Paxcel Technologies Pvt Ltd.
Hartron Complex, Sector 18, Gurgaon, India.
E-Mail: [hidden email]
Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Deepak Agarwal
In reply to this post by Deepak Agarwal
To explain it further, we have one component designed and we call it
controlpanel. By creating multi tenants we are allowing them to use this
component (along with other default components ofbiz provides).
We were assuming that each request gets it's delegator and dispatcher set
from ContextFilter and thereof each tenant was supposed to access it's own
data.  But, this is not what's happening. Once a tenant T1 gets logged in
it sets the delegator default#T1 in the servletContext and since
ServletContext is application wide so delegators keep getting replaced
application wide.



On Tue, Dec 24, 2013 at 12:41 PM, Deepak Agarwal
<[hidden email]>wrote:

> Try following steps:
> 1) Create 2 tenant T1 and T2
> 2) Map T1 with t1.xyz.com
> 3) Map T2 with t2.xyz.com
> 4) Have an entry of t1.xyz.com and t2.xyz.com in your hosts file to point
> to your ofbiz instance
> 5) open t1.xyz.com/webtools
> 6) Login
> 7) Now open t2.xyz.com/webtools from either different browser or same
> browser
> 8) It picks up the T1 delegator because it was set in the ServletContext
> which is application wide.
>
>
> On Tue, Dec 24, 2013 at 6:25 AM, Lawrence Liu <[hidden email]>wrote:
>
>> It also works fine on myside using different tabs in chrome.
>> 2013-12-24 上午3:05于 "Deepak Agarwal" <[hidden email]>写道:
>>
>> > Hello,
>> >
>> > ContextFilter sets the delegator in ServletContext and therefore
>> whichever
>> > tenant gets login first, remains the boss and all of the other tenants
>> gets
>> > that delegator only.
>> >
>> > Should delegator, security and authz not be set at session level only?
>> >
>> > --
>> > Thanks,
>> > Deepak Agarwal,
>> >
>> > Mobile: +91 9501190044
>> >
>>
>
>
>
> --
> Thanks,
> Deepak Agarwal,
>
> Paxcel Technologies Pvt Ltd.
> Hartron Complex, Sector 18, Gurgaon, India.
> E-Mail: [hidden email]
> Mobile: +91 9501190044
>



--
Thanks,
Deepak Agarwal,

Paxcel Technologies Pvt Ltd.
Hartron Complex, Sector 18, Gurgaon, India.
E-Mail: [hidden email]
Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Deepak Agarwal
Correction to point 8. Now, T2 replaces the delegator and T1 gets the
delegator of T2


On Tue, Dec 24, 2013 at 2:43 PM, Deepak Agarwal
<[hidden email]>wrote:

> To explain it further, we have one component designed and we call it
> controlpanel. By creating multi tenants we are allowing them to use this
> component (along with other default components ofbiz provides).
> We were assuming that each request gets it's delegator and dispatcher set
> from ContextFilter and thereof each tenant was supposed to access it's own
> data.  But, this is not what's happening. Once a tenant T1 gets logged in
> it sets the delegator default#T1 in the servletContext and since
> ServletContext is application wide so delegators keep getting replaced
> application wide.
>
>
>
> On Tue, Dec 24, 2013 at 12:41 PM, Deepak Agarwal <
> [hidden email]> wrote:
>
>> Try following steps:
>> 1) Create 2 tenant T1 and T2
>> 2) Map T1 with t1.xyz.com
>> 3) Map T2 with t2.xyz.com
>> 4) Have an entry of t1.xyz.com and t2.xyz.com in your hosts file to
>> point to your ofbiz instance
>> 5) open t1.xyz.com/webtools
>> 6) Login
>> 7) Now open t2.xyz.com/webtools from either different browser or same
>> browser
>> 8) It picks up the T1 delegator because it was set in the ServletContext
>> which is application wide.
>>
>>
>> On Tue, Dec 24, 2013 at 6:25 AM, Lawrence Liu <[hidden email]>wrote:
>>
>>> It also works fine on myside using different tabs in chrome.
>>> 2013-12-24 上午3:05于 "Deepak Agarwal" <[hidden email]>写道:
>>>
>>> > Hello,
>>> >
>>> > ContextFilter sets the delegator in ServletContext and therefore
>>> whichever
>>> > tenant gets login first, remains the boss and all of the other tenants
>>> gets
>>> > that delegator only.
>>> >
>>> > Should delegator, security and authz not be set at session level only?
>>> >
>>> > --
>>> > Thanks,
>>> > Deepak Agarwal,
>>> >
>>> > Mobile: +91 9501190044
>>> >
>>>
>>
>>
>>
>> --
>> Thanks,
>> Deepak Agarwal,
>>
>> Paxcel Technologies Pvt Ltd.
>> Hartron Complex, Sector 18, Gurgaon, India.
>> E-Mail: [hidden email]
>> Mobile: +91 9501190044
>>
>
>
>
> --
> Thanks,
> Deepak Agarwal,
>
> Paxcel Technologies Pvt Ltd.
> Hartron Complex, Sector 18, Gurgaon, India.
> E-Mail: [hidden email]
> Mobile: +91 9501190044
>



--
Thanks,
Deepak Agarwal,

Paxcel Technologies Pvt Ltd.
Hartron Complex, Sector 18, Gurgaon, India.
E-Mail: [hidden email]
Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Pierre Smits
In reply to this post by Deepak Agarwal
Hi Deepak,

Re: tenant table
I know it is there, but up to now we didn't have the requirement to use it
in our ORRTIZ.COM environment for our tenants.

If you feel that this is a broken functionality, please create a JIRA and
maybe any of the other community members can share their insights.

Regards,

Pierre Smits

*ORRTIZ.COM <http://www.orrtiz.com>*
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Mohd Viqar
This post was updated on .
We also faced this problem and the only solution we came up with was to use separate entityDelegatorName in web.xml of the relevant component usually in hot-deploy

E.x /hot-deploy/component1/webapp/component1/WEB-INF/web.xml
 <context-param>
        <param-name>entityDelegatorName</param-name>
        <param-value>abcComponent</param-value>
        <description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
    </context-param>

E.x /hot-deploy/component2/webapp/component2/WEB-INF/web.xml
 <context-param>
        <param-name>entityDelegatorName</param-name>
        <param-value>xyzComponent</param-value>
        <description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
    </context-param>

and then add a definition of these new delegator in entityengine.xml


        <delegator name="abcComponent" 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="localpostnew1"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localpostolap1"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localposttenant"/> 
    </delegator>
        <delegator name="xyzComponent" 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="localpostnew2"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localpostolap2"/>
        <group-map group-name="org.ofbiz.tenant" datasource-name="localposttenant"/> 
    </delegator>

we then have to add datasource definitions

<datasource name="localpostnew1"
        helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
        schema-name="public"
        field-type-name="postnew"
        check-on-start="true"
        add-missing-on-start="true"
        use-fk-initially-deferred="false"
        alias-view-columns="false"
        join-style="ansi"
        result-fetch-size="50"
        use-binary-type-for-blob="true"
        use-order-by-nulls="true">
        <read-data reader-name="tenant"/><read-data reader-name="tenantId1"/><read-data reader-name="tenantId2"/>
        <read-data reader-name="seed"/>
        <read-data reader-name="seed-initial"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <read-data reader-name="ext-test"/>
        <read-data reader-name="ext-demo"/>
        <read-data reader-name="ext-demo"/>
        <inline-jdbc
            jdbc-driver="org.postgresql.Driver"
            jdbc-uri="jdbc:postgresql://127.0.0.1/testdb1"
            jdbc-username="postgres"
            jdbc-password=""
            isolation-level="ReadCommitted"
            pool-minsize="2"
            pool-maxsize="250"
            time-between-eviction-runs-millis="600000"/>
    </datasource>
    <datasource name="localpostolap1"
            helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
            schema-name="public"
            field-type-name="postnew"
            check-on-start="true"
            add-missing-on-start="true"
            use-fk-initially-deferred="false"
            alias-view-columns="false"
            join-style="ansi"
            result-fetch-size="50"
            use-binary-type-for-blob="true"
            use-order-by-nulls="true">
        <read-data reader-name="tenant"/><read-data reader-name="tenantId1"/><read-data reader-name="tenantId2"/>
        <read-data reader-name="seed"/>
        <read-data reader-name="seed-initial"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <read-data reader-name="ext-test"/>
        <read-data reader-name="ext-demo"/>
        <inline-jdbc
                jdbc-driver="org.postgresql.Driver"
                jdbc-uri="jdbc:postgresql://127.0.0.1/testolap1"
                jdbc-username="postgres"
                jdbc-password=""
                isolation-level="ReadCommitted"
                pool-minsize="2"
                pool-maxsize="250"
                time-between-eviction-runs-millis="600000"/>
    </datasource>
Reply | Threaded
Open this post in threaded view
|

Re: Only one tenant works in Multitenant environment

Deepak Agarwal
Even without domain, Could you please try following steps too

1) Have a user login U1 for ofbiz normal data instance and U2 for tenant
data instance.
2) Login with U2 in webtools by providing tenant id and logout (or remain
there)
3) Now you can not login with U1. because now the application is pointing
to tenant database. You will have to restart the ofbiz.


On Tue, Dec 24, 2013 at 6:02 PM, mohd Viqar <[hidden email]> wrote:

> We also faced this problem and the only solution we comeup with was to use
> separate entityDelegatorName in web.xml of the relevant componet usually in
> hot-deploy
>  <context-param>
>         <param-name>entityDelegatorName</param-name>
>         <param-value>abcComponent</param-value>
>         <description>The Name of the Entity Delegator to use, defined in
> entityengine.xml</description>
>     </context-param>
>
>
> and then add a definition of this delegator in entityengine.xml
>
>
>         <delegator name="abcComponent" 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="localpostnew"/>
>         <group-map group-name="org.ofbiz.olap"
> datasource-name="localpostolap"/>
>         <group-map group-name="org.ofbiz.tenant"
> datasource-name="localposttenant"/>
>     </delegator>
>
>
>
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/Only-one-tenant-works-in-Multitenant-environment-tp4646505p4646520.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>



--
Thanks,
Deepak Agarwal,

Paxcel Technologies Pvt Ltd.
Hartron Complex, Sector 18, Gurgaon, India.
E-Mail: [hidden email]
Mobile: +91 9501190044