• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Errors when installing Spring/maven project

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

i am new at Java and having few problems with understanding Spring and Java.

This is how my project looks like:
───PortingMK
   ├───.idea
   │   └───libraries
   ├───.mvn
   │   └───wrapper
   ├───src
   │   ├───main
   │   │   ├───java
   │   │   │   ├───com
   │   │   │   │   └───seavus
   │   │   │   │       └───aek
   │   │   │   │           └───np
   │   │   │   │               └───services
   │   │   │   │                   └───cdb
   │   │   │   ├───META-INF
   │   │   │   │   └───JAXB
   │   │   │   └───mk
   │   │   │       └───softnet
   │   │   │           └───PortingMK
   │   │   │               ├───client
   │   │   │               └───config
   │   │   └───resources
   │   │       ├───static
   │   │       ├───templates
   │   │       └───wsdl
   │   └───test
   │       └───java
   │           └───mk
   │               └───softnet
   │                   └───PortingMK
   └


My errors are:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.902 s <<< FAILURE! - in mk.softnet.PortingMK.PortingMkApplicationTests
contextLoads(mk.softnet.PortingMK.PortingMkApplicationTests)  Time elapsed: 0.002 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'portingMkApplication': Unsatisfied dependency expressed through field 'client'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'soapClient': Unsatisfied dependency expressed through field 'marshaller'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller' defined in class path resource [mk/softnet/PortingMK/config/SoapConfig.class]: Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'soapClient': Unsatisfied dependency expressed through field 'marshaller'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller' defined in class path resource [mk/softnet/PortingMK/config/SoapConfig.class]: Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'marshaller' defined in class path resource [mk/softnet/PortingMK/config/SoapConfig.class]: Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
Caused by: org.springframework.oxm.UncategorizedMappingException:
Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory




SoapClient.java



SoapConfig.java



PortingMkApplication.java




PortingMkApplicationTests.java




pom.xml




THank you for all help!








 
Bartender
Posts: 15743
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the relevant part of your error message. I've split it up in separate bullet points so we can analyse it a bit easier:

  • Error creating bean with name 'portingMkApplication': Unsatisfied dependency expressed through field 'client';
  • Error creating bean with name 'soapClient': Unsatisfied dependency expressed through field 'marshaller';
  • Error creating bean with name 'marshaller' defined in class path resource [mk/softnet/PortingMK/config/SoapConfig.class]: Invocation of init method failed;
  • Implementation of JAXB-API has not been found on module path or classpath.


  • Spring can't create your application because it can't create the SOAP client. It can't create the SOAP client because it can't create the JAX-B marshaller. It can't create the JAX-B marshaller because the application doesn't have access to an implementation of the JAX-B API at runtime.

    You have to understand that a lot of enterprise and web-applications are written against libraries that only contain an API and not an implementation of that API. In this case, Spring's Object/XML Mapping features are written against the JAX-B API, and it is YOUR job to provide an implementation of that API at runtime.

    Thankfully, you don't have to write it yourself, you can just add a runtime dependency on an existing implementation. You can register the reference implementation from Glassfish like this:
     
    Sheriff
    Posts: 22862
    132
    Eclipse IDE Spring TypeScript Quarkus Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Note that this wasn't a problem before Java 11. Up to Java 10, JSE came with a default JAXB implementation. They removed that in Java 11 though. The Glassfish dependency Stephan mentioned is the reference implementation, and should be good for most applications.
     
    miha zoubek
    Ranch Hand
    Posts: 48
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    @Stephan and @Rob thank you soo much for this!

    Another thing, just to help me understand this. When I am reading all documentations, tutorials and etc I am always seeing somthing like this in my main() class:



    Why in this case I do not need this? How does spring fw knows from where to get beans?

    tnx!
     
    reply
      Bookmark Topic Watch Topic
    • New Topic