Here is a (simplified) piece of code and the related unit test I wrote, and for which I was happy until recently.
File vars/deleteFile.groovy
#NonCPS
def call(String path) {
new File(path).delete() //Must be declared as authorized class & method in Jenkins
}
File vars/toto.groovy:
def call(Map params = [:] ) {
...
deleteFile(params.get('envFile'))
...
}
File tests/vars/TotoSpec.groovy:
class TotoSpec extends JenkinsPipelineSpecification {
def toto = null
def setup() {
toto = loadPipelineScriptForTest('vars/toto.groovy')
...
}
def '[toto] test env file'() {
when:
toto envFile: 'env.list'
then:
...
1 * getPipelineMock('deleteFile.call').call('env.list')
}
}
The test used to pass both on my local machine and the CI slave. However, I don't know why, this started to fail on my local machine (but not on the slave):
java.lang.IllegalStateException:
There is no pipeline step mock for [deleteFile.call].
1. Is the name correct?
2. Does the pipeline step have a descriptor with that name?
3. Does that step come from a plugin? If so, is that plugin listed as a dependency in your pom.xml?
4. If not, you may need to call explicitlyMockPipelineStep('deleteFile.call') in your test's setup: block.
at TotoSpec.[toto] test env file(TotoSpec.groovy:90)
I therefore performed the following update on my unit test, though I'm not sure if deleteFile is really a pipeline step since it has no body/closure.
File tests/vars/TotoSpec.groovy:
class TotoSpec extends JenkinsPipelineSpecification {
def setup() {
toto = loadPipelineScriptForTest('vars/toto.groovy')
explicitlyMockPipelineStep('deleteFile')
...
}
def '[toto] test env file'() {
when:
toto envFile: 'env.list'
then:
...
1 * getPipelineMock('deleteFile').call('env.list')
}
}
Now the unit test is OK on my local machine, but fails on the CI slave:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'Mock Generator for [deleteFile]' with class 'com.homeaway.devtools.jenkins.testing.PipelineVariableImpersonator' to class 'groovy.lang.Closure'
at TotoSpec.setup(TotoSpec.groovy:32)
What am I missing ?
Local configuration:
$ java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-120.04, mixed mode, sharing)
mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 14.0.2, vendor: Private Build, runtime: /usr/lib/jvm/java-14-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.19.128-microsoft-standard", arch: "amd64", family: "unix"
CI Slave configuration:
$ java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1bpo91)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1bpo91, mixed mode)
$ /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.3/apache-maven-3.6.3/bin/mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.3/apache-maven-3.6.3
Java version: 11.0.6, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: fr_FR, platform encoding: UTF-8
OS name: "linux", version: "4.9.0-14-amd64", arch: "amd64", family: "unix"
Dependencies in pom.xml
<properties>
<groovy.core.version>2.4.17</groovy.core.version>
<groovy.gmaven.pluginVersion>1.6.1</groovy.gmaven.pluginVersion>
<google.guava.version>20.0</google.guava.version>
<jenkins-spock.version>2.0.0</jenkins-spock.version>
<jenkins.version>2.102</jenkins.version>
<jenkins.servlet.version>3.1.0</jenkins.servlet.version>
<jenkins.workflow.cps.version>2.36</jenkins.workflow.cps.version>
<jenkins.workflow.basic.steps.version>2.6</jenkins.workflow.basic.steps.version>
<jenkins.workflow.durable.task.step.version>2.21</jenkins.workflow.durable.task.step.version>
<jenkins.workflow.stage.step.version>2.3</jenkins.workflow.stage.step.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<junit.plugin.version>1.24</junit.plugin.version>
<surefire.pluginVersion>2.22.0</surefire.pluginVersion>
<logback.configration>logback-test.xml</logback.configration>
<logdir>${project.build.directory}/log</logdir>
<test.loglevel>ERROR</test.loglevel>
<log.logback.version>1.2.3</log.logback.version>
<log.slf4j.version>1.7.25</log.slf4j.version>
</properties>
...
<dependencies>
<dependency>
<groupId>com.homeaway.devtools.jenkins</groupId>
<artifactId>jenkins-spock</artifactId>
<version>${jenkins-spock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${log.logback.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${log.logback.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
<version>${jenkins.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>${jenkins.workflow.basic.steps.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${jenkins.workflow.cps.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- provides sh() step -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>${jenkins.workflow.durable.task.step.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- provides stage() step -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-stage-step</artifactId>
<version>${jenkins.workflow.stage.step.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${jenkins.servlet.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>${junit.plugin.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.core.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${log.slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${log.slf4j.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Having carefully read the documentation again, since deleteFile is declared by myself in the vars directory, it is considered as a Pipeline Shared Library Global Variable.
Therefore, switching to the following unit test now works correctly everywhere:
class TotoSpec extends JenkinsPipelineSpecification {
def setup() {
toto = loadPipelineScriptForTest('vars/toto.groovy')
explicitlyMockPipelineVariable('deleteFile')
...
}
def '[toto] test env file'() {
when:
toto envFile: 'env.list'
then:
...
1 * getPipelineMock('deleteFile.call').call('env.list')
}
}
It remains unclear why I suddenly needed to use explicitlyMockPipelineVariable('deleteFile') on my machine, though.
Related
I am trying to migrate my Cucumber automation project from cucumber (info.cukes ) to cucumber (io.cucumber)
During this process, i having trouble with migrating extend reports. Could you please help me with what I am missing?
dependency:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.6</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>4.2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-html -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.7</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.26-incubating</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
Runner class:
package CucumberWithAfterStep.AfterStepPOC;
import java.io.File;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(features = "src/test/resources/features", glue = { "testSteps" }, plugin = { "pretty",
"html:target/cucumber", "json:target/cucumber.json" , "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
monochrome = true,
tags = {"#WAC003 "}, dryRun = false)
public class MainRunnerTest {
#AfterClass
public static void writeExtentReport() {
Reporter.loadXMLConfig(new File(FileReaderManager.getInstance().getConfigReader().getReportConfigPath()));
}
}
Error:
cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter. It does not implement
cucumber.api.Plugin
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:176)
at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:163)
at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:220)
at cucumber.runtime.formatter.PluginFactory.isStepDefinitionReporterName(PluginFactory.java:203)
at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:386)
at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:165)
at cucumber.runtime.RuntimeOptions.(RuntimeOptions.java:108)
There are 2 ways of implementing extent report in Cucumber
1. Using Cucumber-JVM 4 adapter for Extent Framework(extentreports-cucumber4-adapter) & below are the steps to implement -
Add adapter dependency under POM.XML
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber4-adapter</artifactId>
<version>1.0.6</version>
</dependency>
Add the com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter plugin to the runner.
#RunWith(Cucumber.class)
#CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})
public class RunCukesTest {
// ..
}
Report Output Directory - ../Project Directory/test-output/HtmlReport
2. Adding aventstack dependency under POM.XML
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
In this workflow, Do not Add the com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter plugin to the runner.
I had the same issue. you can use the following combination of dependencies,
Cucumber-core 4.2.0
Cucumber-java 4.2.0
Cucumber-junit 4.2.0
extentreports-cucumber4-adapter 1.0.7
Please note Cucumber-extntsreport which is developed by vimalselvam is not supporting cucumber version 4. Because cucumber 4 is using event based reporting, not the formatter.
so remove this dependency.
cucumber-extentsreport 3.0.2
I am using Spring boot to develop a Spring batch application. I will need my application to write the data finally to MongoDB and thus needs to configure org.springframework.data.mongodb.core.MongoTemplate for org.springframework.batch.item.data.MongoItemWriter.
My pom.xml dependency section looks like this-
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<version>${spring.batch.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jongo/jongo -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jvnet.jaxb2_commons/jaxb2-basics-runtime -->
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>1.11.1</version>
</dependency>
<!--<dependency>-->
<!--<groupId>de.flapdoodle.embed</groupId>-->
<!--<artifactId>de.flapdoodle.embed.mongo</artifactId>-->
<!--<version>1.50.5</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>cz.jirutka.spring</groupId>-->
<!--<artifactId>embedmongo-spring</artifactId>-->
<!--<version>RELEASE</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.6.0</version>
</dependency>
</dependencies>
The application.properties file looks like this
spring.data.mongodb.host=mongohost
spring.data.mongodb.port=27017
spring.data.mongodb.authentication-database=authdb
spring.data.mongodb.username=user
spring.data.mongodb.password=pwd
spring.datasource.driver-class-name=<< I don't know what to put here >>
Main class is also simple enough and looks like this-
#SpringBootApplication
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
Now, whenever I try to run my Main class it gives out error
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
After researching a lot about this problem, I figured out that I need to let Spring know about my data store by providing the value of spring.datasource.driver-class-name in application.properties
spring.datasource.driver-class-name=com.mongodb.Server
If I provide com.mongodb.Server as my drive class name its not found on classpath and isn't recognised despite I have mongo java driver dependency on my classpath.
What should I put the value for mongoDB's driver-class-name provided I want to use mongo-java-driver?
If driver class name is not the cause of this issue, what should be the resolution of issue "Cannot determine embedded database driver class for database type NONE"mentioned in title of this question?
Try exluding DataSourceAutoConfiguration.class in your main class:
#SpringBootApplication
#EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
Also you don't need this:
spring.datasource.driver-class-name
unless you need jpa configuration as well.
Environment:
Ubuntu 14.04
Netbeans 8.0.2
JUnit 4.12
Hi (test class)
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class Hi {
#Test
public void hola(){
assertTrue(true);
}
}
pom.xml
...
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-processing</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
...
For a Maven projekt the test classes must be in src/test/java, not src/main/java.
I'm having trouble creating a JUnit test using a pom.xml dependency.
The test are being run with Arquillian
#RunWith(Arquillian.class)
In this method
#Deployment
public static JavaArchive createDeployment() {
First, I create a JavaArchive with the package of the project I'm testing
JavaArchive merge = ShrinkWrap.create(JavaArchive.class).
addPackages(true,
"migrazioneGeaPersistenzaTampone",
"migrazioneGeaPersistenza",
"it.**.mistral.importGEA4.task",
"migrazioneGeaPersistenzaAccess"
).
addClasses(java.sql.Connection.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
Then when I launch the test, there are some missing dependencies
Unable to resolve any beans for Types: [class it.**.**.be.service.EnvironmentRootService]
present in this dependency
<dependency>
<groupId>it.**.mistral</groupId>
<artifactId>mistral-be</artifactId>
<version>0.1.0</version>
<scope>compile</scope>
</dependency>
I have tried lots of different things to add these dependencies, the best one seems to be using the ShrinkWrap Resolvers (https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc, particullarry this paragraph https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc#resolution-of-artifacts-defined-in-pom-files)
a)
JavaArchive[] archives = Maven.resolver().loadPomFromFile(path_to_pom_file).
importDependencies(ScopeType.TEST,ScopeType.COMPILE).
resolve().withTransitivity().as(JavaArchive.class);
or
Maven.resolver().loadPomFromFile("/path/to/pom.xml").importRuntimeDependencies()
.resolve().withTransitivity().asFile();
The dependency is ignored in either way (i'm missing something?)
b)
JavaArchive[] mistral_be = Maven.configureResolver().workOffline().
resolve("it.**.mistral:mistral-be:0.1.0").withTransitivity().as(JavaArchive.class);
for (int i = 0; i < mistral_be.length ; i++) {
merge = merge.merge(mistral_be[i]);
}
With a simple
System.out.println(merge.toString(true));
I can see that all files from dependencies are present! Anyway I use local repository workoffline()
Maybe I am missing some dependencies?
But exiting the method with a
return merge;
throws a "java.lang.NoClassDefFoundError: com/google/protobuf/GeneratedMessage....Caused by: java.lang.ClassNotFoundException: com.google.protobuf.GeneratedMessage" error.
Then again i tried to add the missing dependecies
// Tryn'g to add protobuf dependencies
JavaArchive[] prto_buf = Maven.configureResolver().withMavenCentralRepo(true).resolve("com.google.protobuf:protobuf-java:2.3.0").withTransitivity().as(JavaArchive.class);
for (int i = 0; i < prto_buf.length ; i++) {
projectPackages = projectPackages.merge(prto_buf[i]);
}
Throws sameException...
Again , with a simple
System.out.println(merge.toString(true));
I can see that com.Google.protobuf.GeneratedMessage is present
Extract of dependencies:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.5.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
Can anybody help me solve this issue?
This smells to me like a classloading issue. Especially considering the fact that you are using embedded container which basically takes everything what's in there from your project classpath.
What is your target container you are deploying your application on? Maybe if you try to run your test there instead of embedded container you will at least see if that is really the problem, or there is still something wrong with your deployment artifact.
I am new to spring try to create application so that i can learn how its work. However when i wrote code Eclipse IDE gives
The type javax.servlet.http.HttpServletResponse cannot be resolved.It is indirectly referenced from required .class files
here is my class
package testPackage;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import domain.serviceLayer.UserService;
import domain.userDetails.User;
#SuppressWarnings("deprecation")
public class UserLoginFormController extends SimpleFormController {
private UserService userService;
public UserLoginFormController() {
setCommandClass(User.class);
setCommandName("user");
}
public void setUserService(UserService userService) {
this.userService = userService;
}
#Override
public ModelAndView onSubmit(Object command) throws Exception {
// TODO Auto-generated method stub
User user = (User) command;
userService.add(user);
ModelAndView modelAndView = new ModelAndView("success", "user", user);
return modelAndView;
}
}
and 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>learnSimpleFormController</groupId>
<artifactId>learnSimpleFormController</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<properties>
<spring.version>3.2.3.RELEASE</spring.version>
</properties>
<dependencies>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>learnSimpleFormController</finalName>
</build>
</project>
Please what is problem and how to remove that error
your project is not referencing to servlet.jar so just add this dependency in your pom
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
</dependency>
Your project is not referring to any Runtime environment.
You can do the folllwoing: import the jar file inside you class:
import javax.servlet.http.HttpServletResponse
add the Apache Tomcat library as follow:
Project > Properties > Java Build Path > Libraries > Add library > Server Runtime > Next > Apache Tomcat v 6.0 > Finish > Ok
I had same exception.
I am using spring-boot 1.5.3.RELEASE but my colleague is using spring-boot 1.5.4.RELEASE.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
So when I got his code, I got this exception.
May be in my PC I had old maven jar files of spring boot and maven could not update those jar files.
Even I deleted all folders of spring-boot from .m2 folder but still generating same error
Finally I got solution by changing the version of spring boot from 1.5.4 to 1.5.3 from pom.xml.