0

I have a backend api spring boot project, when I try to start it from the vscode bash terminal (eclipse bash terminal too) I receive the following error:

10-15 07:38:37,212 org.springframework.context.support.AbstractApplicationContext:refresh WARN - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
10-15 07:38:37,212 org.apache.juli.logging.DirectJDKLog:log INFO - Stopping service [Tomcat]
10-15 07:38:37,227 org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener:logMessage INFO -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

However, when I am using the eclipse plugin: "Boot Dashboard", it works fine and starts, no errors....

The commands I am using in the terminal are:

mvn clean install spring-boot:repackage
java -jar target/project-name-0.0.1-SNAPSHOT.jar

This used to work, and then one day just started throwing the error .

I have tried the maven updates, project cleans, deleting the /m2 folder, making sure all ports are clear/open, "turning it off and on again" .... Doesn't work from terminal but works from the plugin, can't figure out why.

Alex
  • 160
  • 1
  • 2
  • 22
  • what versions you are running of java, https://stackoverflow.com/questions/43574426/java-how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexceptio – Toerktumlare Oct 15 '20 at 12:31
  • I am using jdk 11 – Alex Oct 15 '20 at 13:45
  • 1
    if you read the link i posted, from Java 9 and forward JAXB was removed from the jdk, since it was considered to be a part of Java EE. If you want to include it you need to compile using the flag `--add-modules java.xml.bind` – Toerktumlare Oct 15 '20 at 13:50
  • 1
    @ThomasAndolf I was able to follow the link in your comment and to add this to the pom to fix my issue: javax.xml.bind jaxb-api 2.3.0 If you want to add an answer I can mark it as correct... – Alex Oct 21 '20 at 15:15
  • Yes, that did... if you want to post it an answer (instead of a comment), I can mark it as being the correct answer.... – Alex Oct 21 '20 at 16:33

2 Answers2

0

In Eclipse, open the Debug view, right-click on the tree node that represented the VM executable, and open its Properties to see the entire command line that was used.

nitind
  • 19,089
  • 4
  • 34
  • 43
-1

For Spring Boot application it is preferred to use either Spring Tool suite or Intellij. My preference will be Intellij since am using that currently. If you are using Angular or React or any other frontend libraries then start running that using Visual code studio and then Start the spring boot application using Intellij that sounds good, since you can easily clear the errors since Intellij is designed in such way.