I am creating a web app and at the moment I'm trying to get a tomcat server to run. However I get this error message when ran from the cmd line.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tomcat/uti
l/http/mapper/Mapper
at org.apache.catalina.core.StandardContext.<init>(StandardContext.java:457)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:532)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:526)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:207)
at hello.Server.createTomcatServer(Server.java:34)
at hello.Application.main(Application.java:57)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.http.mapper.
Mapper
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
This 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>org.springframework</groupId>
<artifactId>gs-relational-data-access</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RC4</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.52</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<properties>
<start-class>hello.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
And finally my tomcat server code:
public void createTomcatServer() throws ServletException, LifecycleException{
Tomcat tomcat = null;
Integer webPort = new Integer(9696);
tomcat.setPort(webPort);
tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
System.out.println("configuring app with basedir: " + new File("./" + webappDirLocation).getAbsolutePath());
tomcat.start();
tomcat.getServer().await();
}
I thought I had included all the correct dependencies, etc. But I just cant find out why its not working - I've looked all over google already - so any help would be greatly appreciated.
I encountered the same problem as well and solved it by depending on the embed module instead.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${embedded.tomcat.version}</version>
</dependency>
Related
Using the handler org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest I'm receiving the following error when calling my API Gateway endpoint with the payload below. The function is found and it runs the business logic correctly until it returns and throws this NullPointerException:
Cannot invoke "java.util.Map.size()" because "m" is null: java.lang.NullPointerException
java.lang.NullPointerException: Cannot invoke "java.util.Map.size()" because "m" is null
at java.base/java.util.HashMap.putMapEntries(HashMap.java:495)
at java.base/java.util.HashMap.<init>(HashMap.java:484)
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.enrichInvocationResultIfNecessary(SimpleFunctionRegistry.java:757)
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeFunctionAndEnrichResultIfNecessary(SimpleFunctionRegistry.java:914)
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeFunction(SimpleFunctionRegistry.java:863)
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:716)
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:559)
at org.springframework.cloud.function.adapter.aws.FunctionInvoker.handleRequest(FunctionInvoker.java:85)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
END
However, according to the documentation I should be using the handler org.springframework.cloud.function.adapter.aws.SpringBootApiGatewayRequestHandler::handleRequest but when I do so it does not find the function. I have set both FUNCTION_NAME and MAIN_CLASS environment variables to their respective values.
Class not found: org.springframework.cloud.function.adapter.aws.SpringBootApiGatewayRequestHandler: java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: org.springframework.cloud.function.adapter.aws.SpringBootApiGatewayRequestHandler
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
END RequestId: 83965357-a424-4c0f-b846-7486245380c7
Function
public class Makeuser implements Function<Message<APIGatewayRequest>, Message<User>> {
#Override
public Message<User> apply(Message<APIGatewayRequest> request) {
...
}
}
Application
#SpringBootApplication
public class DemoApplication{
public static void main(String[] args) {
}
}
Request Payload
{
"userRequest": {
"firstName": "userfirst",
"lastName": "userlast",
"email": "user#gmail.com",
"age": 21
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>4.0.0.RELEASE</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Non-native demo application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<wrapper.version>1.0.28.RELEASE</wrapper.version>
<aws-lambda-events.version>3.11.0</aws-lambda-events.version>
<spring-cloud-function.version>4.0.0-SNAPSHOT</spring-cloud-function.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-aws</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>${aws-lambda-events.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.github.derjust</groupId>
<artifactId>spring-data-dynamodb</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.12.272</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-dependencies</artifactId>
<version>${spring-cloud-function.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>${wrapper.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>aws</shadedClassifierName>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
This is the documentation I'm working from: https://docs.spring.io/spring-cloud-function/docs/4.0.0-SNAPSHOT/reference/html/aws.html
Update
I switched the spring-cloud-function version from 4.0.0.RELEASE to 3.2.6 and updated the Function class to remove the Message types. The lambda succeeds in test but fails when making the request from Postman to the API Gateway.
Function
public class Makeuser implements Function<APIGatewayRequest, User> {
#Override
public Message<User> apply(APIGatewayRequest request) {
...
return user;
}
}
Stacktrace
Successfully saved user to database 2d1ed481-999e-4e2d-afc0-62f5315c8f4b user1first user1last user1#gmail.com 21
org/springframework/http/HttpStatus: java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError: org/springframework/http/HttpStatus
at org.springframework.cloud.function.adapter.aws.AWSLambdaUtils.generateOutput(AWSLambdaUtils.java:196)
at org.springframework.cloud.function.adapter.aws.FunctionInvoker.buildResult(FunctionInvoker.java:147)
at org.springframework.cloud.function.adapter.aws.FunctionInvoker.handleRequest(FunctionInvoker.java:114)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
Caused by: java.lang.ClassNotFoundException: org.springframework.http.HttpStatus
... 7 more
END RequestId: 3811dd35-342c-4088-7ef4-f3ed86798b9f
I have a project in which I have used Juint5 for creating tests and test suites. I want to run the test suite via the pom file. Below is the pom file and test suit which I have created. when I run the mvn clean
it does not execute any tests but when I manually run the test suite run as JUnit test all the test cases are executed
can someone please help me here?
Suite file
#RunWith(JUnitPlatform.class)
#SelectClasses( {TestA.class,TestB.class} )
#IncludeTags("unitTest")
public class Testsuite
{
}
classes
public class TestA
{
#Test
#Tag("unitTest")
static void myMethod1()
{
System.out.println("Hello World!");
}
}
public class TestB
{
#Test
#Tag("unitTest")
static void myMethod2()
{
System.out.println("Hello World!");
}
}
pom file entry
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>**/Testsuite*</include>
</includes>
</configuration>
</plugin>
full pom file
<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.junit.karte.emo</groupId>
<artifactId>cg-automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- <packaging>jar</packaging> -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<cucumber.reporting.version>5.3.1</cucumber.reporting.version>
<karate.version>0.9.6</karate.version>
<junit.runner.version>1.0.18</junit.runner.version>
<commons.lang3.version>3.11</commons.lang3.version>
<jsch.version>0.1.55</jsch.version>
<junit.jupiter.engine.version>5.6.2</junit.jupiter.engine.version>
<junit-jupiter-api.version>5.8.0-M1</junit-jupiter-api.version>
<junit.platform.runner>1.6.2</junit.platform.runner>
<cg_password>n</cg_password>
<host_ip>10.204.100.136</host_ip>
<host_usrname>root</host_usrname>
<host_password>n</host_password>
<build_name>change_guardian-6.2</build_name>
<custom_path>/usr</custom_path>
<cg_version>8.5.0.0.13</cg_version>
<web_port>8443</web_port>
<win_host>vlab007206</win_host>
<win_ip>10.204.108.65</win_ip>
<win_user>administrator#cgdom100.lab</win_user>
<win_password>Control4321</win_password>
<asset_type>win</asset_type>
<unix_host>vlab007201</unix_host>
<unix_ip>10.204.100.136</unix_ip>
<unix_user>root</unix_user>
<unix_password>n</unix_password>
<base_build>change_guardian-6.1</base_build>
<basecg_version>8.3</basecg_version>
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.surefire.version>2.22.2</maven.surefire.version>
<maven.site.version>3.7.1</maven.site.version>
<maven.surefire.report.version>3.0.0.M5</maven.surefire.report.version>
<maven.project.info.reports.version>3.0.0</maven.project.info.reports.version>
<runSuite>StanderdPathInstall.java</runSuite>
<groups>StanderdPathInstall</groups>
</properties>
<repositories>
<repository>
<id>sm.releases</id>
<name>NetIQ Security Management site - RELEASES</name>
<url>https://btpartifactory.swinfra.net:443/artifactory/security-sentinel-mvn-releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>${repository-updatePolicy}</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>${repository-updatePolicy}</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
<repository>
<id>sm.snapshots</id>
<name>NetIQ Security Management site - SNAPSHOTS</name>
<url>https://btpartifactory.swinfra.net:443/artifactory/security-sentinel-mvn-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>${repository-updatePolicy}</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>apache.central</id>
<name>Apache Maven Central Repository</name>
<url>https://repository.apache.org/content/repositories/releases/</url>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
<repository>
<id>maven2-maven-org</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.pantsbuild</groupId>
<artifactId>junit-runner</artifactId>
<version>${junit.runner.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>${jsch.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.runner}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>StanderdPathInstall.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven.site.version}</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven.surefire.report.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${maven.project.info.reports.version}</version>
</plugin>
</plugins>
</reporting>
</project>
My solution is
Add #Tag annotation before each test which I want to run
Add tag under the maven-surefire-plugin, e.g integration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>integration</groups>
</configuration>
</plugin>
Run maven command: mvn test -Dgroups="integration"
I am trying to run my first springboot application but facing some issues.
In my application file, this is my code
package com.clog.ServiceMgmt;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
#SpringBootApplication
#EntityScan("models")
#ComponentScan({"com.clog.ServiceMgmt","controllers", "models", "repositories"})
#EnableJpaRepositories(basePackages={"repositories"})
public class ServiceMgmtApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceMgmtApplication.class, args);
}
}
but when i run my application, i get the following error. confused as to why i should get this error and how to solve it.
org.springframework.core.annotation.AnnotationConfigurationException:
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.autoconfigure.SpringBootApplication] is
declared as an #AliasFor nonexistent attribute 'proxyBeanMethods' in
annotation [org.springframework.context.annotation.Configuration].;
nested exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
This is 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 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.2.0.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.clog</groupId>
<artifactId>ServiceMgmt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ServiceMgmt</name>
<description>Service Mgmt</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<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</artifactId>
</dependency>
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</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>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
Does anyone have an idea of how to fix this issue?
Thanks
from spring-projects-github
" proxyBeanMethods is new in 5.2 and I can see 5.1.2.RELEASE in some elements of the stack."
do a dependency:tree and double check that spring match >= 5.2, I had a similar issue and one library brought 5.1 overriding v5.2 from springboot
Had same problem few days ago. Try to change spring-boot-starter-parent version to 2.1.3.RELEASE, thats resolved my problem.
use this in your main springboot application class :#SpringBootApplication(proxyBeanMethods = false)
this will work .
I had this error happen in a Spring Boot project where I added a custom dependency that made use of Spring (not Spring Boot). The issue in my custom dependency was that it had the following plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example.Main</mainClass>
<manifestEntries>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Vendor>Vendor Name, ${timestamp}</Implementation-Vendor>
</manifestEntries>
</transformer>
</transformers>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
Once I removed the shade plugin from my custom dependency, the error disappeared.
I removed the following dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
And the code was up like magic
I executed this command
mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=crawler.Crawler
and found this
An exception occured while executing the Java class. org/apache/log4j/Logger
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" si:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
<repository>
<id>twitter4j.org</id>
<name>twitter4j.org Repository</name>
<url>http://twitter4j.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
second part
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Error
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
You need to add dependency on log4j
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
to your pom.xml file (after dependency on junit).
You can read about this dependency in maven repo:
http://mvnrepository.com/artifact/log4j/log4j/1.2.17
I am busy developing a Vaadin with Maven project. I would like to integrate Hibernate with this project, but I can't do it.
I've added the dependencies and libraries, but Hibernate does not work.
This is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bd</groupId>
<artifactId>achrefvaadin</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Vaadin Web Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>6.7.0</vaadin.version>
<gwt.version>2.3.0</gwt.version>
<gwt.plugin.version>2.2.0</gwt.plugin.version>
</properties>
<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>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.24</version>
<configuration>
<stopPort>9966</stopPort>
<stopKey>achrefvaadin</stopKey>
<!-- Redeploy every x seconds if changes are detected, 0 for no automatic redeployment -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<!-- make sure Jetty also finds the widgetset -->
<webAppConfig>
<contextPath>/achrefvaadin</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<!-- Workaround for Maven/Jetty issue http://jira.codehaus.org/browse/JETTY-680 -->
<!-- <resources>src/main/webapp,${project.build.directory}/${project.build.finalName}</resources> -->
<resourcesAsCSV>src/main/webapp,${project.build.directory}/${project.build.finalName}</resourcesAsCSV>
</baseResource>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
</dependencies>
</project>
Can you help me?
Try this 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bd</groupId>
<artifactId>achrefvaadin</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Vaadin Web Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>6.7.0</vaadin.version>
<gwt.version>2.3.0</gwt.version>
<gwt.plugin.version>2.2.0</gwt.plugin.version>
</properties>
<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>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.24</version>
<configuration>
<stopPort>9966</stopPort>
<stopKey>achrefvaadin</stopKey>
<!-- Redeploy every x seconds if changes are detected, 0 for no automatic redeployment -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<!-- make sure Jetty also finds the widgetset -->
<webAppConfig>
<contextPath>/achrefvaadin</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<!-- Workaround for Maven/Jetty issue http://jira.codehaus.org/browse/JETTY-680 -->
<!-- <resources>src/main/webapp,${project.build.directory}/${project.build.finalName}</resources> -->
<resourcesAsCSV>src/main/webapp,${project.build.directory}/${project.build.finalName}</resourcesAsCSV>
</baseResource>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
</dependencies>
</project>
If you are including just hibernate-entitymanager Maven will download hibernate-core, hibernate-annotations and hibernate-commons-annotations on it's own in the right version.