Monday, December 18, 2017

Externnal jar used as maven dependency

Beside installing 3rd party JARs in maven using mvn install it is posible to use external jars directly in pom.xml in depenency declaration just include systemPath

<dependency>
          <groupId>ro.springsoft</groupId>
          <artifactId>libar</artifactId>
          <version>1.0</version>
          <scope>system</scope>
          <systemPath>${basedir}\ext-libs\libar.jar</systemPath>
  </dependency>

Thursday, July 27, 2017

Docker Terminal in ConEmu

Running Docker Quickstart Terminal is explained in this blog post|: https://jayvilalta.com/blog/2016/05/02/running-docker-toolbox-inside-conemu/
For running docker commands inside any console I created init-docker.cmd inside c:\Program Files\Docker Toolbox\ which I added to the system PATH env. variable and I can run init-docker when I start any console.
initdocker.cmd
@echo off
IF DEFINED DOCKER_MACHINE_EXECUTING (GOTO :eod)
set DOCKER_MACHINE_EXECUTING=1
:configureDocker
FOR /f "tokens=*" %%i IN ('docker-machine env default') DO %%i
:eod

Saturday, October 12, 2013

GUI prototyping tools

Recently I was looking for a GUI drawing tool, I found two free solutions

  1. The pencil project open source GUI drawing tool available for all platforms, including widgets for phones
  2. www.draw.io online drawing solution including GUI drawing and UML diagramming

Monday, February 18, 2013

JAAS problems solved with JBoss As 7.2 prerelease

 

There where problems with simple web applications using JAAS security constraints in web.xml. I got various exceptions like invalid password (for correct password) in jboss console for jboss versions 7.1 .. 7.3 even in jbos eap 6 with no solution on the net :http://www.coderanch.com/t/568240/JBoss/JAAS-Login-PropertiesUsers-JBoss-Final

Today I compiled the jboss as 7.2 prerelease from git hub and everything is working fine.

The curious thing is that even in jboss commercial version eap 6 this issue was not solved for a base service like JAAS.

Sunday, December 30, 2012

Test JPQL (or HQL) using SQuirrel SQL 3.4.0

image
  • In Netbeans 7.2 create a new Java Application Project
  • Add a connection to your database in Services tab –>Databases
  • Copy all JPA entity classes in your project (in correct package)
  • In newly created java app project right click on “Source Packages” –>New –>(Other)->Persistence Unit
  • In New Persistence Unit dialog:
    • Persistence LIbrary = Hibernate (JPA 1.0)  (I tried with hibernate 4.1.9 and jpa 2 but is not working)
    • Database connection = chose your db connection
    • Table generation strategy = none
  • Edit your persistence.xml
    • In design tab –> Include Entity Classes –> add all of them
    • In the source tab –> add the hibernate.dialect property e.g.
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
  • Right click on your project and in Build –>Packaging->select Copy Dependency Libs (this will create a lib folder with all you need in the dist folder)
  • Build your project
  • Right click on your project and in Build –>Packaging->deselect Copy Dependency Libs (this will create your jar without references to other jars – perfect for squirrelsql)
  • Build your project again
  • In Squirrel File –> Global Preferences –> Hibernate: create a new configuration
  • With “Add classpath entity” button:
    • add jars for your jdbc driver
    • add all jars in from your_java_app/dist/lib
    • add your exported java app jar from dist folder
  • select call … persistence-unit and complete persistence-unit name
  • Select Run Hibernatate in SQuirreL’s Java VM
  • Hit Apply Changes to this configuration and OK
image
After you’re connected to your db in the Hibernate tab is all the magic Open-mouthed smile

Monday, December 24, 2012

Run JBoss, Tomcat/Tomee in debug mode

 

The needed params are:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

For jboss as 7 in bin/standalone.bat (or sh) add those additional params to line 53

set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%

the line will look like this:

set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

For tomcat/tomee

in catalina.bat (.sh) at this as the first line in file:

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

To debug the code in Eclipse:

  1. Run -> Debug Configurations… -> Remote Java Application -> Right click –> New
  2. Then on Connect tab, set these Connection Properties: host = localhost, port=8787
  3. Then select your Project and in Source tab add extra projects or libraries.
  4. Press Apply button
  5. Press Debug button
  6. You are connected!!! – the server must be started
  7. Add a Breakpoint in your code
  8. Trigger your application to reach a Breakpoint

To debug the code in Netbeans:

  1. Go in menu: Debug->AttachDebuger…
  2. set port to 8787
  3. press ok (make sure that the server is up and running) – repeat the process every time when you need debugging

Tuesday, December 11, 2012

Global JNDI Names standardized in JEE6

The Enviromental Naming Context (ENC) is a JNDI context that can be accessed via java:comp/env.

This Context is used to create portable JNDI names for EJBs. Names in the ENC are created with entries in a deployment descriptor. The JEE6 adds support for sandard JNDI names of EJBs withour requiring usage of the ENC:

java:global[/<app-name>]/<module-name>/<bean-name>

java:app[/<module-name>]/<bean-name>

java:module/<bean-name>

app-name is same as ear without extension, module-name is ejb jar or war name without extension

also CDI can target specific JNDI name


@EJB(mappedName=”java:global/ejbmodule/FooBean”)
FooRemote foo;

Updating GlasFish v3 with latest EclipseLInk and JSF Mojara

 

Download newer version of EclipseLink binaries from http://www.eclipse.org/eclipselink/downloads/. Choose OSGI bundles from the available downloads.

Download javax.faces-2.1.14.jar from http://javaserverfaces.java.net/download.html (the latest at the moment, not use 2.2.x version because this will be part of the new jee7 spec and may not work with glassfish 3.1)

Replace following files under $GLASSFISH_HOME/glassfish/modules with corresponding jars you downloaded above:

  • org.eclipse.persistence.antlr.jar
  • org.eclipse.persistence.jpa.jar
  • org.eclipse.persistence.asm.jar
  • org.eclipse.persistence.jpa.modelgen.jar
  • org.eclipse.persistence.core.jar
  • org.eclipse.persistence.oracle.jar
  • javax.persistence.jar
  • javax.faces.jar

    Restart GlassFish

  • Note: This will solve problems with create-tables in hsqldb – the defauld eclipse link from glassfish 3 generate some SQLs which are not executed for tables creation.

    Thursday, December 6, 2012

    Switching to the dark side … of development in Netbeans 7.2

    Netbeans_dark

     

    • download JTatoo.jar and put it in [netbeans install folder]/platform/lib
    • edit [netbeans install dirf]\etc\netbeans.conf find the line starting with netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m
      1. append this text to the line:  -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on -J-Dawt.useSystemAAFontSettings=lcd --laf com.jtattoo.plaf.hifi.HiFiLookAndFeel --fontsize 11

      (you can also use –laf Nimbus for Nibus build in look & feel)

      1. the section should look similar to this:
    netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=on -J-Dawt.useSystemAAFontSettings=lcd --laf com.jtattoo.plaf.hifi.HiFiLookAndFeel --fontsize 11"

  • download and install Monaco font (not the latest 5.1 version for windows is not working well with line spacing, you can also use Anonymous fonts as alternative)
  • restart netbeans
  • go to in menu Tools->Options->Fonts&Colors and select Sunburst, Netbeans_Twilight or Monster theme and customize the theme as you like
  • Develop with pleasure Smile

    • Monday, May 21, 2012

      OCMJEA badge and diploma

      On Friday morning I received the diploma and the badge for OCMJEA from Dublin(Ireland). It was quite fast how Oracle managed to send me the package, I confirmed the address only on Tuesday and Friday morning the package from Oracle arrived, they announce me that I passed all steps on Monday morning. The date of certification seems to be the date when I downloaded the assignment for step 2. I'm happy now and I really want to apply what I learned and to set the standard for excellence :).

      Monday, May 14, 2012

      Oracle Certified Master Java EE 5 Enterprise Architect passed today

      Today I received a notification from Oracle that I have passed the Oracle Certified Master, Java EE 5 Enterprise Architect certification and I'm among the elite 1% of certified Java professionals who have gone on to achieve the Java Enterprise Architect certification :) I completed all four steps required and I'm very happy now after a long term motivated study :) It was a lot of learning and trying different uml tools, running snippets of code and most important thinking about problems that arise in enterprise architectures.

      Monday, February 6, 2012

      caps lock warning in web app

      JQuery Bubble Popup for displaying the bubble http://www.vegabit.com/jquery_bubble_popup_v2/

      and the following js:

         1:  
         2: function initCaps() {
         3:                $('#password').CreateBubblePopup({
         4:                    innerHtml : w_msg,
         5:                    manageMouseEvents : false,
         6:                    innerHtmlStyle : {
         7:                        color : '#ffffdf',
         8:                        'text-align' : 'center'
         9:                    },
        10:                    position: 'left',
        11:                    alwaysVisible: true,
        12:                    dropShadow: true,
        13:                    themeName : 'all-blue',
        14:                    themePath: '../img/jquerybubblepopup-theme'
        15:  
        16:                });
        17:                $('#password111').CreateBubblePopup({
        18:                    innerHtml : w_msg,
        19:                    manageMouseEvents : false,
        20:                    innerHtmlStyle : {
        21:                        color : '#ffffdf',
        22:                        'text-align' : 'center'
        23:                    },
        24:                    position: 'right',
        25:                    alwaysVisible: true,
        26:                    dropShadow: true,
        27:                    themeName : 'all-blue',
        28:                    themePath: '../img/jquerybubblepopup-theme',
        29:                });
        30:                $('#old_password, #new_password, #confirm_password, #google_password, #imap_password').CreateBubblePopup({
        31:                    innerHtml : w_msg,
        32:                    manageMouseEvents : false,
        33:                    innerHtmlStyle : {
        34:                        color : '#ffffdf',
        35:                        'text-align' : 'center'
        36:                    },
        37:                    position: 'top',
        38:                    alwaysVisible: true,
        39:                    dropShadow: true,
        40:                    themeName : 'all-blue',
        41:                    themePath: '../img/jquerybubblepopup-theme',
        42:                });
        43:              
        44:                $('#google_password, #imap_password').CreateBubblePopup({
        45:                    innerHtml : w_msg,
        46:                    manageMouseEvents : false,
        47:                    innerHtmlStyle : {
        48:                        color : '#ffffdf',
        49:                        'text-align' : 'center'
        50:                    },
        51:                    position: 'right',
        52:                    alwaysVisible: true,
        53:                    dropShadow: true,
        54:                    themeName : 'all-blue',
        55:                    themePath: '../img/jquerybubblepopup-theme',
        56:                });
        57:              
        58:                $(':password').focusout(function(){
        59:                    $(':password').UnfreezeAllBubblePopups();
        60:                    $(':password').HideAllBubblePopups();
        61:                  
        62:                  
        63:                });
        64:                $('.w_close').click(function(){
        65:                    $(':password').UnfreezeAllBubblePopups();
        66:                    $(':password').HideAllBubblePopups();
        67:                });
        68:              
        69:              
        70: }
        71:  
        72: var capslock = {
        73:    init : function() {
        74:        if(!document.getElementsByTagName) {
        75:            return;
        76:        }
        77:        // Find all password fields in the page, and set a keypress event on them
        78:        var inps = document.getElementsByTagName("input");
        79:        for(var i = 0, l = inps.length; i < l; i++) {
        80:            if(inps[i].type == "password") {
        81:                capslock.addEvent(inps[i], "keypress", capslock.keypress);
        82:            }
        83:        }
        84:    },
        85:    addEvent : function(obj, evt, fn) {
        86:        if(document.addEventListener) {
        87:            capslock.addEvent = function(obj, evt, fn) {
        88:                obj.addEventListener(evt, fn, false);
        89:            };
        90:            capslock.addEvent(obj, evt, fn);
        91:        } else if(document.attachEvent) {
        92:            capslock.addEvent = function(obj, evt, fn) {
        93:                obj.attachEvent('on' + evt, fn);
        94:            };
        95:            capslock.addEvent(obj, evt, fn);
        96:        } else {
        97:            // no support for addEventListener *or* attachEvent, so quietly exit
        98:        }
        99:    },
       100:    keypress : function(e) {
       101:        var ev = e ? e : window.event;
       102:        if(!ev) {
       103:            return;
       104:        }
       105:        var targ = ev.target ? ev.target : ev.srcElement;
       106:        // get key pressed
       107:        var which = -1;
       108:        if(ev.which) {
       109:            which = ev.which;
       110:        } else if(ev.keyCode) {
       111:            which = ev.keyCode;
       112:        }
       113:        // get shift status
       114:        var shift_status = false;
       115:        if(ev.shiftKey) {
       116:            shift_status = ev.shiftKey;
       117:        } else if(ev.modifiers) {
       118:            shift_status = !!(ev.modifiers & 4);
       119:        }
       120:        if(((which >= 65 && which <= 90) && !shift_status) || ((which >= 97 && which <= 122) && shift_status)) {
       121:            // uppercase, no shift key
       122:            capslock.show_warning(targ);
       123:        } else {
       124:            capslock.hide_warning(targ);
       125:        }
       126:    },
       127:    show_warning : function(targ) {
       128:        /*
       129:        if(!targ.warning) {
       130:        targ.warning = document.createElement('img');
       131:        targ.warning.src = "http://farm3.static.flickr.com/2145/2067574980_3ddd405905_o_d.png";
       132:        targ.warning.style.position = "absolute";
       133:        targ.warning.style.top = (targ.offsetTop - 73) + "px";
       134:        targ.warning.style.left = (targ.offsetLeft + targ.offsetWidth - 5) + "px";
       135:        targ.warning.style.zIndex = "999";
       136:        targ.warning.setAttribute("alt", "Warning: Caps Lock is on");
       137:        if(targ.warning.runtimeStyle) {
       138:        // PNG transparency for IE
       139:        targ.warning.runtimeStyle.filter += "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://farm3.static.flickr.com/2145/2067574980_3ddd405905_o_d.png',sizingMethod='scale')";
       140:        }
       141:        document.body.appendChild(targ.warning);
       142:        } */
       143:  
       144:        if(! $('#password').IsBubblePopupOpen() && $('#password').is(":focus"))  {
       145:            $('#password').ShowBubblePopup();
       146:            $('#password').FreezeBubblePopup();
       147:        }
       148:      
       149:        if(! $('#password111').IsBubblePopupOpen() && $('#password111').is(":focus")){
       150:            $('#password111').ShowBubblePopup() ;
       151:            $('#password111').FreezeBubblePopup();
       152:        }
       153:  
       154:        if(! $('#old_password').IsBubblePopupOpen() && $('#old_password').is(":focus")){
       155:            $('#old_password').ShowBubblePopup();
       156:            $('#old_password').FreezeBubblePopup();
       157:        }
       158:      
       159:        if(! $('#new_password').IsBubblePopupOpen() && $('#new_password').is(":focus")){
       160:            $('#new_password').ShowBubblePopup();
       161:            $('#new_password').FreezeBubblePopup();
       162:        }
       163:  
       164:        if(! $('#confirm_password').IsBubblePopupOpen() && $('#confirm_password').is(":focus")){
       165:            $('#confirm_password').ShowBubblePopup();
       166:            $('#confirm_password').FreezeBubblePopup();
       167:        }
       168:      
       169:        if(! $('#google_password').IsBubblePopupOpen() && $('#google_password').is(":focus")){
       170:            $('#google_password').ShowBubblePopup();
       171:            $('#google_password').FreezeBubblePopup();
       172:        }
       173:      
       174:        if(! $('#imap_password').IsBubblePopupOpen() && $('#imap_password').is(":focus")){
       175:            $('#imap_password').ShowBubblePopup();
       176:            $('#imap_password').FreezeBubblePopup();
       177:        }
       178:  
       179:        // var alertMessage = "" + 'Caps ON' + "";
       180:        // $("#password").before(alertMessage);
       181:        // $("#capslock").fadeIn("slow");
       182:  
       183:    },
       184:    hide_warning : function(targ) {
       185:        /*
       186:        if(targ.warning) {
       187:        targ.warning.parentNode.removeChild(targ.warning);
       188:        targ.warning = null;
       189:        } */
       190:      
       191:        $(':password').UnfreezeAllBubblePopups();
       192:        $(':password').HideAllBubblePopups();
       193:  
       194:      
       195:        // $("#capslock").remove();
       196:    }
       197: };
       198: (function(i) {
       199:    var u = navigator.userAgent;
       200:    var e =    /*@cc_on!@*/false;
       201:    var st = setTimeout;
       202:    if(/webkit/i.test(u)) {st(function() {
       203:            var dr = document.readyState;
       204:            if(dr == "loaded" || dr == "complete") {i()
       205:            } else {st(arguments.callee, 10);
       206:            }
       207:        }, 10);
       208:    } else if((/mozilla/i.test(u) && !/(compati)/.test(u)) || (/opera/i.test(u))) {
       209:        document.addEventListener("DOMContentLoaded", i, false);
       210:    } else if(e) {(function() {
       211:            var t = document.createElement('doc:rdy');
       212:            try {t.doScroll('left');
       213:                i();
       214:                t = null;
       215:            } catch(e) {st(arguments.callee, 0);
       216:            }
       217:        })();
       218:    } else {
       219:        window.onload = i;
       220:    }
       221: })(capslock.init)