Tomcat vs Weblogic JNDI Lookup

前端 未结 8 1872
死守一世寂寞
死守一世寂寞 2020-11-28 07:23

The Weblogic servers we are using have been configured to allow JNDI datasource names like \"appds\".

For development (localhost), we might be running Tomcat and whe

相关标签:
8条回答
  • 2020-11-28 07:47

    My application also had a similar problem and this is how I solved it:

    1) WEB-INF/classes/application.properties contains the entry:

    ds.jndi=java:comp/env/jdbc/tcds
    

    2) On the WLS machine, I have an entry in the /etc/sysenv file:

    ds.jndi=wlsds
    

    3) I configured spring to lookup the JNDI vis the property ${ds.jndi}, using a PropertyPlaceholderConfigurer bean with classpath:application.properties and file:/etc/sysenv as locations. I also set the ignoreResourceNotFound to true so that developers need not have /etc/sysenv on their machines.

    4) I run an integration test using Cargo+Jetty and I could not properly set up a JNDI environment there. So I have a fallback BasicDataSource configured too using the defaultObject property of JndiObjectFactoryBean.

    0 讨论(0)
  • 2020-11-28 07:51

    Setting up DataSource in the application itself is not that crazy :) I would say that is even mandatory if application is meant to be deployed on a grid. River, GigaSpaces, or similar.

    Note: I do not say connection settings have to be hardcoded inside of WAR, they need to be supplied at deployment time/runtime. This simplifies management of cloud instances since there is only on place to configure.

    Configuring resources at the container makes sense only if multiple applications are deployed there and they can use shared resource.

    Again, in cloud type of deployments there is only one application per servlet container instance.

    0 讨论(0)
提交回复
热议问题