Re: [Dev] JNDI lookup wont work inside a web-app
Hi all, Is someone working on this issue? We need to fix it ASAP. We might patch the 4.0.3 kernel and use it with this fix. thanks, dimuthu On Tue, Sep 11, 2012 at 11:03 AM, Dimuthu Leelarathne dimut...@wso2.comwrote: Hi all, We need this for 4.0.2 at least. Are we progressing on this? Is someone working on this? thanks, dimuthu On Tue, Jul 10, 2012 at 10:34 PM, Pradeep Fernando prad...@wso2.comwrote: Hi, I'm afraid we cant assign a person on this task from the kernel team at this point, (full time). Of course we are happy to provide any help needed. :) --Pradeep ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
This also a real blocker for AS, as we discussed during the planning meeting we must find a solution for this issue before next AS release. For the moment AS team means only myself and I'm planning to work on Classloading issue on AS because it's the No- 1 blocker for the AS if something will not come in my way I can look into JNDI issue after solving Classloading issues but I can't commit for any specific time-line. We don't have any other option within AS team it would be great if someone from platform can look into this issue because this is a blocker for AS, DS, GS and API manager products. Thanks ! On Wed, Nov 14, 2012 at 12:31 PM, Dimuthu Leelarathne dimut...@wso2.com wrote: Hi all, Is someone working on this issue? We need to fix it ASAP. We might patch the 4.0.3 kernel and use it with this fix. thanks, dimuthu On Tue, Sep 11, 2012 at 11:03 AM, Dimuthu Leelarathne dimut...@wso2.com wrote: Hi all, We need this for 4.0.2 at least. Are we progressing on this? Is someone working on this? thanks, dimuthu On Tue, Jul 10, 2012 at 10:34 PM, Pradeep Fernando prad...@wso2.com wrote: Hi, I'm afraid we cant assign a person on this task from the kernel team at this point, (full time). Of course we are happy to provide any help needed. :) --Pradeep ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Sagara Gunathunga Technical Lead; WSO2, Inc.; http://wso2.com V.P Apache Web Services ; http://ws.apache.org/ Blog ; http://ssagara.blogspot.com ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
Hi all, We need this for 4.0.2 at least. Are we progressing on this? Is someone working on this? thanks, dimuthu On Tue, Jul 10, 2012 at 10:34 PM, Pradeep Fernando prad...@wso2.com wrote: Hi, I'm afraid we cant assign a person on this task from the kernel team at this point, (full time). Of course we are happy to provide any help needed. :) --Pradeep ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
Hi Senaka, We had a meeting today in finding a possible solution to looking up the JNDI resources that is registered from Carbon. So we are registering our own provider to provide the multitenant support, by creating sub-contexts for each tenant. So we would like to know if this implementation can be used somehow in registering the JNDI resources that would be visible by other web apps, and what implications there would possibly be with any changes to the current implementation. And the AS or the Carbon Kernel team please take ownership of this, since the internal workings Tomcat / Carbon Kernel will be required to provide a solution quickly in order to ship with the current C4 release. Cheers, Anjana. On Mon, Jul 9, 2012 at 5:11 PM, Isuru Suriarachchi is...@wso2.com wrote: As Kishanthan has explained in his last reply, this is not something broken and this is how Tomcat is supposed to work. Therefore, I think we have to have a meeting on this and decide what to do. Thanks, ~Isuru On Fri, Jul 6, 2012 at 11:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan/ AS Team, Today App-factory team raised this issue again and they also need to have same requirement. (The capability of accessing resources( inside a wep-app) that registered with JNDI via carbon component using default InitialContext of carbon ). We need to discuss and come-up with a solution for this. Regards, Dinusha. On Thu, May 31, 2012 at 3:51 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Wed, May 30, 2012 at 1:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Here, what we want is to use the same transaction-manager that has expose by the transaction-manager component inside the web-app. But by defining it as a resource in server.xml or context.xml , it register a new transaction manager to use in wep-app rather using it from transaction-manager component. So we loss the need of having transaction-manager carbon component. AFAIK, in previous releases, these resources (TransactionManager, etc) are registered with tomcat via the context descriptor file (CARBON_HOME/lib/tomcat/conf/context.xml). But according to the current implementation in trunk, we are registering those resources to Carbon's InitialContext via a carbon component (transaction-manager) and we want those resources to be accessible everywhere including webapps also. This is the requirement. But as I said earlier, this will not work as we can see that we are trying to access a resource which is not registered with tomcat. So I think the solution for this would be, when registering the resource via carbon, we have to somehow make those available to tomcat global resources. Kishanthan. Regards, Dinusha. On Tue, May 29, 2012 at 11:36 AM, Isuru Suriarachchi is...@wso2.comwrote: According to this, all our global resources can be registered in the tomcat server.xml and can be looked up from anywhere. So we can make the above resources work by doing this. But if we want to allow users to register and look up resources through the carbon context, we have to register those resources in the same context as the server.xml resources. Then only those can be made global. Thanks, ~Isuru On Tue, May 29, 2012 at 10:44 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah
Re: [Dev] JNDI lookup wont work inside a web-app
Hi, I'm afraid we cant assign a person on this task from the kernel team at this point, (full time). Of course we are happy to provide any help needed. :) --Pradeep ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
As Kishanthan has explained in his last reply, this is not something broken and this is how Tomcat is supposed to work. Therefore, I think we have to have a meeting on this and decide what to do. Thanks, ~Isuru On Fri, Jul 6, 2012 at 11:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan/ AS Team, Today App-factory team raised this issue again and they also need to have same requirement. (The capability of accessing resources( inside a wep-app) that registered with JNDI via carbon component using default InitialContext of carbon ). We need to discuss and come-up with a solution for this. Regards, Dinusha. On Thu, May 31, 2012 at 3:51 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Wed, May 30, 2012 at 1:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Here, what we want is to use the same transaction-manager that has expose by the transaction-manager component inside the web-app. But by defining it as a resource in server.xml or context.xml , it register a new transaction manager to use in wep-app rather using it from transaction-manager component. So we loss the need of having transaction-manager carbon component. AFAIK, in previous releases, these resources (TransactionManager, etc) are registered with tomcat via the context descriptor file (CARBON_HOME/lib/tomcat/conf/context.xml). But according to the current implementation in trunk, we are registering those resources to Carbon's InitialContext via a carbon component (transaction-manager) and we want those resources to be accessible everywhere including webapps also. This is the requirement. But as I said earlier, this will not work as we can see that we are trying to access a resource which is not registered with tomcat. So I think the solution for this would be, when registering the resource via carbon, we have to somehow make those available to tomcat global resources. Kishanthan. Regards, Dinusha. On Tue, May 29, 2012 at 11:36 AM, Isuru Suriarachchi is...@wso2.comwrote: According to this, all our global resources can be registered in the tomcat server.xml and can be looked up from anywhere. So we can make the above resources work by doing this. But if we want to allow users to register and look up resources through the carbon context, we have to register those resources in the same context as the server.xml resources. Then only those can be made global. Thanks, ~Isuru On Tue, May 29, 2012 at 10:44 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.comwrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.comwrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. I will have a look at this and provide an update. Created a jira to track this [1].
Re: [Dev] JNDI lookup wont work inside a web-app
Hi, In the case of appfactory this feature is urgent need as we planed initially to take only web app the as application to be managed by appfactory. Thanks. On Fri, Jul 6, 2012 at 11:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan/ AS Team, Today App-factory team raised this issue again and they also need to have same requirement. (The capability of accessing resources( inside a wep-app) that registered with JNDI via carbon component using default InitialContext of carbon ). We need to discuss and come-up with a solution for this. Regards, Dinusha. On Thu, May 31, 2012 at 3:51 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Wed, May 30, 2012 at 1:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Here, what we want is to use the same transaction-manager that has expose by the transaction-manager component inside the web-app. But by defining it as a resource in server.xml or context.xml , it register a new transaction manager to use in wep-app rather using it from transaction-manager component. So we loss the need of having transaction-manager carbon component. AFAIK, in previous releases, these resources (TransactionManager, etc) are registered with tomcat via the context descriptor file (CARBON_HOME/lib/tomcat/conf/context.xml). But according to the current implementation in trunk, we are registering those resources to Carbon's InitialContext via a carbon component (transaction-manager) and we want those resources to be accessible everywhere including webapps also. This is the requirement. But as I said earlier, this will not work as we can see that we are trying to access a resource which is not registered with tomcat. So I think the solution for this would be, when registering the resource via carbon, we have to somehow make those available to tomcat global resources. Kishanthan. Regards, Dinusha. On Tue, May 29, 2012 at 11:36 AM, Isuru Suriarachchi is...@wso2.comwrote: According to this, all our global resources can be registered in the tomcat server.xml and can be looked up from anywhere. So we can make the above resources work by doing this. But if we want to allow users to register and look up resources through the carbon context, we have to register those resources in the same context as the server.xml resources. Then only those can be made global. Thanks, ~Isuru On Tue, May 29, 2012 at 10:44 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.comwrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.comwrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. I will have a look at this and provide an update. Created a jira to track this [1]. Kishanthan. [1]
Re: [Dev] JNDI lookup wont work inside a web-app
Hi Kishanthan/ AS Team, Today App-factory team raised this issue again and they also need to have same requirement. (The capability of accessing resources( inside a wep-app) that registered with JNDI via carbon component using default InitialContext of carbon ). We need to discuss and come-up with a solution for this. Regards, Dinusha. On Thu, May 31, 2012 at 3:51 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Wed, May 30, 2012 at 1:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Here, what we want is to use the same transaction-manager that has expose by the transaction-manager component inside the web-app. But by defining it as a resource in server.xml or context.xml , it register a new transaction manager to use in wep-app rather using it from transaction-manager component. So we loss the need of having transaction-manager carbon component. AFAIK, in previous releases, these resources (TransactionManager, etc) are registered with tomcat via the context descriptor file (CARBON_HOME/lib/tomcat/conf/context.xml). But according to the current implementation in trunk, we are registering those resources to Carbon's InitialContext via a carbon component (transaction-manager) and we want those resources to be accessible everywhere including webapps also. This is the requirement. But as I said earlier, this will not work as we can see that we are trying to access a resource which is not registered with tomcat. So I think the solution for this would be, when registering the resource via carbon, we have to somehow make those available to tomcat global resources. Kishanthan. Regards, Dinusha. On Tue, May 29, 2012 at 11:36 AM, Isuru Suriarachchi is...@wso2.comwrote: According to this, all our global resources can be registered in the tomcat server.xml and can be looked up from anywhere. So we can make the above resources work by doing this. But if we want to allow users to register and look up resources through the carbon context, we have to register those resources in the same context as the server.xml resources. Then only those can be made global. Thanks, ~Isuru On Tue, May 29, 2012 at 10:44 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.comwrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.comwrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. I will have a look at this and provide an update. Created a jira to track this [1]. Kishanthan. [1] https://wso2.org/jira/browse/CARBON-13277 Thanks, ~Isuru Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get
Re: [Dev] JNDI lookup wont work inside a web-app
On Wed, May 30, 2012 at 1:44 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Here, what we want is to use the same transaction-manager that has expose by the transaction-manager component inside the web-app. But by defining it as a resource in server.xml or context.xml , it register a new transaction manager to use in wep-app rather using it from transaction-manager component. So we loss the need of having transaction-manager carbon component. AFAIK, in previous releases, these resources (TransactionManager, etc) are registered with tomcat via the context descriptor file (CARBON_HOME/lib/tomcat/conf/context.xml). But according to the current implementation in trunk, we are registering those resources to Carbon's InitialContext via a carbon component (transaction-manager) and we want those resources to be accessible everywhere including webapps also. This is the requirement. But as I said earlier, this will not work as we can see that we are trying to access a resource which is not registered with tomcat. So I think the solution for this would be, when registering the resource via carbon, we have to somehow make those available to tomcat global resources. Kishanthan. Regards, Dinusha. On Tue, May 29, 2012 at 11:36 AM, Isuru Suriarachchi is...@wso2.comwrote: According to this, all our global resources can be registered in the tomcat server.xml and can be looked up from anywhere. So we can make the above resources work by doing this. But if we want to allow users to register and look up resources through the carbon context, we have to register those resources in the same context as the server.xml resources. Then only those can be made global. Thanks, ~Isuru On Tue, May 29, 2012 at 10:44 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.comwrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.com wrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. I will have a look at this and provide an update. Created a jira to track this [1]. Kishanthan. [1] https://wso2.org/jira/browse/CARBON-13277 Thanks, ~Isuru Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far.
Re: [Dev] JNDI lookup wont work inside a web-app
According to this, all our global resources can be registered in the tomcat server.xml and can be looked up from anywhere. So we can make the above resources work by doing this. But if we want to allow users to register and look up resources through the carbon context, we have to register those resources in the same context as the server.xml resources. Then only those can be made global. Thanks, ~Isuru On Tue, May 29, 2012 at 10:44 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.comwrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.com wrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. I will have a look at this and provide an update. Created a jira to track this [1]. Kishanthan. [1] https://wso2.org/jira/browse/CARBON-13277 Thanks, ~Isuru Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan
Re: [Dev] JNDI lookup wont work inside a web-app
Hi Folks I had the same issue while invoking EJB services using IntialContext as follows *jndiName=ejb:/EJBDemo/ShoppingCartBean!org.ejb.wso2.test.ShoppingCart?stateful fails to load shema ((ejb:))* but this worked well with my client application and after debug I found due * if (NamingManager.hasInitialContextFactoryBuilder()) {* *return getDefaultInitCtx();* * } * where its loading carbon specific intial context (as i think) and its overriding of JNDIContext and due to this it fails to load in a default way and as a work around I have written extended initial context override getURLOrDefaultInitCtx as follows thus it started work fine !. May be this is the same error we may talking in this mail thread so we may have to come up with proper idea to handle this sort of issues work around which works well for me /* (non-Javadoc) * @see javax.naming.InitialContext#getURLOrDefaultInitCtx(java.lang.String) */ @Override protected Context getURLOrDefaultInitCtx(String name) throws NamingException { String scheme = getURLScheme(name); if (scheme != null) { Context ctx = NamingManager.getURLContext(scheme, myProps); if (ctx != null) { return ctx; } } return getDefaultInitCtx(); } cheers Dushan On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Please find the attached web-app. It refers to the transaction-manager, which has bind with JNDI, while transaction-manger bundle get start in carbon sever. Regards, Dinusha. Thanks, Kishanthan. Regards, Dinusha. On Sat, May 26, 2012 at 12:50 PM, Supun Malinga sup...@wso2.comwrote: Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi All, I have registered a object with JNDI and try to access
Re: [Dev] JNDI lookup wont work inside a web-app
I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Please find the attached web-app. It refers to the transaction-manager, which has bind with JNDI, while transaction-manger bundle get start in carbon sever. Regards, Dinusha. Thanks, Kishanthan. Regards, Dinusha. On Sat, May 26, 2012 at 12:50 PM, Supun Malinga sup...@wso2.comwrote: Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Kishanthan Thangarajah* Software Engineer, Development Technologies Team, WSO2, Inc. lean.enterprise.middleware Mobile - +94773426635 Blog - *http://kishanthan.wordpress.com* Twitter - *http://twitter.com/kishanthan*
Re: [Dev] JNDI lookup wont work inside a web-app
If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Please find the attached web-app. It refers to the transaction-manager, which has bind with JNDI, while transaction-manger bundle get start in carbon sever. Regards, Dinusha. Thanks, Kishanthan. Regards, Dinusha. On Sat, May 26, 2012 at 12:50 PM, Supun Malinga sup...@wso2.comwrote: Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception.
Re: [Dev] JNDI lookup wont work inside a web-app
On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.com wrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. Thanks, ~Isuru Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Please find the attached web-app. It refers to the transaction-manager, which has bind with JNDI, while transaction-manger bundle get start in carbon sever. Regards, Dinusha. Thanks, Kishanthan. Regards, Dinusha. On Sat, May 26, 2012 at 12:50 PM, Supun Malinga sup...@wso2.comwrote: Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying
Re: [Dev] JNDI lookup wont work inside a web-app
On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.com wrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.com wrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1 thanks, +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. Thanks, ~Isuru Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Please find the attached web-app. It refers to the transaction-manager, which has bind with JNDI, while transaction-manger bundle get start in carbon sever. Regards, Dinusha. Thanks, Kishanthan. Regards, Dinusha. On Sat, May 26, 2012 at 12:50 PM, Supun Malinga sup...@wso2.comwrote: Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi All, I have registered a object
Re: [Dev] JNDI lookup wont work inside a web-app
This can be done. We have to first register JNDI resources for webapps context. Then we can lookup for them. As Paul mentioned, registering those resources can done in two ways. They can be either global or per webapp. If it is global, you have place them under GlobalNamingResources tag in tomcat's server.xml (catalina-server.xml in our case) file. Then they can be referenced in webapp via linking them in the context.xml file of webapp. Eg - ResourceLink name=jdbc/MyDataSource global=jdbc/MyDataSource type=com.atomikos.jdbc.AtomikosDataSourceBean/ If it is per webapp, then they can be registered by placing them in the context.xml file of the webapp it self. Eg - Resource name=TransactionManager auth=Container type=com.atomikos.icatch.jta.UserTransactionManager factory=org.apache.naming.factory.BeanFactory / Other properties for these resources should go inside each respective Resource tags. Make sure those classes used to define resource-type are in the classpath. Then have a reference for those resources in the web.xml of the webapp. Eg - resource-ref descriptionYour Description/description res-ref-namejdbc/MyDataSource/res-ref-name res-typecom.atomikos.jdbc.AtomikosDataSourceBean/res-type res-authContainer/res-auth /resource-ref I'm currently writing an article on recent tomcat improvements, so it's better to include these details in there as-well. Thanks, Kishanthan. Ref - http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html On Mon, May 28, 2012 at 3:55 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Mon, May 28, 2012 at 2:51 PM, Isuru Suriarachchi is...@wso2.comwrote: On Mon, May 28, 2012 at 2:45 PM, Paul Fremantle p...@wso2.com wrote: If that is the way its meant to work, then we need a way to register things like DataSources and Transaction context into the webapps JNDI. There is some good docs on how this works in Tomcat here: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration In Tomcat it seems you can define JNDI entries either locally in the web.xml or globally and then link to them. +1. This should work for us and looks like it's the correct way of doing this. Kishanthan, please look into this.. I will have a look at this and provide an update. Created a jira to track this [1]. Kishanthan. [1] https://wso2.org/jira/browse/CARBON-13277 Thanks, ~Isuru Paul On 28 May 2012 10:03, Isuru Suriarachchi is...@wso2.com wrote: I had a discussion on this with Kicha and looks like the way it works is correct. When jndi resources are registered in the webapp itself, those get registered in it's own context and can be loaded anywhere within the webapp. But when resources are registered in the initial context, those are not visible to the webapps. Looks like this is the correct behavior. Can we please check whether this webapp works in previous releases? Thanks, ~Isuru On Mon, May 28, 2012 at 1:00 PM, Kishanthan Thangarajah kishant...@wso2.com wrote: Here are the findings on this issue so far. In trunk, TransactionManager, UserTransaction etc, are getting bind with InitialContext of javaUrlContextFactory[1] which handles the “java:” namespace. This context is not bound to any thread or classloader. But in a webapp case, their context are isolated from each other and the classloaders are bound to each webapps naming context. But the initialContext from javaUrlContextFactory will not be accessible for them. This is why it fails when doing lookup within a webapp. The javaUrlContextFactory first checks whether current thread or classloader is bound to any context. If not, it will return the intialContext. This is why the lookup within a service is successful since its class loader is not bound to any naming context. The lookup from any BE component also works fine. So we have to think of a way to handle this issue. @Dinusha, can you try whether this webapp works in previous releases? Thanks, Kishanthan. [1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-catalina/7.0.26/org/apache/naming/java/javaURLContextFactory.java#javaURLContextFactory.getInitialContext%28java.util.Hashtable%29 On Sun, May 27, 2012 at 11:47 AM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi Kishanthan, On Sun, May 27, 2012 at 12:07 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.com wrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Please find the attached web-app. It refers to the transaction-manager, which has bind with JNDI, while transaction-manger bundle get start in carbon sever. Regards, Dinusha.
Re: [Dev] JNDI lookup wont work inside a web-app
Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Kishanthan Thangarajah* Software Engineer, Development Technologies Team, WSO2, Inc. lean.enterprise.middleware Mobile - +94773426635 Blog - *http://kishanthan.wordpress.com* Twitter - *http://twitter.com/kishanthan* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Kishanthan Thangarajah* Software Engineer, Development Technologies Team, WSO2, Inc. lean.enterprise.middleware Mobile - +94773426635 Blog - *http://kishanthan.wordpress.com* Twitter - *http://twitter.com/kishanthan* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Supun Malinga, Software Engineer, WSO2 Inc. http://wso2.com http://wso2.org email - sup...@wso2.com sup...@wso2.com mobile - 071 56 91 321 ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
On Sat, May 26, 2012 at 3:05 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi Kishanthan, The way you suggested also didn't work for me. I guess, in your sample wep-app, JNDI lookup has done for some data-source created within Tomcat itself. Can you share the webapp? I'll have a look into this. Thanks, Kishanthan. Regards, Dinusha. On Sat, May 26, 2012 at 12:50 PM, Supun Malinga sup...@wso2.com wrote: Hi Kishanthan, Any idea why 'normal' jndi lookup doesn't work? If I'm a user and want to do some jndi lookup insid ea webapp I would follow the standard way. If that's not going to work I think we better at least document this. thanks, On Sat, May 26, 2012 at 11:31 AM, Kishanthan Thangarajah kishant...@wso2.com wrote: Hi, This was one the issue I encountered when trying to write some webapps with webapp specific contextXml configuration where I store some JNDI resources in it. Normal lookup is as follow, which gives the exception when trying within a webapp, Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); But after some debugging at tomcat code level, I found a way to overcome this. We have to use the catalina jndi context implementation. Let me give some insight. Context initCtx = new InitialContext(); SelectorContext selectorContext = new SelectorContext((HashtableString, Object) initCtx.getEnvironment(), false); Context envCtx = (Context) selectorContext.lookup(java:comp/env); Here the SelectorContext is the Catalina JNDI Context implementation. First using the IntialContext environment we have to build the Catalina selector context, and then we can lookup from that. Can you please try this and let me know if it fails? You can take a look at the webapp samples here [1]. Thanks, Kishanthan. [1] https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/as/modules/samples/product/TomcatWebApps/ On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Kishanthan Thangarajah* Software Engineer, Development Technologies Team, WSO2, Inc. lean.enterprise.middleware Mobile - +94773426635 Blog - *http://kishanthan.wordpress.com* Twitter - *http://twitter.com/kishanthan* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- Supun Malinga, Software Engineer, WSO2 Inc. http://wso2.com http://wso2.org email - sup...@wso2.com sup...@wso2.com mobile - 071 56 91 321 -- *Kishanthan Thangarajah* Software Engineer, Development Technologies Team, WSO2, Inc. lean.enterprise.middleware Mobile - +94773426635 Blog - *http://kishanthan.wordpress.com* Twitter - *http://twitter.com/kishanthan* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
[Dev] JNDI lookup wont work inside a web-app
Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
Is this on the trunk? If so it is a blocker for the AS release. On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Afkham Azeez* Director of Architecture; WSO2, Inc.; http://wso2.com Member; Apache Software Foundation; http://www.apache.org/ * http://www.apache.org/** email: **az...@wso2.com* az...@wso2.com* cell: +94 77 3320919 blog: **http://blog.afkham.org* http://blog.afkham.org* twitter: **http://twitter.com/afkham_azeez*http://twitter.com/afkham_azeez * linked-in: **http://lk.linkedin.com/in/afkhamazeez* * * *Lean . Enterprise . Middleware* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] JNDI lookup wont work inside a web-app
On Fri, May 25, 2012 at 6:06 PM, Afkham Azeez az...@wso2.com wrote: Is this on the trunk? If so it is a blocker for the AS release. Yeah, it is in trunk build. Regards, Dinusha. On Fri, May 25, 2012 at 5:45 PM, Dinusha Senanayaka dinu...@wso2.comwrote: Hi All, I have registered a object with JNDI and try to access it within a web-app. But JNDI lookup get fails saying javax.naming.NameNotFoundException: Name [java:comp/TransactionManager] is not bound in this Context. Unable to find [java:comp]. Even I tried to lookup a Carbon JNDI data-source, it also fails by giving similar type exception. But same JNDI lookups work inside a Axis2 service(AAR). Any idea why this can be happened ? Regards, Dinusha. ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev -- *Afkham Azeez* Director of Architecture; WSO2, Inc.; http://wso2.com Member; Apache Software Foundation; http://www.apache.org/ * http://www.apache.org/** email: **az...@wso2.com* az...@wso2.com* cell: +94 77 3320919 blog: **http://blog.afkham.org* http://blog.afkham.org* twitter: **http://twitter.com/afkham_azeez*http://twitter.com/afkham_azeez * linked-in: **http://lk.linkedin.com/in/afkhamazeez* * * *Lean . Enterprise . Middleware* ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev