Tuesday, January 8, 2019

Error while building Weblogic Custom Authenticator

Error while building Weblogic Custom Authenticator

Buildfile: D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\build.xml
     [echo] Starting Jar :D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\lib

clean:
   [delete] Deleting directory D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\test
     [echo] Clean finish

build.mdf:
     [java] Working directory ignored when same JVM is used.
     [java] Parsing the MBean definition file: DBAuthenticator.xml
     [echo] Created Supporting Classes

build.mjf:
     [echo] D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\lib
     [java] Working directory ignored when same JVM is used.
     [java] Creating an MJF from the contents of directory test...
     [java] Compiling the files...
     [java] Creating the list.
     [java] Doing the compile.
     [java] D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\test\com\nokia\hdm\security\dbauthentication\DBAuthenticatorMBean.java:5: package weblogic.management.commo does not exist
     [java] import weblogic.management.commo.RequiredModelMBeanWrapper;
     [java]                                 ^
     [java] D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\test\com\nokia\hdm\security\dbauthentication\DBAuthenticatorMBean.java:16: package weblogic.management.commo does not exist
     [java] public interface DBAuthenticatorMBean extends weblogic.management.commo.StandardInterface,weblogic.descriptor.DescriptorBean, weblogic.management.security.authentication.AuthenticatorMBean {
     [java]                                                                        ^
     [java] D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\test\com\nokia\hdm\security\dbauthentication\DBAuthenticatorMBean.java:16: package weblogic.descriptor does not exist
     [java] public interface DBAuthenticatorMBean extends weblogic.management.commo.StandardInterface,weblogic.descriptor.DescriptorBean, weblogic.management.security.authentication.AuthenticatorMBean {
     [java]                                                                                                              ^
     [java] D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\test\com\nokia\hdm\security\dbauthentication\DBAuthenticatorMBean.java:16: package weblogic.management.security.authentication does not exist
     [java] public interface DBAuthenticatorMBean extends weblogic.management.commo.StandardInterface,weblogic.descriptor.DescriptorBean, weblogic.management.security.authentication.AuthenticatorMBean {
     [java]                                                                                                                                                                          ^
     [java] D:\GoogleDrive\Nokia\Workspace\DBAuthenticator\test\com\nokia\hdm\security\dbauthentication\DBAuthenticatorMBean.java:16: cannot access java.lang.Object
     [java] bad class file: java\lang\Object.class(java\lang:Object.class)
     [java] class file has wrong version 52.0, should be 50.0
     [java] Please remove or make sure it appears in the correct subdirectory of the classpath.
     [java] public interface DBAuthenticatorMBean extends weblogic.management.commo.StandardInterface,weblogic.descriptor.DescriptorBean, weblogic.management.security.authentication.AuthenticatorMBean {
     [java]        ^
     [java] Exec failed .. exiting
     [java] org.apache.tools.ant.ExitException: Permission ("java.lang.RuntimePermission" "exitVM") was not granted.
     [java]     at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:194)
     [java]     at java.lang.Runtime.exit(Runtime.java:107)
     [java]     at java.lang.System.exit(System.java:971)
     [java]     at weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvoker.java:497)
     [java]     at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:332)
     [java]     at weblogic.management.commo.WebLogicMBeanMaker.compile(WebLogicMBeanMaker.java:1050)
     [java]     at weblogic.management.commo.WebLogicMBeanMaker.compile(WebLogicMBeanMaker.java:1011)
     [java]     at weblogic.management.commo.WebLogicMBeanMaker.main(WebLogicMBeanMaker.java:728)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:498)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:221)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:154)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:834)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:228)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:137)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:110)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:498)
     [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:352)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:437)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:458)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
     [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:857)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:236)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:286)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
     [java] WLMaker-SubProcess: : Error: Could not find or load main class weblogic.management.commo.BeanGenDriver
     [java] WLMaker-SubProcess: : Stopped draining WLMaker-SubProcess:
     [java] WLMaker-SubProcess: : Stopped draining WLMaker-SubProcess:
     [java] BeanGen code generation failed
     [java] Security breach!. Request Terminated.
     [echo] Created Mbean Jar

build:

BUILD SUCCESSFUL
Total time: 0 seconds

Solution:
The error "class file has wrong version 52.0, should be 50.0"
It means your Java runtime version is 1.8, but your compiler version (javac) is 1.6. To simply solve it, just retreat the Java version from 1.8 to 1.6.

Enjoy coding...

Monday, December 17, 2018

Best node.js rest client for post request

I was trying to make a post request from my server to a rest API which records data for auditing,
I found requestify as very clean package for node.js

