user2764818
user2764818

Reputation:

Loading Tomcat Resource in Spring

Within my server.xml I have something like the following line:

  <GlobalNamingResources>
<!-- Editable user database that can also be used by
     UserDatabaseRealm to authenticate users
-->
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
<Resource factory="com.company.ServerEnvironmentFactory" name="config/ServerEnvironment" type="java.util.Map"/>

Within Spring 3, how to do ensure that the ServerEnvironmentFactory is created, such that I can do a Context lookup for java:/comp/env/config/ServerEnvironment.

Thank you

Upvotes: 1

Views: 796

Answers (2)

Garry
Garry

Reputation: 4533

I think you need to configure your context.xml so that all Application are aware of the global resource.

<ResourceLink global="config/ServerEnvironment" name="config/ServerEnvironment" type="java.util.Map" />

Upvotes: 1

Hank Lapidez
Hank Lapidez

Reputation: 2025

Give this a try:

<bean id="myEnv" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:/comp/env/config/ServerEnvironment"/>
</bean>

Resources:

Tomcat Java JNDI Example

Spring JNDI Example

Upvotes: 0

Related Questions