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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:47:39+00:00 2026-05-26T16:47:39+00:00

When I execute the following code in scala REPL: javax.persistence.Persistence.createEntityManagerFactory(manager1) I get javax.persistence.PersistenceException: No

  • 0

When I execute the following code in scala REPL:

javax.persistence.Persistence.createEntityManagerFactory("manager1")

I get

javax.persistence.PersistenceException: No Persistence provider for EntityManager named manager1

The same maven project running Java has no problems (in other words, I believe my dependecies are setup correctly)

Using the remote debugger I found the problem seem to be at PersistenceProviderResolverHolder where it executed the following code:

Enumeration<URL> resources = cl.getResources( "META-INF/services/" + PersistenceProvider.class.getName() )

The returned enumeration has no elements.

When I execute the same REPL session

val cl = classOf[javax.persistence.spi.PersistenceProviderResolverHolder].getClassLoader()
cl.getResources( "META-INF/services/javax.persistence.spi.PersistenceProvider").hasMoreElements

I get “true”

This happens both when using mvn:scala or when using scala directly:

scala -cp "target/dependency/*":target/classes

My dependencies are

[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) @ java.jpa.basics ---
[INFO] com.edc4it:java.jpa.basics:jar:1.0
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.2:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.6.2:compile
[INFO] |  \- log4j:log4j:jar:1.2.16:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.6:compile
[INFO] +- javassist:javassist:jar:3.9.0.GA:compile
[INFO] +- org.scala-lang:scala-library:jar:2.9.1:compile
[INFO] \- org.hibernate:hibernate-entitymanager:jar:3.6.7.Final:compile
[INFO]    +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[INFO]    |  +- antlr:antlr:jar:2.7.6:compile
[INFO]    |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO]    |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO]    |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO]    |  \- javax.transaction:jta:jar:1.1:compile
[INFO]    +- cglib:cglib:jar:2.2:compile
[INFO]    |  \- asm:asm:jar:3.1:compile
[INFO]    \- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile

The only JPA releated dependency is “org.hibernate:hibernate-entitymanager:3.6.7.Final”

It looks like a classloading problem, but could it be something different?

  • 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-26T16:47:40+00:00Added an answer on May 26, 2026 at 4:47 pm

    After some more digging and debugging, I found out that the JPA implementation uses the current tread’s contextual classloader (which in my case is the sun.misc.Launcher$AppClassLoader). That classloader indeed does not include the JPA and Hibernate JARs. (see javax.persistence.spi.PersistenceProviderResolverHolder.PersistenceProviderResolverPerClassLoader#getContextualClassLoader)
    Changing the contextual classloader prior to getting the EntityManagerFactory therefore does the trick:

    Thread.currentThread().setContextClassLoader(JPAUtil.class.getClassLoader());
    emf =  Persistence.createEntityManagerFactory("manager");
    

    In REPL setting the contextual classloader does not work, it is reset to the application classloader after setting it.

    I dkn’t know what the consequences are yet (not sure if all the JPA code will actually work, just did a few tests and seems to work so far).
    Also i don’t understand why hibernate would use the contextual classloader and not just the current classloader.

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

Sidebar

Related Questions

When I execute following code in scala REPL console: java.util.Collections.max(new java.util.ArrayList[String]()) NoSuchMethodError exception is
I get the following error when I try and execute the code down below.
When I execute the following code, I get ConcurrentModificationException Collection<String> myCollection = Collections.synchronizedList(new ArrayList<String>(10));
if i execute the following code i get a cannot convert to object error;
When I execute the following code: Preferences.userRoot().nodeExists(strNodeName); I get an exception : java.util.prefs.BackingStoreException: Cannot
When I execute the following code; I get a seg fault every time! Is
When I am trying to execute following code to email the contact form details,
To test if i can connect to my database, I execute the following code
I'm using the following code to execute a query in Lucene.Net var collector =
I'm trying the following code to execute a search and it's not working. On

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.