Search code examples
javaangularweblogic

WebLogic doesn't use contextpath for loading javascript files


I created one war which contains my backend application(Spring Boot) and frontend(Angular2). In frontend application i use Angular CLI for creating distribution files.
I need to deploy this war to WebLogic application server.
For building frontend project, i run"ng build" command through exec-maven-plugin.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.5.0</version>
    <executions>
        <execution>
            <id>exec-npm-install</id>
            <phase>generate-sources</phase>
            <configuration>
                <workingDirectory>${project.basedir}/src/main/ngapp</workingDirectory>
                <executable>npm.cmd</executable>
                <arguments>
                    <argument>install</argument>
                </arguments>
            </configuration>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
        <execution>
            <id>exec-npm-ng-build</id>
            <phase>generate-sources</phase>
            <configuration>
                <workingDirectory>${project.basedir}/src/main/ngapp</workingDirectory>
                <executable>ng.cmd</executable>
                <arguments>
                    <argument>build</argument>
                    <argument>--base-href=/applicationName</argument>
                </arguments>
            </configuration>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Content of index.html:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>CometTest</title>
  <base href="/applicationName">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app>Loading...</app>
<script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="scripts.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
</html>

When i deployed resulting war to Tomcat with contextPath='applicationName' on my local machine, it's working fine.
But when i deployed to remote WebLogic it throws error while loading javascript files.

Failed to load resource: the server responded with a status of 404 (Not Found) http://24.211.213.46:7611/inline.bundle.js

Why does WebLogic try to download files without applicationName in url?
And i can reach this javascript file by following url:

http://24.211.213.46:7611/applicationName/inline.bundle.js

Solution

  • For proper loading of my javascript files, I have to use deploy-url parameter

    ng build --environment=prod --deploy-url http://24.211.213.46:7611/applicationName