Eclipse proxy setting

To enable Eclipse to connect to the internet through proxy:


  • set proxy settings in General -> Network Connections. Set for both HTTP and HTTPS BUT leave SOCKS empty! 
  • Active provider: manual

Export entire oracle database

For a full database export/import use
exp user@DB FULL=Y FILE=PATH_TO_DUMPFILE
imp
user@DB FULL=Y FILE=PATH_TO_DUMPFILE
The user must have EXP_FULL_DATABASE resp IMP_FULL_DATABASE role (or something equivalent, like DBA). DB is your database (e.g. XE, if you have expreess edition)

IntelliJ shortcuts

Moving from Eclipse to IntelliJ was painful mainly because of the keyboard shortcuts that made me so productive in Eclipse have to be relearnt.

1. Moving between occurence.
In Eclipse, this is achieved by placing caret over a class name or an instance, then Ctrl+. or Ctrl+,
In IntelliJ, place the caret on the class name or instance name and press Ctrl+Shift+F7 to mark. Then move to the next/prev occurence by F3 or Shift+F3. To open pop-up window showing all occurences of a certain instance: Ctrl+Alt+F7. After done navigating, press Esc.

2. Showing type hierarchy.
In Eclipse, Ctrl+T.
In IntelliJ,
Ctrl+Alt+U

3. Go to definition
In Eclipse, F3
In IntelliJ, Ctrl+B

4. List all members of a class
In Eclipse, Ctrl+O
In IntelliJ, Ctrl+F12

Go to Class, to quickly open any class in the editor: Ctrl+N
To open any file, not just classes: Ctrl+Shift+N
Comment/Uncomment current line or selection: Ctrl+/ and Ctrl+Shift+/

Rename refactoring to rename any identifier. Can look in comments, text files and across different languages too: Shift+F6
all purpose shortcut is Ctrl+Shift+A

Go to next/prev open tab: Alt+Left/Right
Go to last viewed open tab: Ctrl+Alt+Left/Right.
Go to implementation Ctrl+Alt+B
Go to super class Ctrl+U

More coming up as I discover them

Ant Tasks for Websphere Deployment

The following is my ant for websphere deployment, application start & stop, etc. The complete API doc can be found in IBM website: https://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.wsps.602.javadoc.doc/doc/index.html
For this tasks to run, you need to have the jar file com.ibm.ws.runtime.jar. This jar file can be found in plugins directory of your Websphere installation.

<property name="hostName" value="localhost" />
<property name="connType" value="SOAP" />
<property name="port" value="8880" />
<property name="deployEar.dir" value="C:\Users\firmanw\Documents\zw2\OSMS\build" />
<property name="deployEar" value="osms.war" />
<property name="wasHome.dir" value="C:\Program Files (x86)\IBM\TeamConcert\runtimes\base_v7" />
<property name="app.name" value="osms_war" />
<property name="profile.name" value="profilexfirman" />
<taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpath="com.ibm.ws.runtime.jar" />
<taskdef name="wsStartApplication" classname="com.ibm.websphere.ant.tasks.StartApplication" classpath="com.ibm.ws.runtime.jar" />
<taskdef name="wsStopApplication" classname="com.ibm.websphere.ant.tasks.StopApplication" classpath="com.ibm.ws.runtime.jar" />
<target name="installEar" depends="build.osms">
<echo message="Deployable EAR File found at: ${deployEar.dir}/${deployEar}" />
<wsInstallApp ear="${deployEar.dir}/${deployEar}" wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="profilexfirman" options="-appname ${app.name} -usedefaultbindings -update" />
</target>
<target name="startInstallEar" depends="installEar">
<echo message="Mulai ngestart" />
<wsStartApplication wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="${profile.name}" application="${app.name}" />
</target>
<target name="startEar">
<echo message="Mulai ngestart" />
<wsStartApplication wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="${profile.name}" application="${app.name}" />
</target>
<target name="stopEar">
<echo message="Mulai nyetop" />
<wsStopApplication wasHome="${wasHome.dir}" conntype="${connType}" port="${port}" host="${hostName}" profilename="${profile.name}" application="${app.name}" />
</target>

