Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:58:07+00:00 2026-05-22T02:58:07+00:00

We have a plain standalone spring application and we need to put jdbc datasource

  • 0

We have a plain standalone spring application and we need to put jdbc datasource in jndi. (we use jboss treecache and it need datasource to be in the jndi).

Some googling found most of all jndi-lookup examples with spring, where an object is already put in jndi (by tomcat or application server etc), but we need otherwise: I have a plain datasource Spring bean, which I inject to other services, but I can’t inject it to TreeCache, because it needs it only from jndi.

Found org.springframework.jndi.JndiTemplate, which can be declared as bean, e.g.:

<bean id="fsJndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
        <props>
            <prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</prop>
            <prop key="java.naming.provider.url">file:///c:\windows\temp</prop>
        </props>
    </property>
</bean>

but not found how to bind with it other than in java code: fsJndiTemplate.bind(name, obj) from init-method of some other bean.
Is there any way to do it declaratively?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:58:08+00:00Added an answer on May 22, 2026 at 2:58 am

    Your can create a JndiExporter which uses a JndiTemplate to bind a map of object with a name:

    <bean id="jndiExporter" class="org.xxx.JndiExporter">
        <property name="jndiTemplate" ref="jndiTemplate">
        <property name="objects">
              <map>
                <entry key="name1" value="bean1"/>
                <entry key="name2" value="bean2"/>
                <entry key="name3" value="bean3"/>
                <entry key="name4" value="bean4"/>
              </map>
        </property>
    </bean>
    

    Your JndiExporter have to implements BeanFactoryAware to retrieve the spring bean with the injected BeanFactory.

    This is one possible may 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an plain simple java application that use spring 2.5.5 and hiberate 3.3.1.GA.
In an iPhone application, I have some plain C functions. Is it possible to
I have an XSLT file generating plain HTML. I need to wrap some elements
I have a plain text file looking like this: some text containing line breaks
I have a simple form with some plain html input like bellow using ASP.NET
We have developed a standalone application using visual basic 6. Now we are changing
I have a plain ruby application (it's not a Web app, so not using
I have a plain Plone 4 configuration and I need to keep track of
I have a plain sql file with some SQL INSERT statements. Is it possible
I have some applications (some native, some .NET) which use manifest files so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.