I am using Maven and Bing API to create a web search interface for a class project. When compiling the files through the command prompt, I am receiving a weird error.
This is the command line results when compiling:
C:\Users\zacha\Desktop\java-project>mvn compile exec:java
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM C:\Users\zacha\Desktop\java-project\pom.xml: start tag not allowed in epilog but got b (position: END_TAG seen ...</build>\r\n</project>\r\n<b... #46:3) # line 46, column 3
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project (C:\Users\zacha\Desktop\java-project\pom.xml) has 1 error
[ERROR] Non-parseable POM C:\Users\zacha\Desktop\java-project\pom.xml: start tag not allowed in epilog but got b (position: END_TAG seen ...</build>\r\n</project>\r\n<b... #46:3) # line 46, column 3 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
C:\Users\zacha\Desktop\java-project>
Below is my POM 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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.websearch.web</groupId>
<artifactId>java-project</artifactId>
<version>1</version>
<name>New Project Using SchemaCrawler</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>us.fatehi</groupId>
<artifactId>schemacrawler</artifactId>
<version>${schemacrawler.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<schemacrawler.version>11.02.01</schemacrawler.version>
<skip.signing.artifacts>true</skip.signing.artifacts>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<!--Your comment
Replace the mainClass with the path to your java application.
It should begin with com and doesn't require the .java extension.
For example: com.bingwebsearch.app.BingWebSearchSample. This maps to
The following directory structure:
src/main/java/com/bingwebsearch/app/BingWebSearchSample.java.
-->
<mainClass>com.WebSearch</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!--Your comment
Replace the mainClass with the path to your java application.
For example: com.bingwebsearch.app.BingWebSearchSample.java.
This maps to the following directory structure:
src/main/java/com/bingwebsearch/app/BingWebSearchSample.java.
-->
<mainClass>com.WebSearch.java</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure.cognitiveservices</groupId>
<artifactId>azure-cognitiveservices-websearch</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
I am new to this and seem to be stumbling through this assignment. I have been following a tutorial from microsoft's website. Any help would be greatly appreciated.
Thank you in advance for your time.
The problem is that you have multiple root (top-level) elements while XMLs must have only one. In POM, the root element is <project>. So your other top-level elements should be moved inside <project>. Then you should merge your multiple <build> elements into one.
Please learn more about XML and read the POM reference which tells you exactly what elements can each element contain. Try to understand the structure and then you can solve these kind of problems yourself. Using an IDE would be a huge help for you as it points out the errors while you're editing the file, and it may suggest a solution.
Your final POM structure should look like this:
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.websearch.web</groupId>
<artifactId>java-project</artifactId>
<version>1</version>
<name>New Project Using SchemaCrawler</name>
<dependencies>
<dependency>...</dependency>
<dependency>...</dependency>
...
</dependencies>
<properties>
...
</properties>
<build>
<plugins>
<plugin>...</plugin>
<plugin>...</plugin>
...
</plugins>
</build>
</project>
Check the position of 'parent' tag in the pom.
It should come after the 'dependencies' closing tag.
I got the same maven errors but I have a valid pom.xml file. The only thing happened was that I hit the CTRL+SHIFT+F while viewing the pom file in STS editor. Afterward spring boot gave me tons of errors complaining about this and that. I tried to fix the problems but not the one pointing at the . It kept complaining about invalid content after the project end tag but nothing was there.
So, instead of trying to troubleshoot the problem that is not really a problem, I shut down and restart STS tool. The problem magically cleared. I got a clean build of my project and it worked magically without further troubleshooting.
I have an error in my karaf feature project wher I run my mvn install. Here is the pom.xml:
<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>
<parent>
<groupId>com.dmasoft.karaf.example</groupId>
<artifactId>assemblies-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.dmasoft.karaf.example.feature</groupId>
<artifactId>dmasoft-feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>feature</packaging>
<name>${project.groupId}/${project.artifactId}:${project.packaging}:${project.version}</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
When I run my mvn clean install I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install (default-install) on project dmasoft-feature: NoFileAssignedException: The packaging plugin for this project did not assign a main file to the project but it has attachments. Change packaging to 'pom'. -> [Help 1]
The maven-install-plugin:3.0.0-M1 was released as of 01/10/2018
Since, I got the same error with flexmojos projects where packaging was set to .
Solution is to set the version for the maven-install-plugin to the previous version (2.5.2) explicitly so it won't resolve the version automatically.
Note: I had to do this for the maven-deploy-plugin too. There may be others.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</build>
Now you can change mule.tools.version to 1.7 1.7 instead of setting maven plugins version if you are using it.
It all happens when I was trying to build a springboot application by ./mvnw clean install
When I first run the install command, it runs into following problem.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.749s
[INFO] Finished at: Fri Jun 21 02:14:32 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
**[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-social-twitter4j: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile: org/codehaus/plexus/compiler/CompilerException**
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/SS%20Computer/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar
[ERROR] urls[1] = file:/C:/Users/SS%20Computer/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.compiler.CompilerException
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
I searched the problem on Stackoverflow and was able to solve this problem by the post
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)
Then, I got into another problem
[ERROR] Source option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
I'm on OS X. mvn -v shows:
Maven home: /Users/matthuntington/Desktop/apache-maven-3.5.0
Java version: 9, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
Here is my pom 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.packtpub.restapp</groupId>
<artifactId>ticket-management</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ticket-management</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>1.5.7.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
You can specify maven source/target version by adding these properties to your pom.xml file
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
I think this means that
You are using JDK9 or later
Your project uses maven-compiler-plugin with an old version which defaults to Java 5.
You have three options to solve this
Downgrade to JDK7 or JDK8 (meh)
Use maven-compiler-plugin version or later, because
NOTE: Since 3.8.0 the default value has changed from 1.5 to 1.6
See https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#target
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
Indicate to the maven-compiler-plugin to use source level 6 and target 6 (or later).
Best practice recommended by https://maven.apache.org/plugins/maven-compiler-plugin/
Also note that at present the default source setting is 1.6 and the default target setting is 1.6, independently of the JDK you run Maven with.
You are highly encouraged to change these defaults by setting source and target as described in Setting the -source and -target of the Java Compiler.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
or use
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
This error might be also for plugin versions. You can fix it in the .POM file like the followings:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Make sure you have following configuration in your pom.xml file.
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
For me the solution was to set the version of the maven compiler plugin to 3.8.0 and specify the release (9 for in your case, 11 in mine)
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
This worked for me!!!!
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>academy.learnprogramming</groupId>
<artifactId>hello-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<target>10</target>
<source>10</source>
<release>10</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
In IntelliJ:
Open Project Structure (⌘;) > Modules > YOUR MODULE -> Language
level: set 9, in your case.
Repeat for each module.
There can be corrupted jar file for which it may show error as "ZipFile invalid LOC header (bad signature)"
You need to delete all jar files for which it shows the error and add this Dependency
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
I got this error: "Source option 5 is no longer supported. Use 6 or later"
after I changed the pom.xml
<java.version>7</java.version>
to
<java.version>11</java.version>
Later to realise the property was used with a dash insteal of a dot:
<source>${java-version}</source>
<target>${java-version}</target>
(swearings), I replaced the dot with a dash and the error went away:
<java-version>11</javaversion>
You need to set JDK 1.5 to your project and also all dependent project or jar file should also compiled with JDK 1.5
Via Maven I would like to build a Docker image from a Springboot project.
I run: mvn clean package docker:build
Issue:
ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.21.0:build (default-cli) on project spring-boot-docker: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.21.0:build failed: An API incompatibility was encountered while executing io.
fabric8:docker-maven-plugin:0.21.0:build: java.lang.UnsatisfiedLinkError: unknown
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>io.fabric8:docker-maven-plugin:0.21.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/Johan/.m2/repository/io/fabric8/docker-maven-plugin/0.21.0/docker-maven-plugin-0.21.0.jar
Etc
The maven pom.xml file contains:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<docker.image.prefix>springframeworkguru</docker.image.prefix>
<docker.image.name>springbootdocker</docker.image.name>
<docker.host.url>unix:///var/run/docker.sock</docker.host.url>
</properties>
The build plugin section contains:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.21.0</version>
<configuration>
<dockerHost>${docker.host.url}</dockerHost>
<verbose>true</verbose>
<images>
<image>
<name>${docker.image.prefix}/${docker.image.name}</name>
<build>
<dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
As suggested, I removed my maven repository, which did not help.
Using other dockerHost values (like http://127.0.0.1:2375) did not help.
I really hope you can help!
This is the solution on Windows 7, 8 and 10 Home:
Find the docker machine environment variables. Go to the docker (shell) and type: docker-machine env. The docker host and certification path are important.
Add the following properties to your pom.xml (maven) file:
<docker.host.url>(e.g.) tcp://192.168.99.100:2376</docker.host.url>
<docker.host.certPath>(e.g.) a path</docker.host.certPath>
In your build plugin add just after configuration
<dockerHost>${docker.host.url}</dockerHost>
<certPath>${docker.host.certPath}</certPath>
I have a jenkins ci that builds our projects and make a .war file of it.
But i can´t get it to deploy to jenkins, how do i do that?
My pom.xml looks like this:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MavenWeb</groupId>
<artifactId>MavenWeb</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<description></description>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>e-ject.se</id>
<name>e-ject.se</name>
<url>http://e-ject.se/MavenWeb</url>
<layout>default</layout>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<url>http://e-ject.se:8080/manager</url>
<server>e-ject.se</server>
<path>/MavenWeb</path>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>
And i added all info in settings.xml i found on the web. I can login to e-ject.se:8080/manager/html with the username and password.
<server>
<id>e-ject.se</id>
<username>jonathan</username>
<password>*****</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
I get this in the jenkins console:
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project MavenWeb:
Failed to deploy artifacts: Could not transfer artifact MavenWeb:MavenWeb:war:0.0.1-20120412.150346-1 from/to e-ject.se
(http://e-ject.se/MavenWeb): Failed to transfer file: http://e-ject.se/MavenWeb/MavenWeb/MavenWeb/0.0.1-SNAPSHOT/MavenWeb-0.0.1-20120412.150346-1.war.
Return code is: 405
If i just add tomcat:deploy in jenkins instead of deploy
i get:
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project MavenWeb: Cannot invoke Tomcat manager
cause : Cannot invoke Tomcat manager
and later:
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/deploy?path=%2FMavenWeb&war=
Can someone please help me get this to work, i have read a ton of guides but i cannot get it to work!
Regard
Jonathan
I realized i had more than one jenkins installed maven and i had previouse installations that misslead me! Sometimes its just better to just start over and do it right.