Archive for the ‘howto’ Category

HowTo: Setup GWT remote logging

Posted: February 26, 2013 in howto, Java, Technology
Tags: , , ,

I find the official documentation on remote logging wasn’t complete. Here are my notes based on various web sites I visited (here, here, and here). Hope this helps!

App.gwt.xml

You should add the inherits statement below. You should be able to adjust the log level to any of the following: ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE. I find the popup log console in the browser annoying, so I disabled it.

<inherits name=”com.google.gwt.logging.Logging”/>
<set-property name=”gwt.logging.simpleRemoteHandler” value=”ENABLED” />
<set-property name=”gwt.logging.logLevel” value=”FINEST”/>
<set-property name=”gwt.logging.enabled” value=”TRUE”/>
<set-property name=”gwt.logging.consoleHandler” value=”ENABLED” />
<set-property name=”gwt.logging.popupHandler” value=”DISABLED” />

web.xml

The following code is necessary for the server to receive log information and redirect to server log file.

<servlet>
<servlet-name>remoteLogging</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogging</servlet-name>
<url-pattern>/YOUR_MODULE/remote_logging</url-pattern>
</servlet-mapping>

java

Here is the example code you can use in GWT client-side.

import com.google.gwt.logging.client.SimpleRemoteLogHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;

SimpleRemoteLogHandler remoteLog = new SimpleRemoteLogHandler();
remoteLog.publish(new LogRecord(Level.INFO, “log message”));

Revisiting SSH Tunneling Tricks

Posted: September 4, 2012 in howto, Technology
Tags: ,

SSH tunneling is so useful that I find myself revisiting it again. This post helped me to get started. I would add the -f option to run the command in the background. 5126 is the port I use on my own machine once the tunnel is established.

ssh -f -N -L 5126:TARGET_SERVER:22 USER@GATEWAY_SERVER

Once the tunnel is established, I could establish a ssh connection using the tunnel. In this case I also enabled X forwarding.

ssh -X -p5126 USER@localhost

Listing files excluding certain names

Posted: August 28, 2012 in howto, Technology
Tags:

I need to list all files in a directory tree excluding files with certain text in its names. This thread helped me to create something similar:

find . -type f |grep -v '/[.svn-base]' -

Call Forwarding

Posted: August 26, 2012 in howto
Tags: ,

I need to forward a call to a different number when the cell phone is unattended or has no signal. This inquiry led me to the following instructions. It worked beautifully! :)

Cloning a disk

Posted: August 22, 2012 in howto, Technology
Tags: , , ,

Today I tried to use Parted Magic to clone a disk. At first, I used Clonezillathat came with Parted Magic. It failed on the last partition, which was a lvm2 pv partition. Next, I tried dd command with basic options, i.e.

dd  if=/dev/sda of=/dev/sdb 

That returned with an IO error. Then I used ddrescue, also bundled in Parted Magic, by following the first example to do a simple disk-to-disk clone. The command completed without a single error! The cloned disk boots successfully as well. :)

I needed to migrate a folder from one Subversion server to another. So, I attempted to follow this page to use dump with svndumpfilter. This combo led me to a lot of issues. The dump command exports all the commits for a repository while svndumpfilter attempts to filter the folder I am interested to keep. Unfortunately, the filter tool is very buggy and unable to filter correctly. Here are the scenarios that did not work for me:

If a commit contains a move action with source location outside of the folder I want to include, the filter fails. I had to include that location when filter. If a commit contains an add action, the parent folder has to exist when loading. I could resolve this by creating the parent folder manually. If a commit contains a delete action and the target folder/file doesn’t exist, the load fails. I could try to create the folder/file manually in an attempt to not fail the delete action. This trick didn’t work when the commit includes a delete of parent folder before attempt to delete the file in it.

When I about to give up, I came across svndumpfilter3 and was happy to find it dump/load without an error. :) Here are the commands I used:

svnadmin dump [path to source repository] | ./svndumpfilter3 --untangle=[path to source repository] [target folder to include] > dump_file.dmp

svnadmin load [path to target repository] --parent-dir [path to target parent dir] < dump_file.dmp

I needed to start svnserve at boot time as a particular user on Red Hat Enterprise Linux. After looking at this and this posts, I came up with the following:

/etc/rc.d/rc.local
su svn -c "svnserve -d"

 

This effectively runs svnserve in daemon mode as svn user after all other init scripts ran at boot time.

I find this howto very useful on accessing both Exchange email and calendar from a linux machine. Very happy! :)

SVN::Notify

Posted: April 13, 2012 in howto, Technology
Tags:

After setting up an instance of SVN using the instructions I found here. I wanted to setup email notification for every commit on a SVN server. I was able to setup SVN::Notify using the tutorial on this page. When attempting to run perl -MCPAN -e 'install SVN::Notify', the install command complained that MakeMaker version is not new enough. So, I went to this CPAN page and download the module and install it before resume installing SVN::Notify. The install command complained again about a missing directory. I repeated the command and the installation completed successfully. :)

The instruction statement on “replace the existing call to commit-email.pl” wasn’t very clear to me. It didn’t say which file I should edit. I eventually figured out that I should make a copy of [SVN_REPOSITORY]/hooks/post-commit.tmpl file and name the new file [SVN_REPOSITORY]/hooks/post-commit. In the file, I commented out the following line:

mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

Next, I added the following line:

/usr/bin/svnnotify --repos-path "$1" --revision "$2" --to me@mydomain.com --user-domain mydomain

Please note that I replaced me@mydomain.com and mydomain with correct values for my environment. I also ran the following command to make it executable.

chmos +x post-commit

After completed all these, I was able to receive the email notification every time an user commit to the repository. :)

Maven + GWT
I needed to create a GWT project using maven again. The original post lacked some details. This time, I got it to work with a slightly different steps. First, I ran the following command:

mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchtypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.4.0 -DarchetypeRepository=repo1.maven.org

Somehow, Maven didn’t pickup the group ID and artifact ID. So, I had to choose from one of the listed item.

Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 337
Choose org.codehaus.mojo:gwt-maven-plugin version: 
1: 1.1
2: 1.2
3: 2.1.0
4: 2.1.0-1
5: 2.4.0
Choose a number: 5: 5

Next, I defined the properties for my project.

Define value for property 'groupId': : com.my.app.package.name
Define value for property 'artifactId': : directoryNameForTheGeneratedProject
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  com.my.app.package.name
Define value for property 'module': : moduleName

Now I can run the generated module with the following command. This will bring up a console. All I have to do is copy the URL and then past it in the browser.

mvn gwt:run

Maven + Eclipse
Next, I followed the instructions on this page to run the following command within the project folder to enable support for Eclipse:

mvn eclipse:eclipse

Then, I use Eclipse to import existing project into workspace to open the project. Eclipse complained that the default directory for the project should be set to /PorjectFolder/src/main/webapp/WEB-INF/classes Since I want to use Maven to build, I ignore the error by right click on the error, choose quick fix, choose Do not use the WAR directory for ProjectName launching and deploying (this disables management of WEB-INF)

Maven + WebLogic
I noticed that the JRE libraries were referencing version Java SE 7 jars, I changed it to 6 so the project will be compatible with WebLogic 11g. For WebLogic 12c, see this post.

I followed the instructions to configure WebLogic 11g with Maven. The available commands for 11g are slightly different from 12c. They are are deploy, help, list-apps, redeploy, start-app, stop-app, undeploy, update-app. Once I completed the configuration, I was able to run mvn weblogic:list-apps command. Next, I ran mvn package to create the WAR file before attempted mvn weblogic:deploy. I was able to load the application in my browser! :)