<target name="restartEar" depends="stopEar, startEar"></target>

Websphere hot deployment and dynamic reloading

In the office we use Websphere AS and RAD as IDE. When you make changes to a Java class file, the changes are publised by the IDE to the AS, and the server restarts for the changes to take effect. This is in contrast to the changes done to JSP which do not require server restart to take effect. Actually there is a possibility of hot deployment and dynamic reloading (http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/trun_app_hotupgrade.html) which basically works like this: you replace the class file in the server with the new class file and the changes should take effect immediately without needing server restart. This is a very useful feature of WAS and it makes me wonder why the WAS plugin for RAD/Eclipse does not have a feature to enable this. I know there are limitations, like when you replace Hibernate entities or deployment descriptor, then you still need to restart the server but generally this feature is very useful during development.

So i decided to write an ant build file which runs when there is an automatic build. The job of this build file is basically to replace the class files in the server with the newly built class files in the workspace.

To do this, I first need to manually deploy the EAR via the WAS console. This is to make the exploded EAR file available in the server. Because when i deploy the ear by right clicking on the project -> run as -> run in the server, the exploded ear file is not there in the server! I dont know where, probably in one of the numerous plugin directories of the RAD/Eclipse installation.

After the ear file is manually deployed, then disable automatic publishing in the WAS plugin.


And then the ant build file:



Pretty obvious I guess. The src.osms is the workspace build directory while the des.osms is the WAS exploded ear directory. The most important part of the build file is the mnodified selector (https://ant.apache.org/manual/Types/selectors.html#modified) which selects only recently modified file (which is the file newly built by Eclipse automatic build) and copies these files to WAS.

Now, this ant build file needs to run everytime you modify a class file or anything, so enable automatic build on your project.

And then right click on your project -> properties -> builders -> new -> ant builders -> OK. You get this dialog
Choose your ant build file. Then click on the target tab and set the target for manual build and auto build. Done.


PS: if you have money, try JRebel.

Migrating app from Glassfish to JBoss

I have trying to port app written for Glassfish to JBoss Wildfly, since i met numerous issues with Glassfish. The default JPA impl for Glassfish is EclipseLink, while for Wildfly it is hibernate. I wanted to keep using EclipseLink in Wildfly.

1. Download eclipselink. http://www.eclipse.org/eclipselink/downloads/

2. Unzip it, copy the eclipselink.jar to modules/system/layers/base/org/eclipse/persistence/main

3. Update module.xml in the directory to reflect the change:
























Make sure to match the exact name of the jar file in module.xml. If the jar file includes version numbers, for example, this should be reflected in module.xml file.

3. Execute the following while Wildfly is running:

jboss-cli.sh --connect '/system-property=eclipselink.archive.factory:add(value=org.jipijapa.eclipselink.JBossArchiveFactoryImpl)'

Or alternatively, modify standalone.xml to add the following:


4. Add the following dependence to pom.xml. Make sure the version matches the version of eclipselink jar you copied in Wildfly directory in step 2.








5. Define the provider for eclipselink in persistence.xml












Note that if the provider tag in persistence.xml is removed, then the app server will fallback to the default JPA implementation, which is hibernate for Wildfly and eclipselink for Glassfish.


Changing default JDK in Mac OS X Mavericks

So i have two installations of JDK on my Mac OS X. 1.7 and 1.8. The following is to list all JDK in Mac.


/usr/libexec/java_home -V

The above command resulted in the following:

Matching Java Virtual Machines (2):
    1.8.0_05, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home
    1.7.0_25, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home

Because of some problem with Spring when using Java 8, i need to change the default back to Java 7. This is what i do to the .profile file in my home directory.

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
#export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Sorted!