We all need to earn our living ...

Your Ad Here

Wednesday, September 09, 2009

Glassfish and Ubuntu

Developing on a Mac is great, but from time to time I have to work on other OSes. One of them is Ubuntu Linux.

And I noticed one thing about Glassfish under Ubuntu: you have to change the AS_JAVA variable in asenv.conf file located on glassfish/config directory.

The default value is often linked to a specific release of the JDK or JRE, so when performing an upgrade (apt-get dist-upgrade or apt-get upgrade) you end up with a non working Glassfish since the old Java path is no more...

One solution I've found is to make this AS_JAVA variable points to a dynamic link updated by Ubuntu upgrade process; so whatever the java release you are using it is always the good one and Glassfish starts.

Here is the value I entered: AS_JAVA="/usr/lib/jvm/java-6-sun/jre/.."

This takes advantage of the fact that the java-6-sun directory is a link to the right release.

Monday, August 10, 2009

OS X, Ruby, Rails and MySQL

Well, Leopard is a great OS, but from time to time it might appeared complex.

For instance, where is the config file used by MySQL and needed by gem install process in order to link Rails to MySQL ?

When you had to install MySQL gem for Rails you noticed that "sudo gem install mysql" does not really worked, now, what to do from here ?

You need something more. But what and where to find it ?

Actually you need to tell gem installer where is you mysql_config file. It is located in your MySQL bin dir, and if you downloaded MySQL as an OS X package on MySQL web site, then what you have to do is very simple:

"sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config"

After what you can use "sudo gem update mysql" to update from time to time gems used to connect to your local MySQL engine.

Enjoy ;-)

Sunday, August 09, 2009

JavaME on OS X

It seems that there are moves toward a release of JavaMe for OS X.

Well, this looks pretty good and very nice since it has been expected for a long time.

Here is a link to the article with screenshots.

Enjoy ;-)

Wednesday, July 15, 2009

Ruby on Rails on OS X

There are many articles on Ruby on Rails on OS X on the net. A quick search on Google let you see thousands.

But, there is one, from Apple, which is really worth looking at. I noticed that many article dealing with Ruby and OS X are using "old" method to install and configure Ruby on Rails for OS X.

This is particularly true for OS 10.5 which includes Ruby and Rails. All you have to do is to update them to the latest version using Ruby tools.

Process are describes here

Monday, July 13, 2009

Netbeans book

I just found out that Apress released a new book covering Netbeans up to version 6.5
"The Definitive Guide to Netbeans Platform".

This updated release covers many aspects of the netbeans rich client platform.

One regret, it does not cover Netbeans 6.7

This is always the same thing, books are often lagging behind versions.

Friday, May 29, 2009

Building ext environment for Liferay

Some of you asked me how to create an EXT directory for Liferay.
Well, this is not that difficult but you need to pay attention to few things.

For those who do not know why an ext dir is interesting: ext directory is used to develop extension to Liferay. You can use them to develop specific configuration, plugins, configuration to your current Liferay platform.
I use it to develop extension such as portlets, but also templates and themes which are used for my projects.
It is good practice to use the ext directory and to built from it a Liferay instance in order to have all specific parameters, pictures, flash, portlets, etc. stored in a place that will not change. If you are building Liferay from SVN, you can not do so otherwise your specific parts will be deleted next time you sync with the repository.

Here is the way I proceed:

First: Liferay
I go for the SVN branche. Now I'm using 5.2.x branch which is the current stable version of Liferay. 5.3.x is pointing out, but still under heavy development and not stable enough to use it as a production or development platform.

Second: Glassfish
I'm using Glassfish 2.1. Just download it from Glassfish web site (download the right bin according to you Operating System).
Then, remember path to it, you will need it later.

Third: Configuring the whole things to get the ext dir
So, now that we have Liferay and Glassfish let's do some configuration.

First, place the right jar libraries at the right place (see here for some explanation on how to do under os x)

Second, go to your Liferay directory and find the following configuration files: app.server.properties and release.properties.

In app.server.properties make sure that Glassfish is selected as your Application Server and that all other application servers are commented out by a #
Then, hard code (or if you are smarter used env variable to do it) path to your Glassfish server. You should have it there: app.server.parent.dir=PATH/TO/YOUR/GLASSFISH/SERVER
example:
let's say your glassfish is under Jhon Doe accoung (jdoe) on OS X:
/Users/jdoe/Documents/JavaProjets/glassfish then you should have the following line in your app.server.properties file:
app.server.parent.dir=/Users/jdoe/Documents/JavaProjets

Make sure that there is no trailing / and that the last directory it the one containing your Glassfish directory as seen in the example just above.

End by saving this file as app.server.username.properties where username is your username as used to log into your computer.
According to the example just above the file should be saved under app.server.jdoe.properties

Now that Liferay is properly configured I suggest a test run before going further and building the ext directory.
So just go to your Liferay directory and enter the following command:

ant start

ant compile

ant deploy

then go to you Glassfish bin dir and make it rock and roll: asadmin start-domain
If nothing come to your display, check your Glassfish logs for error.

If you have a running Liferay, you are free to proceed to the next step and start building your ext directory.

Go to your release.properties file in Liferay and check that you have the following lines:

##
## Extension Environment
##

lp.ext.dir=${project.dir}/../ext

According to your operating system you will have to change / in to \ (\ is for Windows, while OS X, Linux, Solaris will use / as path separator)

