I am somewhat new to api's and servlets and have been developing a servlet to act as an api for a MySQL database, after a while i realised that the maven project i was making did not Compile as a war file, to make it compile as a war file i added these lines
Appilcation.java
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
and also war in my pom file, it now does generate a war file however i am now getting these errors. This is a group project so other code may have been changed but this is as much as I know.
EDIT: after adding the new dependancy to my pom the new errors i get are
Using CATALINA_BASE: "C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33"
Using CATALINA_HOME: "C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33"
Using CATALINA_TMPDIR: "C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_73"
Using CLASSPATH: "C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\bin\bootstrap.jar;C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\bin\tomcat-juli.jar"
28-Apr-2016 16:23:34.997 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.33
28-Apr-2016 16:23:35.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Mar 18 2016 20:31:49 UTC
28-Apr-2016 16:23:35.001 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.33.0
28-Apr-2016 16:23:35.001 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
28-Apr-2016 16:23:35.002 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
28-Apr-2016 16:23:35.002 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
28-Apr-2016 16:23:35.002 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_73\jre
28-Apr-2016 16:23:35.002 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_73-b02
28-Apr-2016 16:23:35.003 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
28-Apr-2016 16:23:35.003 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33
28-Apr-2016 16:23:35.003 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33
28-Apr-2016 16:23:35.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dhttp.nonProxyHosts=localhost|127.0.0.1|DESKTOP-LFKQO6C
28-Apr-2016 16:23:35.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\logging.properties
28-Apr-2016 16:23:35.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
28-Apr-2016 16:23:35.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\endorsed
28-Apr-2016 16:23:35.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33
28-Apr-2016 16:23:35.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33
28-Apr-2016 16:23:35.006 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\temp
28-Apr-2016 16:23:35.006 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.5 using APR version 1.5.1.
28-Apr-2016 16:23:35.007 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
28-Apr-2016 16:23:36.053 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2g 1 Mar 2016)
28-Apr-2016 16:23:36.294 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
28-Apr-2016 16:23:36.311 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
28-Apr-2016 16:23:36.313 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2299 ms
28-Apr-2016 16:23:36.367 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
28-Apr-2016 16:23:36.368 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.33
28-Apr-2016 16:23:36.383 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\mavenproject1.xml
28-Apr-2016 16:23:36.530 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mavenproject1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@47ebf2f8]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4927)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5057)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 10 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Users\systo\Documents\NetBeansProjects\mavenproject1\target\mavenproject1-1.0-SNAPSHOT] is not valid
at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:723)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:684)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 13 more
28-Apr-2016 16:23:36.533 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\mavenproject1.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mavenproject1]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
28-Apr-2016 16:23:36.537 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\mavenproject1.xml has finished in 152 ms
28-Apr-2016 16:23:36.537 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\ROOT.xml
28-Apr-2016 16:23:39.327 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.3.RELEASE)
28-Apr-2016 16:23:43.879 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\ROOT.xml has finished in 7,341 ms
28-Apr-2016 16:23:43.879 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\Spring4MVCCRUDRestService.xml
28-Apr-2016 16:23:45.444 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Spring4MVCCRUDRestService]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Failed to register servlet with name 'dispatcher'.Check if there is another servlet registered under the same name.
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.registerDispatcherServlet(AbstractDispatcherServletInitializer.java:97)
at org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.onStartup(AbstractDispatcherServletInitializer.java:70)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5240)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 10 more
28-Apr-2016 16:23:45.445 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Error deploying configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\Spring4MVCCRUDRestService.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Spring4MVCCRUDRestService]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
28-Apr-2016 16:23:45.446 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\Spring4MVCCRUDRestService.xml has finished in 1,567 ms
28-Apr-2016 16:23:45.446 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\docs
28-Apr-2016 16:23:45.495 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\docs has finished in 49 ms
28-Apr-2016 16:23:45.496 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\examples
28-Apr-2016 16:23:45.846 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\examples has finished in 350 ms
28-Apr-2016 16:23:45.847 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\host-manager
28-Apr-2016 16:23:45.902 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\host-manager has finished in 56 ms
28-Apr-2016 16:23:45.902 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\manager
28-Apr-2016 16:23:45.939 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\webapps\manager has finished in 37 ms
28-Apr-2016 16:23:45.944 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
28-Apr-2016 16:23:45.962 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
28-Apr-2016 16:23:45.965 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 9651 ms
28-Apr-2016 16:23:46.929 INFO [http-apr-8080-exec-5] org.apache.catalina.startup.HostConfig.undeploy Undeploying context []
28-Apr-2016 16:23:46.967 INFO [http-apr-8080-exec-10] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\code.xml
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.3.RELEASE)
28-Apr-2016 16:23:53.686 INFO [http-apr-8080-exec-10] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor C:\Users\systo\Downloads\apache-tomcat-8.0.33-windows-x64\apache-tomcat-8.0.33\conf\Catalina\localhost\code.xml has finished in 6,718 ms
28-Apr-2016 16:23:53.693 INFO [http-apr-8080-exec-8] org.apache.catalina.util.LifecycleBase.start The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/code]] after start() had already been called. The second call will be ignored.
My Pom file is
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>org.springframework</groupId>
<artifactId>gs-rest-service</artifactId>
<version>0.1.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<dependencies>
<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-web</artifactId>
</dependency> -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.5.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.3.3.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.3.3.RELEASE</version>
<type>jar</type>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>University</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
<classifier></classifier>
</dependency>
</dependencies>
<properties>
<jdbc.url>jdbc:url</jdbc.url>
<jdbc.username>username</jdbc.username>
<jdbc.password>password</jdbc.password>
<jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>