0

A spring boot app that runs perfectly fine on the command line with:

mvn clean package spring-boot:run

I then add the spring boot plugin option to create an executable jar:

<plugin>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <executable>true</executable>
     <mainClass>for.bar.Application</mainClass>
     <layout>JAR</layout>
  </configuration>
</plugin>

and my app launches on the command line. However, DataNucleus crashes with an error:

Could not find API definition for name "JDO". Perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?

The problem is partially explained here: Datanucleus, JDO and executable jar - how to do it?

So I sort of understand what's happening. DataNuclues is an OSGi library. It it even possible to make a spring boot exec jar with DataNuclues as the persistence layer? I'm about to try to switch to spring data which is going to be a nightmare.

bsautner
  • 4,479
  • 1
  • 36
  • 50
  • I don't see DataNucleus as having any particular requirements, other than the user putting things in the CLASSPATH, since it is simply a Java process - OSGi is irrelevant to the argument ... so it is OSGi enabled, and?. You could read http://www.datanucleus.org/servlet/forum/viewthread_thread,8020_lastpage,yes#lastpost – Neil Stockton Jun 27 '17 at 05:54
  • thanks for the help Neil - i'm still working on this, in the link I posted in the question - datanuclues talks about how unpacking and repacking the dependencies breaks DN. I've tried using different tools to make a fat jar with one jar or the maven assembly pluging but that ends up breaking spring boot. – bsautner Jun 27 '17 at 15:20
  • Define how a single jar with correctly merged plugin.xml / MANIFEST.MF breaks Spring-boot. Who knows what Spring Boots requirement is – Neil Stockton Jun 27 '17 at 15:37
  • This post has one way someone merged it all ... for those that want to https://stackoverflow.com/questions/37484239/apache-spark-hive-executable-jar-with-maven-shade but you could check whether something is merged correctly before using it with Spring boot, so you know where the problem is – Neil Stockton Jun 27 '17 at 17:39
  • thanks again for all of the help - this was all a real mess between the spring boot maven plugin and DN - despite several attempts at using one-jar, the maven assembly plugin, and the various hacks in these threads I opted to backtrack and make my app into a war instead of an executable jar - then just installed tomcat and deployed the war which i'm happy with. If i find a way to make an executable jar with spring boot / DN using maven plugins i'll update this thread. – bsautner Jun 27 '17 at 19:29
  • Aaargh! Has anyone ever got DN to work in a fat Spring Boot jar? – Adam Sep 22 '17 at 15:54
  • oh man, i'm sorry to hear someone being stuck in the same place I was. With all do respect to DN - I only chose that persistence layer because at the time I was targeting GAE. I ended up rewriting my entire DAO in Spring Data / JPA and using the CrudRepository interfaces, which I'll tell you are delightful to work with after years of fighting the enhancer. However, building a WAR and installing to tomcat instead of making an executable jar had worked with DN as well. Good luck! – bsautner Sep 22 '17 at 16:24

0 Answers0