Get Implementation below:
     var requestify = require('requestify');
     requestify.get('https://reqres.in/api/users?page=2')
               .then(function(response) {
                   // Get the response body (JSON parsed - JSON response or jQuery object in case of XML response)
                   console.log(response.getBody());

                   // Get the response raw body
                   console.log(response.body);
                });

POST Implementation


      requestify.post('https://reqres.in/api/users', {
             "name": "Asker",
             "job": "SSE"
          }).then(function(response) {
             // Get the response body
             console.log(response.getBody());
             console.log(response.body);
          });


Monday, July 2, 2018

How to set Max File Size in Spring Boot

Once you try to upload a file with size more than 10 MB. You will face the following error.

[org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: 

org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes.]

The solution I Applied is is as follows.

@Bean
public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    factory.setMaxFileSize("124MB");
    factory.setMaxRequestSize("124MB");
    return factory.createMultipartConfig();
}
Ref: https://www.experts-exchange.com/questions/28990849/How-to-increase-Spring-boot-Tomcat-max-file-upload-size.html

Wednesday, June 27, 2018

How to run ANT with a lower Java Version than installed

ANT Refer to the Java version mentioned in JAVA_HOME path in system Environment Variables.

In a Scenario where you have to run ANT with JDK 1.7 while Java 8 is installed in the system.

Update JAVA_HOME to the JDK1.7 Path and execute the ANT Command.

Saturday, May 12, 2018

Collection Framework in Java Script -

