WebService.class not found

[javac] An exception has occurred in the compiler (1.5.0_18). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
[javac] com.sun.tools.javac.code.Symbol$CompletionFailure: file javax/jws/WebService.class not found

If you get such an error the JSR 181 is missing.

I added the following Ivy dependency to fix the issue while I’m using http://mvnrepository.com/artifact as my repository root.

<dependency org="javax.jws" name="jsr181-api" rev="1.0-MR1"/>
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Eclipse, Axis2 and Tomcat

If you are looking for a howto for that toolchain you’re wrong here. If you are here because you’ve got the same/similar problem than me, go on.

While I was following step 6 in this tutorial I got the following error.

Result: Failed while installing Axis2 Web Services Core 1.1

This forum wasn’t useful for me so I updated my Axis2 to the latest release 1.5.3 and checked the axis2 and tomcat preferences. The web service runtime was unfortunately set to Apache Axis so I changed it to Apache Axis2.

I did step 6 of the tutorial again while I deselected Javascript in the Project Facets dialog this time and it happily worked. Then I created another project with Javascript selected but I got the same error from above again. From that point on the error alway appeared regardless the Javascript selection. No chance to get rid of that error message.

Does somebody experience the same? Any workaround?

Update 1:

I downgraded to Eclipse Java EE IDE for Web Developers (Build id: 20100218-1602, Galileo) but this time eclipse hanged up while I was creating the Dynamic Web Project. The process “waiting user operation” stuck. I updated the packages (Help > Check for Updates) and only an xml problem appeared which seems to not be a big problem as I was now able to create a project without any error messages.

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Installing buildr

Installing buildr

sudo gem install buildr -v 1.3.5

recently failed. I got an environment variable JAVA_HOME not set error which was definitely set to /System/Library/Frameworks/JavaVM.framework/Home in ~/.profile.

I noticed later that exporting the java home in that file unfortunately doesn’t have an effect on the environment variables under sudo. The trick is to pass it to sudo.

sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.5
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

ID3 batch editing

Some of my music had no interpreter and title tags set thus I wrote a little shell script to batch edit these ID3 tags. The filenames of the songs looked like “01 Interpret – Song Title.mp3″. In a few moments I wrote the following php script1 which split the filename into the interpreter and the title.

All the python scripts listed here are using the library pytagger.

<?php
if ($handle = opendir('.'))
{
   while (false !== ($file = readdir($handle)))
   {
	   if ($file != "." && $file != "..")
	   {
		$file_name = $file;
		$file = explode("-", $file);

		if(count($file) < 2)
		  continue;

		$interpret = trim($file[0]);
		$title = trim(str_replace(".mp3","",$file[1]));

		echo "interpret: $interpret , tite: $title \n";
		// execute the python script id3.py to set the tags
		exec("./id3.py '$file_name' '$title' '$interpret' ");
	   }
	}
}

closedir($handle);
?>

Unfortunately I forgot to strip the digits so all the interpreters had two leading digits afterwards.

I had to iterate over the files again. As id3.py creates new tag frames I had to write another script (fix_interpreters.py) that reads the old frames to get the old values.

#!/usr/bin/env python

from tagger import *
import sys, os, fnmatch, pickle, re

filename = sys.argv[1]

print "Processing '", filename, "'"

try:
  id3 = ID3v2(filename)

  if id3.tag_exists():
    interpret_frame = None
    for frame in id3.frames:
      interpretfid = 'TPE1'
      if id3.version == 2.2:
        interpretfid = 'TP1'

      if frame.fid == interpretfid:
        interpret_frame = frame
        break

    interpret = interpret_frame.strings[0]
    repaired = re.sub('^\d\d\s', '', interpret)

    print "Repairing "", interpret, "" => "",repaired,"""
    interpret_frame.set_text(repaired)

    # replace interpret frame
    id3.frames = [frame for frame in id3.frames if frame.fid != interpretfid]
    id3.frames.append(interpret_frame)
    id3.commit(pretend=0)

except ID3Exception, e:
  print("ID3 exception: %s" % str(e))

I didn’t want to rewrite the php script above because I thought that typing a loop in the shell would be easier (or at least faster).

for file in `ls -1 *.mp3`; do ./fix_interpreters.py $file; done

I tried it with this loop but ls -1 *.mp3 doesn’t list each mp3 file one per line as expected. Instead it splits the filenames after each whitespace. Thankfully to Greg Miller’s post about Handling Filenames With Spaces this wasn’t no problem anymore. I changed the loop into

find ./ -name '* *' | while read filename; do ls -ld "$filename"; ./fix_interpreters.py "$filename"; done

and ta-da, it worked.

  1. PHP scripts can be executed in a shell. Use php -f script.php to execute a file or use -r instead of -f to run inline code.
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

jQuery: eq() vs. get()

There are several ways to access queried DOM elements. You get either a DOM element using get() or a jQuery object using eq(). This can be confusing while you try to call jQuery API functions on DOM elements.

The example shows how to get the first array element on three different ways.

<ul>
  <li></li>
  <li></li>
  <li></li>
</ul>

<script type="text/javascript">
    $(document).ready(function(){
        var elems, elem;
        elems = $("li"); // get an array of all the list items

        // This is a jQuery object that you can call jQuery related methods on.
        elem = elems.eq(0); 

        // This is the DOM element itself that lets you access the native
        // javascript attributes and methods.
        elem = elems.get(0); 

        // This is the DOM element too.
        elem = elems[0];
    });
</script>

Instead of using the filter method eq() you can combine the filter with the selector like this

var elem = $("li:eq(0)");

or

var elem = $("li:first");

To turn a DOM element into a jQuery object you can wrap it with jQuery(element) or $(element) if you’re not in conflict mode. But keep in mind that this creates a new object which wastes consumes memory so pay attention if you do this in a loop.

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare