Friday, December 29, 2017

Deploying Oracle JET application ( .war file ) to Weblogic/ JCS

These steps are tested for Oracle JET 4.X release as well.

I was searching for the details on how to generate WAR file out of JET application and then deploy it to JCS / Weblogic.

I have found some really nice articles, however i would like to present the same in the way I understood them.

Not demeaning the content from those posts, I would like to condense the steps a little bit, so that it would be a reference to me as well. So here we go : 

a. Install the grunt-war using below command : 
         npm install grunt-war --save-dev

b. Verify if the directory "/grunt-war" is generated in the node_modules directory.

c. Create a javascript file as below in scripts folder : 


The file content is as below :

/*******************************************************************************/

module.exports =  {

  /*
   * Build a WAR (web archive) without Maven or the JVM installed.
   *
   * Template strings in the <%= %> tags are set in the data section of Gruntfile.js,
   *  or you can hardcode the strings here instead
   */
      
        target: {
          options: {
            war_dist_folder: '<%= distdir %>',      /* Folder to generate the WAR into, set in data section of Gruntfile.js */
            war_name: '<%= appname %>',            /* The name for the WAR file (.war will be the extension) */
            webxml_webapp_version: '2.5', /* I needed this older version for JCS-SX */  
            war_extras: [ {filename: 'grunt-war-credits.txt', data: 'This line will appear in the file!\n see http://likeahouseafire.com/2017/08/09/updated-using-grunt-to-create-war-jet3x/ '}, 
                          {filename: 'WEB-INF/weblogic.xml', data: '<?xml version="1.0" encoding="UTF-8"?>\n<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">\n  <jsp-descriptor>\n    <keepgenerated>true</keepgenerated>\n    <debug>true</debug>\n  </jsp-descriptor>\n  <context-root>/<%= appname %></context-root>\n</weblogic-web-app>'}],
                                          /* the war_extras are extra files to be generated, needed since grunt-war doesn't create a weblogic.xml */                                          /* also notice that we're using the <%= appname %> variable in there */  
            webxml_welcome: 'index.html', /* to point web.xml to the default page */
            webxml_webapp_extras: [ '<login-config />\n', '<session-config>\n    <session-timeout>\n    30\n    </session-timeout>\n</session-config>\n' ]  
                                          /* some extra settings for web.xml to work with JCS-SX */

          },
          files: [
            {
              expand: true,
              cwd: '<%= appdir %>',             /* find the source files for the WAR in the /web folder, set in Gruntfile.js */
              src: ['**'],
              dest: ''
            }
          ]
        }
};

/*******************************************************************************/
d. Add the below content to the file : Gruntfile.js which is already available in the project : 


/*******************************************************************************/
var path = require('path');

module.exports = function(grunt) {

  require('load-grunt-config')(grunt, {
  configPath: path.join(process.cwd(), 'scripts/grunt/config'),
    data: {
      appname: path.basename(process.cwd()),  // same as project directory name, accessible with '<%= appname %>'
      appdir: 'web',  // accessible with '<%= appdir %>'
      distdir: 'dist'  // accessible with '<%= distdir %>'
    }
  });

  grunt.loadNpmTasks("@oracle/grunt-oraclejet");

  grunt.registerTask("build", "Public task. Calls oraclejet-build to build the oraclejet application. Can be customized with additional build tasks.", function (buildType) {
    grunt.task.run([`oraclejet-build:${buildType}`,`war`]);
  });

  grunt.registerTask("serve", "Public task. Calls oraclejet-serve to serve the oraclejet application. Can be customized with additional serve tasks.", function (buildType) {
    grunt.task.run([`oraclejet-serve:${buildType}`]);
  }); 
};
/*******************************************************************************/

e. Now run the below command :
         grunt build:release

f. A new folder called "dist" will be created with the application .war file.

Please note that here we are not modifying the files : oraclejet-build.js , oraclejet-serve.js and hence we are not dependent on the command : ojet build --release command.


For more details please refer to this blog post on http://likeahouseafire.com

Thanks for reading,
Srikanth


No comments:

Post a Comment

Fusion BIP : How to show one parameter in report and pass different value to the datamodel

Hi All, There can be a scenario where we might need to show one value in the report and a different value to the actual query. Lets say a...