I am trying to deploy my application to Heroku, but I'm geting this message all the time. When I run it in IntelliJ the application is working.
The application is written in Spring Boot.
What could be the cause of this error?
Here is my pom.xml
I think the problem is due to a mismatch of the Java version in your project's pom.xml file and that being used by Heroku.
A simple solution could be either specify your target version in pom.xml or configure the Java version in Heroku. You can add the following code below <description> in your pom.xml file to specify your target version.
<properties>
<java.version>1.8</java.version>
</properties>
Related
I'm trying to deploy a spring boot application in Kubernetes hosted by Scaleway.
After the deployment, I have the following error :
java.lang.UnsupportedClassVersionError: xx/yy/zz/Application has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 58.0
My pom file has the following properties :
<properties>
<java.version>18</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
In my dockerfile configuration, I use the following config :
FROM --platform=linux/amd64 openjdk:14-jdk-alpine
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
I tried different versions without solving the problem.
Do you have an idea ?
You are compiling your application for a newer JVM than the container image, that is executing the application, provides.
You are also mixing the compiler settings with the old (maven.compiler) and newer (java.version) syntax.
Leaving out the "java.version" setting should fix your immediate issue.
The kubernetes configuration lacks the imagePullPolicy: Always property
When i create my spring Boot starter project im getting error as maven configuration problem. Please help me to solve.
enter image description here
Similar Bug was reported in eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340
You can fix this by temporary downgrading the maven jar plugin version to 3.1.1 from 3.1.2. Add this to the properties section:
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
In your pom.xml
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Update: A fix has been released. Click Help > Check for updates in Eclipse/STS and install the newest m2e connector.
I am creating bamboo plugin with java11 and maven project.
mvn clean install is returning success status with below NPE
java.lang.NullPointerException
at aQute.bnd.osgi.Processor.quote(Processor.java:1322)
at aQute.bnd.header.Attrs.append(Attrs.java:404)
at aQute.bnd.header.Parameters.append(Parameters.java:172).......
when tried uploading plugin in bamboo 6.8.1 with java11 then it throws failure error.
Firstly tried on hello world plugin as well as per pom.xml mentioned in URL:
https://community.atlassian.com/t5/Bamboo-questions/Create-bamboo-plugin-tutorial/qaq-p/686456
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<bamboo.version>6.2.3</bamboo.version>
<bamboo.data.version>6.2.3</bamboo.data.version>
<amps.version>6.2.3</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version>
<atlassian.plugin.key>${project.groupId}.${project.artifactId}
</atlassian.plugin.key>
</properties>
expecting bamboo plugin should get build without any error and should get upload successfully.
Bamboo doesn't work with Java 11 yet. So plugin should be built with Java 8 as well
Is there a way to have a single Spring Boot project be packagable into both JAR and WAR without changing the pom.xml or the application source?
I've read Converting a Spring Boot JAR Application to a WAR, but it converts the project to WAR and it loses the ability to be packaged as JAR.
I don't expect mvn package to do both. What I want is something like mvn i-want-a-jar and it would package the project as JAR. Or I could run mvn i-want-a-war and it would package the project as WAR.
Is this possible?
I managed to do it by adding
<packaging>${packaging.type}</packaging>
to the POM file and then setting different profiles for JAR and WAR:
<profiles>
<profile>
<id>jar</id>
<properties>
<packaging.type>jar</packaging.type>
</properties>
</profile>
<profile>
<id>war</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Now mvn package -P war produces a WAR and mvn package -P jar produces a JAR.
Another option is to create separate modules for JAR and WAR, but I didn't go that route.
What's wrong with a WAR file that's executable? Isn't that what you really need?
P.S. like
java -jar name.war
We've recently had a similar requirement, where an existing Spring Boot based project that was originally packaged as an executable Jar needed to support Tomcat and WildFly deployments.
Due to some dependencies used in this project (for example WebJars), a simple switch to WAR package wasn't an option since some of those dependencies were required for WildFly (VFS support) but not for other deployment.
The solution was to restructure the project modules in a way that core module contained the actual project but without having Spring Boot’s plugin applied, while several package modules would depend on core module and configure deployment artifact specifics (Boot and other plugins, deployment specific dependencies etc.).
That way project build was able to generate multiple deployment artifacts (Boot's executable JAR, traditional WAR and WildFly specific WAR) in a single build run.
In case anyone finds this useful, the sample project to demonstrate the approach is available on Github. The project can be built by either Gradle or Maven.
I have a strange issue and that I have not been able to resolve. I am trying to use the sample JPA sprint boot (v0.5.0-M6) project as a starting point for an application I am writing. I grabbed the JPA sample and got that to run locally. I then proceeded to add my code into that project. I imported into eclipse and run as spring-boot. Then I get this error:
Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.springframework.core.io.DefaultResourceLoader$ClassPathContextResource from class org.springframework.boot.context.embedded.EmbeddedWebApplicationContext
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getResourceByPath(EmbeddedWebApplicationContext.java:386)
at org.springframework.core.io.DefaultResourceLoader.getResource(DefaultResourceLoader.java:100)
at org.springframework.context.support.GenericApplicationContext.getResource(GenericApplicationContext.java:211)
at org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer.load(ConfigFileApplicationContextInitializer.java:192)
at org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer.load(ConfigFileApplicationContextInitializer.java:134)
at org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer.initialize(ConfigFileApplicationContextInitializer.java:121)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:403)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:287)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:749)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:738)
From what I can tell, this is the wrong application context, since I am not using XML configuration but annotations to drive the configuration. Spring boot is automatically selecting this one and I need to tell it not to use the above. At least that is what I think I need to do.
I did search here and in the spring.io forums but no one seems to have the same issue.
Question: What drives the selection of an application context with the auto configuration?
What should I be looking at to resolve the above issue? What else do I need to provide to here help debug the auto configuration issue?
TIA,
Scott
I got the same problem.
if you use maven check your pom.xml
remove conflict version in Spring Lib.
<properties>
<hibernate.version>4.2.0.Final</hibernate.version>
<mysql.connector.version>5.1.21</mysql.connector.version>
<spring.version>3.2.2.RELEASE</spring.version>
</properties>
i remove this line
<spring.version>3.2.2.RELEASE</spring.version>
and in maven dependency just
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
Hope this help.
I was facing the same problem, and solved fixing the referencing to the boot-starter-parent pom.
At the pom.xml file I used:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>0.5.0.M6</version>
</parent>
I have some urgent issues to fix now, so I didn't inspected this parent pom to see what's so important here, but I hope this can help you - don't forget to verify the version you're using!