Mac OSX DNS failure on VPN

If you are connected to your corp VPN and DNS lookup fails for all your corp hosts, then try the below solution

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

This basically bounces the mDNSResponder

JAX-WS 2.2 on Java 6 – maven endorsed

If you create webservices stubs using apache CXF 2.5+, you will most likely run into the following error when you compile your app on Java 6.

You will probably run into the following error.

 

“This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 API jar”

In my case I was using maven to build my project. maven2+JAX-WS API 2.2 on Java 6 dont really play well with the default config. Add the following to your pom.xml to endorse JAX-WS 2.2

 

 

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <compilerArguments>
            <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
          </compilerArguments>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.3</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
              <silent>true</silent>
              <artifactItems>
                <artifactItem>
                  <groupId>javax.xml.bind</groupId>
                  <artifactId>jaxb-api</artifactId>
                  <version>2.2.7</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>javax.xml.ws</groupId>
                  <artifactId>jaxws-api</artifactId>
                  <version>2.2.9</version>
                  <type>jar</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>

localhost is not allowed by Access-Control-Allow-Origin

Recently I ran into the following error while working on my node/express app & client side ajax/jsonp using jquery.

 http://localhost is not allowed by Access-Control-Allow-Origin.

This is a typical CORS error – one domain to another via JSONP ( you can run into this on the same domain different ports – localhost:80 to localhost:3001 etc)

Just add the following in your node/express app

response.header(“Access-Control-Allow-Origin”, “*”);

 

If you are running into this on Chrome browser then you will also need to add the following

 

response.header(“Access-Control-Allow-Headers”, “Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With”);

response.header(“Access-Control-Allow-Methods”, “GET, POST, PUT”);

 

 

Jquery live Vs On

If you have been using Jquery live in your code and have just upgraded to Jquery 1.9 you will notice that live() is no longer supported. Live() was deprecated in 1.7 and was removed as of 1.9

You can fix this by editing your code and changing all your live() method calls to on() or you can simply add the following to your code. What this does is it creates a new method called live and it wraps it with the on() method.

<script>
jQuery.fn.extend({

live: function( types, selector, data, fn, /*INTERNAL*/ one ) {
return this.on(types, selector, data, fn, one);
}
});

</script>

More info@ - https://github.com/vijaykarthik/addJQueryLiveEvent

Enabling git on mac osx mountain lion

Git comes installed on mac osx mountain lion.

All you need to do is edit your bash_profile file and add /usr/local/git/bin to the path env variable.

open terminal

$sudo edit ~/.bash_profile

 

##this will open your bash_profile on your default text editor

## add the following to the file & save it

export PATH=”/usr/local/git/bin:$PATH”

##now run your bash_profile to reset the path

source ~/.bash_profile

 

 

Google App Engine Vs nodejs MVC/MVR

Finally my Google App Engine replacement – nodejs, express, mongoose, backbone, passport and jade. Use nodemon if you want your changes to be published immediately without restarting node.

Solving xml parser cast exception error in JBoss 5xx – Classloader issues

Recently I ran one of my old spring web applications on Jboss 5.0 and ran into ClassCastException.

“java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory”

This is because Jboss 5.0 comes bundled with xercesImpl.jar which conflicts with xml-apis.jar found inside the application’s lib directory.

You can either remove xml-apis.jar from your application by adding an exclusion in your pom.xml file or you can simply tell your app to use your libraries in its lib directory Vs the ones found under Jboss’s lib directory – Simple Classloader instruction to your application

 

Here is how you do it. Within your app’s WEB-INF directory create a file called jboss-classloading.xml

 

inside this file just  add the following

 

<classloading xmlns=”urn:jboss:classloading:1.0″
name=”<your app name>”

domain=”<your app package>”>

parent-domain=”Ignored”

export-all=”NON_EMPTY”
import-all=”true”>
</classloading>

 

 

 

Follow

Get every new post delivered to your Inbox.