I have been trying for several days to get the spring boot 15 minute hello world working. I keep encountering the following error:
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.warn(SLF4JLocationAwareLog.java:179)
at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:91)
at org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:810)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at com.symphony.Application.main(Application.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
I know this question appears elsewhere on the site, I have tried countless things and nothing works. I am using IntelliJ 2016.1.3, Java version 1.8.0._60.
My pom.xml is:
<?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.spring</groupId>
<artifactId>com.spring</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.7.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I have tried maven clean from IntelliJ and no luck.
EDIT: Screenshot added to show everything being pulled into project.
Maven Dependencies
UPDATE: Completely uninstalled maven 3.3.9 and only have the built in maven from IntelliJ ultimate. Still not working, extremely frustrating. Over a week into this and can't get the 15 minute demo working.
You appear to have an incompatibility with versions of logging frameworks. See if replacing the spring-boot-starter and spring-web artifacts with spring-boot-starter-web helps, as per the current Getting Started guide.
Update
I was able to configure and build the Spring Getting Started guide down to the Add Unit Tests heading without error on Intellij Ultimate 2016.2 using its own embedded Maven 3, and on the command-line using Maven 3.1.1 and Java 8 (1.8.0_31-b13).
I found significant build errors and/or execution errors when I:
changed the Maven configuration in Intellij to use Maven 2
compiled with the spring-boot-starter and spring-web artifacts rather than spring-boot-starter-web.
I think your problem is a build configuration error. Whenever I get these, I go back to command-line to build and run just to be sure the problem isn't an artifact of some IDE bug.
I've run in the same problem, but got it solved by excluding logback-classic
So my pom now Looks like this:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
If you're in Eclipse (idk, if IntelliJ has this Feature too) and look at the dependency hierarchy tab, you'll see, spring-boot itself implements multiple slf4j-apis.
Visualization of the dependency hierarchy filtered by "slf4j"
I know it may be too late for you, but your post was one of the first result by Google, so maybe it'll help someone else.
your pom lists java 8, but you said you are using java 6 for the project. make sure your project is pointing to a Java 8 ddk.
Related
I am following this guide: https://spring.io/guides/gs/serving-web-content/,
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/>
</parent>
<groupId>org.example</groupId>
<artifactId>plats-bruts</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
but I have this problem on the pom:
Project 'org.springframework.boot:spring-boot-starter-parent:2.4.0' not found
but Its here https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.4.0
I just ran into a similar problem. I'm using IntelliJ IDEA Ultimate 2020.2. The version number 2.4.0 was red and the message was the same as yours.
Selecting File -> Invalidate Caches / Restart... and choosing the Invalidate and Restart option fixed the issue. I guess it was just a stale cache.
What worked for me was re-building and remote caches and then local caches. Here're the steps I followed (on Mac, please translate to your target environment):
Goto Preferences Menu: ie: IntelliJ IDEA > Preferences
Under Build Tools: ie: "Build, Execution, Deployment" > Build Tools
Select Repositories: ie: Maven > Repositories
Notice the Remote and Local repositories, and the Update button
Select Each repository and click Update. This will take a while depending on your internet speed, but it will do a complete check of the broken downloads and stale Maven caches
Spring Boot's starter parent pom certainly does exist in Maven Central.
I copied your pom.xml and ran mvn test using Maven 3.6.3. All required libraries, including the parent pom were downloaded just fine. You will probably want to look at your ~/.m2/settings.xml file to see if any proxies are active that are preventing you from connecting to Maven Central.
Just reload your Maven project in the IDE. It will work.
Probably you are trying to run mvn spring-boot:run directly.
You can use the wrapper instead cf. ./mvnw spring-boot:run This should fix your problem.
I'm using IntelliJ IDEA Ultimate 2021.1.1. The version number 2.5.4 Spring Boot.
I just restarted Intellij and the error was fixed.
In my case mvn clean and than mvn package helped me with the same problem.
Short Answer: Double check if your internet provider is blocked maven repohttps://repo.maven.apache.org/maven2/ site mistakenly.
I also encounter with this problem. For my case, I tried everything, like invalidate cache and restart Intellij, re-import the maven dependencies. But those are not working for me.
When I try to re-import the maven dependencies with my mobile data, then everything is okay. So, there was a problem with my internet provider.
After I inform them, then I was fixed. Thanks
I'm getting this kotlin exception when trying to run some PACT tests using Java and not sure how to fix it please.
Here the error :
Exception in thread "Thread-2" java.lang.NoSuchMethodError:
kotlin.io.ByteStreamsKt.readBytes(Ljava/io/InputStream;)[B
EDIT
I've updated my PACT dependencies to use more up to date versions, and I'm still getting the same issue, however only when I have the below dependency as part of it and not sure why.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
This is my current pom:
<?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.hmhco</groupId>
<artifactId>update-catalog</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
<properties>
<rest-assured.version>3.0.0</rest-assured.version>
<json-schema-validator.version>3.3.0</json-schema-validator.version>
</properties>
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${json-schema-validator.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-consumer-junit5</artifactId>
<version>4.0.10</version>
</dependency>
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-junit</artifactId>
<version>4.0.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-maven</artifactId>
<version>4.0.10</version>
<configuration>
<pactDirectory>target/pacts</pactDirectory>
<pactBrokerUrl>http://pact-broker-hmh.devel.hmheng-qe.brnp.internal/</pactBrokerUrl>
<projectVersion>${project.version}</projectVersion>
<trimSnapshot>true</trimSnapshot>
</configuration>
</plugin>
</plugins>
</build>
And that's what I see when look for Kotlin after running maven dependency tree. The complete project can be found here.
Thanks very much.
A possible reason you are getting that error (I'm assuming) is because you are mixing major versions of the Pact libraries.
<pact.version>3.5.24</pact.version>
<pact-jvm-provider-maven.version>3.5.9</pact-jvm-provider-maven.version>
<pact-jvm-maven.version>3.5.24</pact-jvm-maven.version>
<pact.jvm.consumer.junit.version>4.0.10</pact.jvm.consumer.junit.version>
You have versions 3.5.9, 3.5.24 and 4.0.10. You should use the same major version.
Versions 3.5.x are mostly written in Kotlin (probably version 1.2.x), while version 4.0.x is written using Kotlin 1.3.x.
I'm not sure why Sprinboot is impacting things, but maybe a Spring dependency is also bringing in a version of the Kotlin standard library.
The best thing to do is use version 4.0.10 for all the Pact libraries, then run the Maven dependency tree plugin and check that versions of the Kotlin standard libraries that are being used.
I'm trying to create a maven project in intellij, to create a parser in antlr. Here is my pom.xml:
<?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.mua</groupId>
<artifactId>json-parser-java-antlr</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Json parser Java ANTLR</name>
<packaging>jar</packaging>
<description>Trying to create a parser using ANTLR in Java, as facing problems with LLVM</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.io</artifactId>
</dependency>
</dependencies>
</project>
When I click on import changes, it loads for just 1-2 seconds then done. But if I try to import MapUtils from org.apache.commons.collections4.MapUtils it says it can't resolve common, although I added in <groupId>org.apache.commons</groupId> dependency.
I'm new in maven project creation and management.
So, what is the problem here and how can I resolve this problem ?
I studied some pom.xml and found a parent attribute. No idea how to configure that.
My Eclipse editor shows:
Project build error: 'dependencies.dependency.version' for org.antlr:antlr4-runtime:jar is missing.
Project build error: 'dependencies.dependency.version' for org.apache.commons:commons-collections4:jar is missing.
Project build error: 'dependencies.dependency.version' for org.apache.directory.studio:org.apache.commons.io:jar is missing.
None of the dependencies work, because it doesn't know which version of them you want.
Specifying dependencies without a version is something you do when you have a parent pom. You don't, so versions are mandatory.
You could try adding a specific version of antlr to your pom.xml. And if you are using the antlr plugin as well, make sure the version of antlr run-time you are using is the same as the built-in version of the plugin.
I m trying to get started with cucumber but i can't seem to figure out why the *.feature file isn't recognised.
This is what I did till this point :
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>groupId</groupId>
<artifactId>untitled1</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.8.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jayway.restassured/rest-assured -->
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Then I made a package called features under test\java, in this package when i make the *.feature file, it comes up with a "?" next to it and it dosen't open, this should be a cucumber file right?
I have compiled the whole thing, it worked with no errors
You are using a really recent version of Cucumber (thnx!) and sometimes the IDE plugins take a while to catch up:
1. Try to upgrade your IDE and the plugin.
2. Search YouTrack for known issues related to the Cucumber plugin (and please upvote them!) or create one if it doesn't already exists.
3. Downgrade to a slightly older version of Cucumber that is working with your IDE.
I am using Spring Tool Suite 3.1.0.RELEASE and the pom.xml file in every project that I create has a single error entitled "org.apache.maven.plugin.jar.JarMojo". No further error details.
This error is present even in the auto generated pom.xml when creating a new Spring Utility Project.
It does not cause any errors during build, it is only shown in the IDE (top of the Overview tab in the pom editor and first line of pom.xml).
Anyone seen this before and knows how to fix it? Google has not been helpful.
Here is the default pom.xml generated by my Spring Tool Suite for a Spring Utility Project (it causes the error described):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples.spring</groupId>
<artifactId>spring-utility</artifactId>
<version>1.0.0.CI-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Spring Utility</name>
<url>http://www.springframework.org</url>
<description>
<![CDATA[
This project is a minimal jar utility with Spring configuration.
]]>
</description>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<spring.framework.version>3.0.6.RELEASE</spring.framework.version>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Fixed. I downloaded Maven 3.0.5 separately and extracted to C:\springsource\apache-maven-3.0.5. (STS was using Maven 3.0.3) Then in STS went to Windows->Preferences from the menu, searched for "installations" to find the Maven installations page. Added a new installation by pointing to the folder above. Applied. Then right clicked on existing project and chose Maven->Update Project. Error gone.
All new projects also don't have the error anymore. Win.
We faced the same issue with Eclipse Java EE IDE for Web Developers (Juno Service Release 2), POM.xml simply has this "org.apache.maven.plugin.jar.JarMojo" error as shown in the above diagram.
This seems a version issue with newer Maven. Finally we install an older C:\apache-maven-3.0.5
Then inside Eclipse -> Windows -> Preference -> search "Maven" -> Installations, add the External C:\apache-maven-3.0.5
Then go Project -> Clean
and right click on existing proect -> Maven -> Update Projects
and maybe restart EClipse.
The error status will disappear.
convert the packaging from jar to war. This solved my problem.