0

I've created the archetype maven project: jersey-quickstart-webapp. I've added the project files I've prepared before and I had to add the following <dependency> in the pom.xml file:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <type>jar</type>
    </dependency>

and now full file looks like this:

 <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 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.glassfish.jersey.archetypes</groupId>
<artifactId>ParkingSystem</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>ParkingSystem</name>

<build>
    <finalName>ParkingSystem</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
     <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
        <!-- artifactId>jersey-container-servlet</artifactId -->
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.inject</groupId>
        <artifactId>jersey-hk2</artifactId>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-binding</artifactId>
    </dependency>
</dependencies>
<properties>
    <jersey.version>2.27</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

I know that error means that there is more than one root element. However this is the default file from the archetype and there is <project> </project> as the root element, or maybe I don't understand something? Every other elements are within <project> element. The only change I made is that I added javax-servlet dependency as first from the top in the <dependencies> tag. I've checked xmlns and none of those is self-closing. I found tag <project.build.sourceEncoding in the <properties> tag but I don't think it has an effect on the root <project> </project> element anyway it was by default there. Clearly, I'm missing something and I really want to understand.

This is the only error message I got:
[Fatal Error] :3:6: The markup in the document following the root element must be well-formed.
No more info.

9
  • Please post the error messages. Commented Aug 25, 2018 at 12:46
  • I've updated a question, however, the only error message I got is the one in question title :( Commented Aug 25, 2018 at 12:53
  • I mean, sounds like either the <project> element is malformed, or something right after. Maybe we can't see it here. You could post the raw content to something like pastebin. But I'd check for some formatting problems, do you maybe have an editor with XML syntax highlighting? Commented Aug 25, 2018 at 12:55
  • Here it is I put it into pastebin - as XML: pastebin.com/sDJTsM3B Commented Aug 25, 2018 at 13:02
  • A full message will provide more information about When and Which step printed out this "Fatal Error". Commented Aug 25, 2018 at 13:05

1 Answer 1

1

In your context.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/ParkingSystem"/>
    <Resource name="sql2226123"
       auth="Container" type="javax.sql.DataSource"
       maxActive="20" maxIdle="5" maxWait="10000"
       username="sqldb" password="xyz123"
       driverClassName="com.mysql.jdbc.Driver"
       url="jdbc:mysql://sql2.freemysqlhosting.net:3306/sql2226123"/>
</Context>

The second line <Context path="/ParkingSystem"/> has closed Context, so this file is malformed. Delete the last / this line will fix the problem. The correct file should be like:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/ParkingSystem">
    <Resource name="sql2226123"
       auth="Container" type="javax.sql.DataSource"
       maxActive="20" maxIdle="5" maxWait="10000"
       username="sqldb" password="xyz123"
       driverClassName="com.mysql.jdbc.Driver"
       url="jdbc:mysql://sql2.freemysqlhosting.net:3306/sql2226123"/>
</Context>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Thank you so much :D Ill remember now to check all other XML files in a situation like this! You saved me :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.