Should you have to save changes to this file, remember to name it release.username.properties (according to example you it will be release.jdoe.properties)

Then launch a ant build-ext command and you will have just above your Liferay dir the ext dir you are expecting.
Just go to that directory and make sure app.server.properties is poiting to the right Application Server (here Glassfish) as mentioned above.
For the same reason it is good to save changes in app.server.username.properties

Fourth: this is your time. Just play with it
From here you a free to go alone and play with your freshly build ext directory.

Remember that in order to get it work you'll have to run ant deploy from the ext dir. This will deploy your Liferay instance with all its specific parts.

Saturday, May 23, 2009

Java VisualVM now available in Java SE 6 (OS X 10.5)

Well, for those lucky guys running OS X 10.5.6 or later, it is possible to get access to Java VisualVM.

All you need is an Apple developer account (free) to get access to the download area. There, just download "Java for Mac OS X v10.5 Update 4 Developer Preview".

Once downloaded and installed, open a terminal (I'm using iTerm, which I found more interesting than provided Terminal, but both are ok) and type: jvisualvm to get access to this new and interesting tool to monitor and gather java application and VM data.

I'll let you discover this tool here

VisualJVM screenshot

WARNING: keep in mind this is a Developer Preview, and as quoted by Apple it may lack of testing and stability (and eventually crash you system).


Monday, May 18, 2009

Liferay 5.2.3 on Glassfish on OS X

Well, this has been a long time without a post about Liferay and Glassfish, but here we are.

I went back to some project on this point and started looking at an old "bug" when attempting to deploy Liferay 5.2.3 on Glassfish v2.1 on OS X.

My configuration is OS X 10.5 with both Java 1.5 and 1.6 JDK.

As usual I picked up an SVN version of Liferay and built it up.
The point was after launching Glassfish: Nothing! Or I should say, many error messages at all levels in Glassfish.

I pointed out that many of them were related to XML parsing and that some libraries (jar files) might be missing or not at the right place.
After googling few minutes I found out that the following library have to be moved.
serializer.jar
xalan.jar
xml-apis.jar
xercesImpl.jar

These jar file have to be moved from glassfish/domains/domain1/applications/j2ee-modules/liferay-portal/WEB-INF/lib/ to glassfish/domains/domain1/lib/

If not, then you will see error like this

java.lang.NoSuchMethodError: org.apache.xml.utils.DefaultErrorHandler.(Z)V at org.apache.xalan.processor.TransformerFactoryImpl.(TransformerFactoryImpl.java:
In your Glassfish log.

In addition to moving files to glassfish/domains/domain1/lib/, I also shifted my default JDK to 1.6 instead of standard 1.5

Source : Liferay Wiki

Friday, May 08, 2009

Chantango

I added a small bloglet on the side to let people talk about Java and all other subjects related and/or talked about on this blog.

Enjoy ;-)

Wednesday, May 06, 2009

For those who have read : How to change JDK under OS X, here is a deeper view of the Java Preferences application.

Depending on your JDK (Java) version on OS X this application is either located in /Applications/Utilities/ or /Applications/Utilities/Java/Applications/Utilities
It can be accessed and launched via Finder.

Once launched the first tab that appears is the following:

From this tab you can change default Java version. Note that it is possible to select 32 or 64 bits release when available and this for both: Java Application and Java Applet.
You can use the Restore Defaults to come back to original configuration.

The Security tab mainly stores keychain related to site. This is something really specific, I never used it yet although I have no doubt on its utility.

The next 2 tabs are more used.
Let's see the Network tab first:

Network Setting button is used to define if network settings are going to be the same as the System ones or different. It is though possible to define an other proxy or a direct connexion that will be used by current Java (JDK).
The second part of this tab helps defining Cache folder, size and if JAR file should be compressed or not in order to spare disk space and accelerate application loading and/or start.

The last tab, Advanced, is used to set and tweak lower level features to enforce higher level or security (or decrease security level) and help debugging application (applets) by enabling tracing and logging.

How to change default JDK under OS X

Many of you might want one day to change their default JDK from one to an other since most configuration have more than one JDK install (likely 1.4, 1.5 and latest released by apple 1.6 only for the luck running Leopard).

Well, before that you have to know which version of Java your system is running by default.
In order to have this information just open a terminal and type in: java -version

You should see something like this:
java version "1.5.0_16" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-290) Java HotSpot(TM) Client VM (build 1.5.0_16-134, mixed mode)
Where version is going to change according to your default JDK and state of update.

Then you need to know which Java JDK are present on your system.
For that have a look at the following directory:
System/Library/Frameworks/JavaVM.framework/Versions/
You will see something like this:


Notice the Current and CurrentJDK links.
These links are pointing and thus defining system wide which JDK (Java) is the default on for your system. And these are the things we want to change in order to go from one Java version to an other.

Well, since they are links you might be tempted by changing them by your own via a Terminal and with the help of sudo command. But Apple just has the tool to do it, just here, in /Applications/Utilities (can be access and launched via Finder)


Depending on your update stage this tool might be located in /Applications/Utilities/Java or /Applications/Utilities/Java/Application/Utilities (which can be the correct path for those not using latest build or developers builds)

There is also a other nice tool /usr/libexec/java_home that can be used to define or chage value of $JAVA_HOME which can be used by some application.