I am using Eclipse to develop a Java project to run on a server. I have two projects:
1) jbosswildfly
: one with Java code made up of a number of RESTful Services, and a Maven pom.
2) theWhoZoo-web
: the other is a web project containing a few html files.
I would like to merge these projects and just have one project. I have tried copying the WebContent
folder from theWhoZoo-web
to jbosswildfly
, starting the server, but I cannot access the index.html
.
Question
What is the best way to merge these two projects, so that the RESTful Services as well as the index.html
are accessible on the same server?
Thanks
UPDATE
I try run the JBoss index.html
but get a 404.
But, when I invoke one of the RESTful Services, it returns a result.
e.g. http://localhost:8080/jbosswildfly-1.0/category/list
but,
http://localhost:8080/jbosswildfly-1.0/index.html
returns:
14:23:31,699 WARN [org.springframework.web.servlet.PageNotFound] (default task-4) No mapping found for HTTP request with URI [/jbosswildfly-1.0/index.html] in DispatcherServlet with name 'rest'
My pom.xml
has:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
metadata-complete="false">
<!--
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
-->
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
WebAppInitializer.java
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(AppConfig.class);
ctx.setServletContext(servletContext);
Dynamic dynamic = servletContext.addServlet("rest", new DispatcherServlet(ctx));
dynamic.addMapping("/*");
dynamic.setLoadOnStartup(1);
}