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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:04:44+00:00 2026-05-16T09:04:44+00:00

The Spring configuration I am using contains the definition of a persistenceUnitPostProcessor within my

  • 0

The Spring configuration I am using contains the definition of a persistenceUnitPostProcessor within my entityManagerFactory bean.

When I run a JUnit test (i.e. outside of the container) the post processor is being invoked, yet when it participates as part of a deployed web app (running in Glassfish v3) the post processor is not being executed. Everything else works, the spring context is loaded correctly, all the defined beans load, it’s just that the post processor is never fired.

The purpose of the entity scanner is to locate @Entity annotated classes. The project is split between two modules, one which contains Domain Models and the other which contains DAOs and persistence code.

The scanner code is loosely based on the blog post here : auto-scanning-jpa-entities which searches the classpath. As I say, this all works fine outside of the container.

The relevant spring config elements showing the post processor bean (trimmed for brevity) are as follows:

<bean id="entityScanner" class="com.inno.spring.EntityScanner"> 
    <property name="classPathFilter">
        <value>insurer</value>
    </property>
    <property name="targetPersistenceUnits"> 
        <value>unitTest-hsqldb</value> 
    </property> 
    <property name="classesToExclude"> 
        <value></value> 
    </property> 
</bean>

with the entity manager factory being defined as follows:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="loadTimeWeaver">
        <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
    </property>
    <property name="dataSource">
        <!-- Workaround to allow custom isolation levels -->
        <bean class="org.springframework.jdbc.datasource.lookup.IsolationLevelDataSourceRouter">
            <property name="defaultTargetDataSource" ref="unitTestDataSource" />
            <property name="targetDataSources">
                <map>
                    <entry key="ISOLATION_READ_UNCOMMITTED">
                        <bean
                            class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter">
                            <property name="targetDataSource" ref="unitTestDataSource" />
                            <property name="isolationLevelName" value="ISOLATION_READ_UNCOMMITTED" />
                        </bean>
                    </entry>
                </map>
            </property>
        </bean>
    </property>
    <property name="persistenceUnitName" value="unitTest-hsqldb" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="database" value="HSQL" />
            <property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
            <property name="showSql" value="${jpa.hibernate.showSql}" />
            <property name="generateDdl" value="${jpa.hibernate.generateDdl}" />
        </bean>
    </property>
    <property name="jpaPropertyMap">
        <map>
            <entry key="hibernate.ejb.interceptor" value="com.inno.jpa.interceptors.InsurerInterceptor" />
        </map>
    </property>
    <property name="persistenceUnitPostProcessors"> 
        <list> 
            <ref bean="entityScanner" /> 
        </list> 
    </property> 

</bean>

I am a relative newbie to Spring and JPA so go easy on me if I’ve made an obvious mistake!

Thanks Steve

  • 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-16T09:04:45+00:00Added an answer on May 16, 2026 at 9:04 am

    I gave up trying to get this to work in the end, instead I moved the code into the same project. Seems a bit silly to me that the jar-file option under the persistence unit definition in persistence.xml isn’t a little more flexible in terms of being able to scan the classpath directly.

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

Sidebar

Related Questions

I already know how to: Load properties files into my Spring configuration using: <context:property-placeholder
In a spring configuration, what is the difference between using name vs id? I'm
Spring IoC container gives you an option of replacing a method of a bean.
Here's a standard scenario: if(string.IsNullOrEmpty(Configuration.AppSettings[foobar])) throw new SomeStandardException(Application not configured correctly, bozo.); The problem
Spring security has a nice feature, it remembers the url of request resource and
Spring.NET is an open source application framework that makes building enterprise .NET applications easier.
Spring.NET 1.2.0 M1 comes with several XSD files for the <objects> node, database stuff,
Spring: In my context.xml, I have: <util:set id=someIDs set-class=java.util.HashSet value-type=java.lang.String> <value>W000000001</value> <value>W000000003</value> <value>W000000009</value> </util:set>
Spring has a very handy convenience class called PropertyPlaceholderConfigurer , which takes a standard
string [] files = new string[2]; files[0] = ThinkFarAhead.Example.Settings.Configuration_Local.xml; files[1] = ThinkFarAhead.Example.Settings.Configuration_Global.xml; //Resharper complains

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.