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 8521803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:55:43+00:00 2026-06-11T06:55:43+00:00

I need to do very similar thing to what is described in Injecting Entitymanager

  • 0

I need to do very similar thing to what is described in Injecting Entitymanager via XML and not annnotations, but I need to inject from XML the real, container-created, entity manager, so that it behaves exactly as if there is a real @PersistenceContext annotation. I’ve found a LocalEntityManagerFactoryBean (notice missing “Container” word), but I’m affraid that it creates a new entity manager factory and therefore entity manager won’t be compatible with that injected via real @PersistenceContext annotation.

I will describe the reason, because it is weird and maybe the solution to my problem is to choose completely different approach. I’m using PropertyPlaceholderConfigurer in my spring configuration and in this configurer I’m referencing other beans. I’m experiencing a bug that autowiring doesn’t work in those referenced beans. I don’t know why and how PropertyPlaceholderConfigurer turns off autowiring in those referenced beans but the fact is, that if I replace autowiring by xml configuration for those beans, everything works. But I’m unable to replace autowiring of EntityManager, since it’s not standard spring bean, but jndi-loaded something I don’t fully understand.

One way or the other, is there some solution?

  • 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-06-11T06:55:45+00:00Added an answer on June 11, 2026 at 6:55 am
    <bean id="earlyInitializedApplicationSettingsService" class="...services.impl.ApplicationSettingsServiceImpl" autowire-candidate="false">
        <property name="applicationSettingsDao">
            <bean class="....impl.ApplicationSettingsDaoImpl">
                <property name="entityManager">
                    <bean class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
                        <property name="entityManagerFactory">
                            <bean class="org.springframework.jndi.JndiObjectFactoryBean">
                                <property name="jndiName" value="java:comp/env/persistence/somePersistenceUnit"/>
                            </bean>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
    

    Notice mainly the fact, that I’m not using standard jee:jndi-lookup, because it didn’t work (in the conditions created by PropertyPlaceholderConfigurer) and that was the source of my confusion. When I used direct JndiObjectFactoryBean, it worked.

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

Sidebar

Related Questions

I know there are very similar questions but im not sure that any of
I have 2 tables in a DB with very similar schemas that need to
I need to perform a very large sql server insert from a c# application.
I need to get images along with other data (very similar to email with
I need to extract data from a .dbf file and transform it into xml.
The Good For Enterprise solution from good.com is a very very difficult thing to
There is a question very similar to this but I wanted to ask it
I need very basic template engine, which is incapsulated in single class. So I
I need a very simple menu which probably contains only one or two items:
I need a very simple jQuery to constantly scroll a list of text items

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.