Http Status 404 - Not Found
Closed this issue · 2 comments
Hi there,
I have to apologise first for this issue for the reason below:
I am a
PHP
developer that has minimalJava
experience. I have always read about most Java Technologies and Tools and so the knowledge I have is barely theoretical even.
I have manually built a Tomcat Servelet Container that is sitting on Ubuntu 16.4 distribution. The server works as expected and well. I played around with few of the examples in there.
My problem is that when I cloned this project and built it myself everything looked promising as all 96 test cases passed during the built process.
I noticed that the packaging strategy uses a *.jar
for deployment. Knowing that the Servelet Container allows *.war
files for deployment I added the following dependencies within my pom
file as shown by git dIff
:
diff --git a/pom.xml b/pom.xml
index 80df796..69dd8c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,6 +5,7 @@
<artifactId>dddsample</artifactId>
<name>DDDSample</name>
<version>2.0-SNAPSHOT</version>
+ <packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
@@ -166,6 +167,11 @@
<artifactId>selenium-java</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<reporting>
My assumption was that the context path would be what Tomcat gives back if not dddsample
, that is, http:localhost:8080/dddsample would have pointed me to the index page of the application.
It really is not easy to have a working deployment of the application and I suspect perhaps Tomcat is not a good enough server to recognise Spring Framework application. I am also sceptical on Glassfish as it never proved me better before.
Anything I am doing wrong here?
Hi again,
It will seem as though I wasted your time more than I wasted mine by openning this issue. I now can be able to deploy my app on Tomcat with the changes shown below:
index d1144c7..7786250 100644
--- a/src/main/java/se/citerus/dddsample/Application.java
+++ b/src/main/java/se/citerus/dddsample/Application.java
@@ -10,12 +10,14 @@ import se.citerus.dddsample.application.util.SampleDataGenerator;
import se.citerus.dddsample.config.DDDSampleApplicationContext;
import javax.annotation.PostConstruct;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.support.SpringBootServletInitializer;
@Configuration
@Import({DDDSampleApplicationContext.class,
PathfinderApplicationContext.class})
@EnableAutoConfiguration
-public class Application {
+public class Application extends SpringBootServletInitializer{
@Autowired
SampleDataGenerator sampleDataGenerator;
@@ -28,4 +30,10 @@ public class Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
+ {
+ return builder.sources(Application.class);
+ }
}
I will close this issue as I managed to have it resolved.
Ah! And the pom file ofcourse:
diff --git a/pom.xml b/pom.xml
index 80df796..f9343f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,6 +5,7 @@
<artifactId>dddsample</artifactId>
<name>DDDSample</name>
<version>2.0-SNAPSHOT</version>
+ <packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
@@ -166,6 +167,15 @@
<artifactId>selenium-java</artifactId>
<scope>test</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-web</artifactId>
+ </dependency>
</dependencies>
<reporting>