0

I'm learning from in28minutes course "Master Java Web Services and REST API with Spring Boot".

Errors

When I try Maven's command Update Project, I get these internal errors:

An internal error occurred during: "Building".

java.lang.reflect.InvocationTargetException

An internal error occurred during: "Updating Maven Project".

java.lang.reflect.InvocationTargetException

My pom.xml file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.0-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.in28minutes.soap.webservices</groupId>
    <artifactId>soap-course-management</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>soap-course-management</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
                    <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                    <clearOutputDir>false</clearOutputDir>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

</project>

Another file src/main/resources/course-details.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://in28minutes.com/courses" 
xmlns:tns="http://in28minutes.com/courses" elementFormDefault="qualified">
    <xs:element name="GetCourseDetailsRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="id" type="xs:integer"/>       
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="GetCourseDetailsResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="CourseDetails" type="tns:CourseDetails"/>     
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="CourseDetails">
        <xs:sequence>
            <xs:element name="id" type="xs:integer"/>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="description" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    

</xs:schema>

I tried using Java 8,11,16.

hc_dev
  • 8,389
  • 1
  • 26
  • 38
pga2
  • 11
  • 5
  • Does this answer your question? [Runtime error while running a Spring Session + Spring Boot application](https://stackoverflow.com/questions/28571460/runtime-error-while-running-a-spring-session-spring-boot-application) – Lakshan Jul 26 '21 at 16:28

3 Answers3

0

It could be a conflicting version of some dependencies and spring-boot version. Change the version of spring-boot then retry.

  • ``` org.springframework.boot spring-boot-starter-parent 2.6.0-SNAPSHOT ``` You mean change this part of code in pom.xml ()? – pga2 Jul 26 '21 at 09:12
0

Try adding below dependency in pom.xml

 <dependencies>
    <dependency>
     <groupId>javax.activation</groupId>
     <artifactId>activation</artifactId>
     <version>1.1.1</version>
    </dependency>
</dependencies>
Conner
  • 15
  • 4
0

The problem is the different Java version and JAXB2 plugin version I was using. In my case it is Java version 11 - check pom.xml:

<java.version>11</java.version>

As a result of this, the JAXB2 plugin version 2.5.0 should be used (not 1.6 as mentioned in the video):

2.5.0

This version change of the plugin will require this setting to be modified:

${project.basedir}/src/main/resources

... into this:

${project.basedir}/src/main/resources/course-details.xsd

Then, do a right click on the project > Maven > Update Project (no further checkboxes to check)... That's it.

Here the plugin snippet in the pom.xml:

...

org.codehaus.mojo

jaxb2-maven-plugin

2.5.0

<execution>

  <id>xjc</id>

  <goals>

    <goal>xjc</goal>

  </goals>

</execution>
<sources>

  <source>${project.basedir}/src/main/resources/course-details.xsd</source>

</sources>

<outputDirectory>${project.basedir}/src/main/java</outputDirectory>

<clearOutputDir>false</clearOutputDir>