Search code examples
angularmavenjbosswar

Angular WAR build


I would like to build Angular 5 app to .war and deploy and run it from JBoss.

I have angular 5 app with maven for .war building. During the JBoss deployment there is an error but I can deploy after making WebContent catalog in WEB-INF but can't reach the site. I am not sure if my POM/WEB.XML are configured properly.

I am building using mvn compile war:war

I have no experience with Maven so if you could help me I would be very grateful.

POM.XML

 <project 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.vdb</groupId>
<artifactId>vdb</artifactId>
<version>0.0.1</version>

<build>
 <plugins>

   <plugin>
     <artifactId>maven-clean-plugin</artifactId>
     <version>2.5</version>
     <configuration>
       <filesets>
         <fileset>
           <directory>dist</directory>
           <includes>
             <include>*</include>
           </includes>
         </fileset>
       </filesets>
     </configuration>
   </plugin>

   <plugin>
     <groupId>com.github.eirslett</groupId>
     <artifactId>frontend-maven-plugin</artifactId>
     <version>1.5</version>
     <executions>
       <execution>
         <id>install node and npm</id>
         <goals>
           <goal>install-node-and-npm</goal>
         </goals>
         <configuration>
           <nodeVersion>v8.9.1</nodeVersion>
           <npmVersion>5.5.1</npmVersion>
         </configuration>
       </execution>

       <execution>
         <id>npm install</id>
         <goals>
           <goal>npm</goal>
         </goals>
         <configuration>
           <arguments>install</arguments>
         </configuration>
       </execution>

       <execution>
         <id>prod</id>
         <goals>
           <goal>npm</goal>
         </goals>
         <configuration>
           <arguments>run-script prod</arguments>
         </configuration>
         <phase>generate-resources</phase>
       </execution>
     </executions>
   </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <webXml>.\WEB-INF\web.xml</webXml>   
            <webResources>
                <resource>
                    <!-- this is relative to the pom.xml directory -->
                    <directory>./dist/</directory>
                </resource>
            </webResources>
        </configuration>

    </plugin>

 </plugins>

and WEB.XML

<?xml version="1.0" encoding="ISO-8859-1" ?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>VDB WebApp</display-name>
<description>
</description>

<servlet>
    <servlet-name>VDBWeb</servlet-name>
    <servlet-class>vdb.Servlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>VDBServlet</servlet-name>
    <url-pattern>/vdb</url-pattern>
</servlet-mapping>


Solution

  • Turned out that servlet name in and need to match. I also tried to open /vdb where I needed to go to /warname.