Skip to content

Non-Hibernate JPA config #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mark666 opened this issue Jul 17, 2014 · 8 comments
Closed

Non-Hibernate JPA config #1268

Mark666 opened this issue Jul 17, 2014 · 8 comments
Labels
type: bug A general bug
Milestone

Comments

@Mark666
Copy link

Mark666 commented Jul 17, 2014

I need to configure boot to use EclipseLink, I thought I could just extend JpaBaseConfiguration and provide the createJpaVendorAdapter etc. However, JpaBaseConfiguration includes JpaProperties which has an embedded Hibernate specific class. That class has a DEFAULT_NAMING_STRATEGY which extends ImprovedNamingStrategy. So running boot with EclipseLink (or OpenJPA) results in "Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/ImprovedNamingStrategy"

@odrotbohm
Copy link
Member

I don't think you need to tweak the auto-configuration. You should be able to simply declare a bean of type LocalContainerEntityManagerFactoryBean and set it up appropriately to disable the auto-configuration for that particular bean.

@philwebb philwebb added the bug label Jul 17, 2014
@philwebb philwebb added this to the 1.1.5 milestone Jul 17, 2014
@philwebb
Copy link
Member

I guess you are likely to see the NoClassDefFoundError even if you declare your own configuration because JpaProperties is used in a number of places. We should switch to lookup that class using reflection.

@Mark666 Mark666 changed the title Non-Hibernate JPA auto config Non-Hibernate JPA config Jul 21, 2014
@dsyer
Copy link
Member

dsyer commented Jul 21, 2014

Is there a nice compact sample project somewhere that uses Eclipselink?

dsyer pushed a commit that referenced this issue Jul 21, 2014
With this change I got a simple Eclipselink version of the data-jpa
sample working. I'll push that when I get time to research it a bit more
(I needed to set up a Java agent so either that might be a problem
for our integration tests if we can't work around it).

Fixes gh-1268.
@dsyer dsyer closed this as completed in ac2ab39 Jul 21, 2014
dsyer pushed a commit that referenced this issue Sep 15, 2014
With this change I got a simple Eclipselink version of the data-jpa
sample working. I'll push that when I get time to research it a bit more
(I needed to set up a Java agent so either that might be a problem
for our integration tests if we can't work around it).

Fixes gh-1268. Cherry picked onto master after (apparently) a failed
merge of commit ac2ab39.
@ThomBrando
Copy link

Has auto-configuration working for EclipseLink been accomplished in either the 1.2.4 or 1.3.0 snapshot builds yet? I'm using the 1.2.3 release build and haven't been able to configure my spring boot app to use eclipselink. Spring complains that there isn't a bean of one type. Then, after I create that bean in my Application class, it complains there's another bean missing. So far, I've created the following beans: JndiObjectFactoryBean (my DataSource), LocalContainerEntityManagerFactoryBean, EntityManagerFactoryBuilder, EclipseLinkJpaVendorAdapter, JpaProperties, DefaultPersistenceUnitManager, and JpaTransactionManager. Now, the message I'm getting says:

"Error creating bean with name 'entityManagerFactory' defined in org.mitre.eev.Application: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified"

I'm using Spring Boot 1.2.3.RELEASE, Spring Framework 4.1.6.RELEASE. I've tried compiling and running with Java 7 and 8 on Tomcat 7 and 8.

This may or may not be important, but the JpaProperties bean I create contains no database connection information, since the DataSource is coming from JNDI. Or am I missing something major here?

@dsyer
Copy link
Member

dsyer commented Apr 21, 2015

It definitely worked for me. I had a sample but didn't push it to the main repo because it required some fiddly configuration for a load time weaver that I thought might be hard in unit tests. Here it is: https://github.com/dsyer/spring-boot-sample-data-eclipselink, or if that doesn't work maybe @olivergierke has something in Spring Data already?

@odrotbohm
Copy link
Member

I don't but your's looks like a great candidate to get polished and promoted to one :). We have a ticket over here for that which I'll take care of.

@ThomBrando
Copy link

@dsyer I've looked at your sample, but I don't see a persistence.xml nor any database connection info. I think the sample uses an in-memory database, while I'm trying to use an Oracle database with a DataSource that's defined in Tomcat's server.xml.

@dsyer
Copy link
Member

dsyer commented Apr 21, 2015

You probably need to start with something simple and work up to it then, but I don't see that much of a gap. Spring Boot can connect to a JNDI data source (http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-connecting-to-a-jndi-datasource) and it's not that different from using an embedded one, just one line of configuration. If you prefer to use persistence.xml I'm sure there are samples available for that as well, but why not try without it to start with, since that's the way that most people use Spring Boot. If you have issues please raise them elsewhere though (this issue is closed in github), either on StackOverflow or in github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants