Monday, November 26, 2018

Node JS installation behind firewall with ntlm authentication.

Strangely enough the ntlmaps.exe didn't work well with Nodejs.  Downloading of the dependencies and javascripts fails.

Quick solution for this was using px-proxy pyhon based proxy.

You can Install it with:

pip install px-proxy

and run it with:

px --proxy=X.X.X.X:port 

where X.X.X.X is Ip address of your firewall and port is the port used.

The catch here was that to use pip ... i used ntlmaps.exe  (see one of my previous posts)

So, you need a ntlm proxy (ntlmaps.exe)  to download ntlm proxy (px-proxy) behind firewall ;-)

Thursday, November 15, 2018

Glassfish 4.1.1 Rest Missing Library

When trying to Implement Rest ApI using jersey on Glassfish 4.1.1 the following exception in

thrown:
 java.lang.ClassNotFoundException:        com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector
not found by com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider


This is due to missing library jackson-module-jaxb-annotations-2.5.4.jar in

 C:\Program Files\glassfish-4.1.1\glassfish\modules

 Putting it there solves the problem.

 Thanks to this blog

 https://javaeeblog.wordpress.com/2016/06/21/jackson-glassfish-4-1-1/


Sunday, June 17, 2018

Run firexox in single process mode


To disable multiprocess go to "about:config" by typing it in your URL bar.
Search for browser.tabs.remote.autostart using the search box on about:config.
There may be multiple results.
Set them all to false and restart the browser

Wednesday, December 13, 2017

Showing build time, version etc in web apps and desktop applications


It is quite convenient to be able to show Application Version and build time in any given java program. Below is my way of doing this. 

Ant script for War Files 
<target name="-post-dist">      
        <!-- Empty placeholder for easier customization. -->
        <!--<property file="build.properties"/>-->
        <buildnumber file="build.version"/>
        <tstamp>
            <format property="timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
        </tstamp>
            <jar destfile="${dist.war}" update="true">
     
        <manifest>
            <attribute name="Manifest-Version" value="1.0" />        
            <attribute name="Created-By" value="Me" />        
            <attribute name="Bundle" value="${build.number}"/>
            <attribute name="Bundle-Date" value="${timestamp}" />
        </manifest>
        </jar>
        <!-- You can override this target in the ../build.xml file. -->
 </target>
Java Code for Web Application 

 public static String getBuildNumberAndDateFromWar(WebServiceContext context){
        String buildNumber="";
        try {
            javax.xml.ws.handler.MessageContext mc = context.getMessageContext();
            HttpServletRequest req = (HttpServletRequest) mc.get(javax.xml.ws.handler.MessageContext.SERVLET_REQUEST);
            InputStream stream = req.getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF");
            Manifest manifest = new Manifest(stream);
            Attributes attributes = manifest.getMainAttributes();
            String bundle = attributes.getValue("Bundle");
            String bundle_date = attributes.getValue("Bundle-Date");
            stream.close();
            if (bundle!=null && !"null".equals(bundle))
                buildNumber = " [bundle:"+ bundle + ", date:" + bundle_date+"] ";

        } catch (Exception e) {
            e.printStackTrace();
        }
        return buildNumber;
    }

Ant Script for Jar file

 <target name="-post-jar">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
        <buildnumber file="build.version"/>
        <tstamp>
            <format property="timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
        </tstamp>
            <jar destfile="${dist.jar}" update="true">
     
        <manifest>
            <attribute name="Manifest-Version" value="1.0" />        
            <attribute name="Version" value="1.0.1" />
            <attribute name="Created-By" value="Me" />        
            <attribute name="Bundle" value="${build.number}"/>
            <attribute name="Bundle-Date" value="${timestamp}" />
        </manifest>
        </jar>
 </target>

Java code for Java Application 

  public static  String getVersionBuildNumberAndDateFromJar(){
        String buildNumber="";
        try {
            InputStream stream = (new EscrowPaymentsAppClient()).getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
            Manifest manifest = new Manifest(stream);
            Attributes attributes = manifest.getMainAttributes();
            String version = attributes.getValue("Version");
            String bundle = attributes.getValue("Bundle");
            String bundle_date = attributes.getValue("Bundle-Date");
            stream.close();
            if (bundle!=null && !"null".equals(bundle))
                buildNumber = " [version:"+ version + ", bundle:"+ bundle + ", date:" + bundle_date+"] ";

        } catch (Exception e) {
            e.printStackTrace();
        }
        return buildNumber;
    }

Tuesday, December 12, 2017

Using Python's pip behind Firewall (on Windows)

To use python behind a firewall that uses ntlm authentication we will use ntlm maps local proxy.

So here are the steps:

1. Download and install ntlm maps 
   (local proxy that will handle the authentication with our corporate proxy)
    http://ntlmaps.sourceforge.net/

2. Configure server.cfg of the ntlm maps,  change the following
      LISTEN_PORT:5865
      PARENT_PROXY:XXXX.XXXX.XXXX.XXXX
      PARENT_PROXY_PORT:XXXX
      NT_DOMAIN:xxxxx.xxx
      USER:xxxxxxxxxxx
      PASSWORD: 

   If we leave the password blank it will ask us for it at run-time.

3. if ntlm maps does not run - then some dlls are missing those are
    -MSVCP71.DLL
    -MSVCR71.DLL
    Copy then into SysWOW64 if needed (on 64 bit system) or into (System32 on 32 bit system)

4. run the ntlm maps

5.  download and install python
       https://www.python.org/downloads/
       https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi

6. open command prompt (cmd) and enter:
      set http_proxy=localhost:5865

7. use pip to download and install plugins
    -cx_Oracle-doc
    pip --proxy http://127.0.0.1:5865 install cx_Oracle --upgrade
    -Jinja2-2.7.2
    pip --proxy http://127.0.0.1:5865 install Jinja2 --upgrade
    -mechanize-0.2.5
    pip --proxy http://127.0.0.1:5865 install mechanize --upgrade
    -beautifulsoup4
    pip --proxy http://127.0.0.1:5865 install beautifulsoup4 --upgrade

Windows 10 God Mode Folder on Desktop

If you have created a "God Mode" folder on your desktop - think twice before deciding to keep it there.
It turns out that some applications will refuse to perform their basic functionalities (like: open file, browse etc) and will crash - only because the folder sits on your desktop.


As always, had to learn that the hard way....

*If you don't know what the "God Mode" folder is - then probably you don't have one . This folder  usually is created explicitly by the user using some undocumented features of the Windows OS.




Windows 10 missing sticky notes and microsoft store problem

After installing Windows 10 I realized that the Microsoft Store was missing also the sticky note app was not there either...

The solution came from power-shell.
I guess Microsoft has adopted linux-like approach in getting updates and missing packages.

So here what I did:

 1. Enter Windows Power-Shell (as Admin)
 2. Get-Appxpackage -Allusers > res.txt
 3. Add-AppxPackage -register "C:\Program Files\WindowsApps\[packageFullName]\AppxManifest.xml" -DisableDevelopmentMode

Here the res.txt file is needed to find missing package's full name.

[Microsoft.MicrosoftStickyNotes]
[Microsoft.WindowsStore]

We use that name to download and install the package (step 3).