Friday 11 September 2009

After setting up environment for developing web services, creating simple Demo service and deploying it, console gave out the following message:
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@337838
org.apache.axis2.transport.http.AxisAdminServlet
java.lang.ClassNotFoundException: org.apache.axis2.transport.http.AxisAdminServlet
...
The cause is that current WTP doesn't support Axis2 1.5 version. Currently it supports only 1.4.1 (see this discussion).

Saturday 27 June 2009

Adding local postgres database to PgAdmin in ubuntu

Synaptic makes both (posgres & pgadmin) installations trivial. After installation you must change password of 'postgres' user:
sudo -u postgres psql postgres
ALTER USER postgres WITH PASSWORD 'secret';
\q
Now add local database in PgAdmin, which shouldn't cause any problems.

Friday 26 June 2009

Eclipse minimal installation

Update: I've created an updated (my) version of installation of minimal versionupdated (my) version of installation of minimal version since link referred in this post is dead.

This post explains how to get minimal eclipse installation. This works great! Now i can install plugins by my choice - i don't need nor CVS, nor RST and a lot of other stuff included in JEE version.
Also new plugin installation has been improved a lot in Galileo. Eclipse keeps getting better and better. Can't wait to see other new features and improvements.

Wednesday 3 June 2009

Maven remote archetype catalogs through proxy

Some days ago created a new maven archetype. Everything went good till i had to deploy it on our maven (Nexus) repository.
First i had to install an archetype plugin. Since i had older Nexus installation, i had to update it to 1.3.x to get that plugin working (later i came across some e-mail treads where developers agreed to create that plugin 1.2.x-compatible... later... :( ).
Finally i could see archetype-catalog.xml through my browser. But when i added it to eclipse as remote file, it gave me WARN messages saying "Error reading archetype catalog http://my.domain.com/service/local/nexus-archetype-plugin/public/archetype-catalog.xml Error transferring file". Now what?!?
It turns out that there's a bug http://jira.codehaus.org/browse/ARCHETYPE-202 - can't fetch remote archetype catalogs through proxy. And no fix versions. yet... Is this the cause?

Now i'm using workaround:
  1. downloadi XML file and save it as /home/me/.m2/archetype-catalog.xml
  2. add it to m2eclipse archetypes as local catalog
  3. repeat after catalog changes :(
Better ideas?

"mvn archetype:generate -DarchetypeCatalog=http://my.domain.com/service/local/nexus-archetype-plugin/public/archetype-catalog.xml"
But why is it working though command line?

There's still much to learn...

Friday 24 April 2009

HIbernate equals/hashCode

Just to write this down:
When implementing equals() or hashCode() methods wich will be used in Hibernate, you should always use properties with real "business value" (keep your hands off the ID).
See also: http://www.hibernate.org/109.html

Eclipse fails to recognise tomcat startup

Some time ago i had a problem with starting tomcat from Eclipse. First time i couldn't solve this problem, but few months ago i run into it again.
Brief introduction to problem:
  1. Start tomcat
  2. Console says "Server startup in ...ms"
  3. Server's state still is "Starting..."
  4. After timeout it says "Server ... failed to start"
My problem was that first page (http://localhost/) contains a redirect. So Ecipse did receive status code 30x (instead of 200 OK). When I removed the redirect, it started working.
Of course, check WTP Tomcat FAQ for other possible problems.

Wednesday 11 March 2009

Java mail MIME type errors

I've developed small job on local machine which sends email with PDF attachments. But when i ran it on test environment, an exception was thrown:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;

While searching the solution, found this question. Solution i found was adding MIME type handlers programmatically:
// add handlers for main MIME types
MailcapCommandMap mc = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);
Others solutions didn't work for me - i had recent activation.jar and mail.jar in WEB-INF/lib folder already. Can someone explain me why META-INF/mailcap file wasn't read from mail.jar?

Monday 2 March 2009

Vendor branches

Little time ago had a little struggle with vendor branches. Red-book describes this concept pretty good, but command line interface is not my favourite (in this particular situation) when it comes to merging.
Preconditions: Eclipse, Subclipse, svn-load (or svn_load_dirs is equivalent, but i'm using Ubuntu and svn-load can be installed from default repositories)
Here's my example:
  1. update vendor version
    svn update /path/to/vendor
  2. copy updated version to another folder (we'll need to disconnect it from SVN)
    cp -r /path/to/vendor /path/to/vendor_copy
  3. disconnect folder from SVN
    rm -fr `find /path/to/vendor_copy -type d -name .svn`
  4. Send changes to SVN with svn-load:
    svn-load -t tags/vendor_version_2009-02-01 \
    http://svn.mydomain.com/projectX \
    branches/vendor \
    /path/to/vendor_copy
    * I prefer tagging each vendor import
  5. In Eclipse be sure that you've committed all changes and you're working in trunk
  6. Merge new tag and previous one:
  7. in Team Synchronizing perspective double check all changes (this perspective is really useful for merging)
  8. commit!
Hope this helps!