A Collection Framework class contains all basic classes like Stack, Queue, HashMap, ArrayList, Set Download Here
define(['require','CONSTANT'], 
    function ( require, CONSTANT ) {
        /**
		 * A Collection Framework class contains all basic classes like Stack, Queue, HashMap, ArrayList, Set
		 * @name Collections
		 * @class Collections
		 * @example require('Collections')
		 * @exports Collections
		 * @version 1.0
		 * @module Collections
		 * @augments CONSTANT
		 **/
		var Collections = {
			
			 /**
			 * Object types provided by Collections 
			 * @name TYPE
			 * @class TYPE
			 * @example require('Collections').TYPE.STACK
			 * @example require('Collections').TYPE.ARRAYLIST
			 * @example require('Collections').TYPE.HASHMAP
			 * @example require('Collections').TYPE.SET
			 * @example require('Collections').TYPE.QUEUE
			 * @example require('Collections').TYPE.TREE
			 * @exports TYPE
			 * @version 1.0
			 * @module Collections
			 * @memberOf Collections
			 * @field
			 **/
			TYPE:{
				/** @constant*/
				STACK:"Stack",
				ARRAYLIST:"ArrayList",
				HASHMAP:"HashMap",
				SET:"Set",
				QUEUE:"Queue",
				TREE:"Tree"
			},
	        /**
			 * A Stack is a Collection that contains duplicate values. Last In First Out. 
			 * @name Stack
			 * @class Stack
			 * @example require('Collections').Stack()
			 * @exports Stack
			 * @version 1.0
			 * @module Collections
			 * @memberOf Collections
			 **/
			Stack: 	function () {
				var stac = [];
				var stackObj = {
					/**
					 * @name pop
					 * @memberOf Collections.Stack
					 * @method 
					 * @description removes the top item from teh stacks
					 * @return {Object} item 
					 * @function
					 */
					pop : function() {
						return stac.pop();
					},
					/**
					 * @name push
					 * @memberOf Collections.Stack
					 * @method 
					 * @description removes the top item from teh stacks
					 * @param {Object} item
					 * @return {null}  
					 * @function
					 */
					push : function(item) {
						stac.push(item);
					},
					/**
					 * @name isEmpty
					 * @memberOf Collections.Stack
					 * @method 
					 * @description returns true if teh Stack is empty.
					 * @return {boolean}  
					 * @function
					 */
					isEmpty : function() {
						return stac.length == 0;
					},
					/**
					 * @name objType
					 * @memberOf Collections.Stack
					 * @method 
					 * @description returns teh Object type as "Stack"
					 * @return {String} ObjectType  
					 * @function
					 */
					objType : function(){
						return "Stack";
					},
					/**
					 * @name getElements
					 * @memberOf Collections.Queue
					 * @method 
					 * @description returns teh Elemnts in the Queue
					 * @return {Object[]} itemArray  
					 * @function
					 */
					getElements : function(){
						return stac.clone();
					},
					/**
					 * @name toString
					 * @memberOf Collections.Stack
					 * @method 
					 * @description returns the JSON data of teh Object
					 * @return {String} ObjectType  
					 * @function
					 */
					toString : function(){
						return "["+stac.join()+"]";
					},
					/**
					 * @name clone
					 * @memberOf Collections.Stack
					 * @method 
					 * @description returns Collection.Stack a new Stack with the cloned object of the items.
					 * @return {Collections.Stack}
					 * @function
					 */
					clone:function(){
						var Collection = require('Collections');
						var cloneStack = Collection.Stack();
						var elements = stac;
						for(var i=0;i=0; i--){
							if(elements[i].clone)
								cloneQueue.add(elements[i].clone());
							else
								cloneQueue.add(elements[i]);
						}
						return cloneQueue;
					}
				};
				return queueObj;
			},
			/**
			 * An ArrayList is a Collection that contains duplicate values. 
			 * @name ArrayList
			 * @class ArrayList
			 * @example require('Collections').ArrayList()
			 * @exports ArrayList
			 * @version 1.0
			 * @module ArrayList
			 * @memberOf Collections
			 **/
			ArrayList : function() {
				var arr = [];
				var array = {
					/**
					 * @name add
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description insert an Item to the ArrayList, it adds to the last of the array, It allows duplicate values in the list.
					 * @param {Object} item
					 * @return {null} 
					 * @function
					 */
					add : function(item) {
						arr.push(item);
					},
					/**
					 * @name addAll
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description insert an array of Items to the ArrayList, it adds to the last of the array, It allows duplicate values in the list.
					 * @param {Object[]} itemArray
					 * @return {null} 
					 * @function
					 */
					addAll : function(items) {
						for(var i=0; i< items.length; i++)
							this.add(items[i]);
					},
					/**
					 * @name indexOf
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns teh index of teh item in the ArrayList, if item not found it returns -1.
					 * @param {Object} item
					 * @return {integer} 
					 * @function
					 */
					indexOf : function(item) {
						return arr.indexOf(item);
					},
					/**
					 * @name contains
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns whether the item present in the ArrayList.
					 * @param {Object} item
					 * @return {boolean} 
					 * @function
					 */
					contains:function(item){
						return arr.indexOf(item) != -1;
					},
					/**
					 * @name remove
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description remove an item from the array, then the remaining items will be shifted left, and their index will be reduced by 1.
					 * @param {Object} item
					 * @return {null} 
					 * @function
					 */
					remove : function(item) {
						if (arr.indexOf(item) >= 0)
							arr.splice(arr.indexOf(item), 1);
					},
					/**
					 * @name size
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns the number of the Elements present in the ArrayList.
					 * @return {integer} 
					 * @function
					 */
					size:function(){
						return arr.length;
					},
					/**
					 * @name get
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns the object at the prvided index.
					 * @param {integer} index
					 * @return {Object} item 
					 * @function
					 */
					get : function(index){
						return arr[index];
					},
					/**
					 * @name set
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description set an item at the specified location
					 * @param {integer} index
					 * @param {Object} Item
					 * @return {null}  
					 * @function
					 */
					set:function(index, item){
						if(index<0) throw "Index out of bound exception";
						arr[index]=item;
					},
					/**
					 * @name getElements
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns teh Elemnts in the ArrayList
					 * @return {Object[]} itemArray  
					 * @function
					 */
					getElements : function(){
						return arr.clone();
					},
					/**
					 * @name objType
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns teh Object type as "ArrayList"
					 * @return {String} ObjectType  
					 * @function
					 */
					objType:function(){
						return "ArrayList";
					},
					/**
					 * @name toString
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns the JSON data of teh Object
					 * @return {String} ObjectType  
					 * @function
					 */
					toString : function(){
						return "["+arr.join()+"]";
					},
					/**
					 * @name json
					 * @memberOf Collections.ArrayList
					 * @method 
					 * @description returns the JSON string
					 * @return {String} json  
					 * @function
					 */
					json :function(){
						var jsonArr=[];
						for(var i=0; i

Thursday, May 10, 2018

How to set the max size of upload file in Spring Boot embedded Apache Tomcat

Error in spring boot : org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field uploadfile exceeds its maximum permitted size of 1048576 bytes. I found the solution at Expert Exchange, which worked well.
@Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize("124MB");
        factory.setMaxRequestSize("124MB");
        return factory.createMultipartConfig();
    }
Expert Exchange

Wednesday, November 8, 2017

Error while connecting Hive

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hive/service/rpc/thrift/TCLIService$Iface
 at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at io.saagie.example.hive.Main.main(Main.java:39)
Caused by: java.lang.ClassNotFoundException: org.apache.hive.service.rpc.thrift.TCLIService$Iface
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 ... 4 more