Friday, January 15, 2010

This blog entry only makes sense if you've read Chapter 14 of the Bucky Book.

I have a Mac Book Pro with Snow Leopard. I tried with both Eclipse 3.5.1 and Eclipse 3.6M4. It works with neither. It does work, however, with Linux (Ubuntu) and Eclipse 3.5.1. I haven't tried Eclipse 3.6M4 on Linux.

Installation Issues

There's something going on with installation that I don't understand. I think of the Buckminster installation as having three steps.

Why is the headless SVN Subclipse client from the cloudsmith site and not from eclipse.org? The Bucky Book refers to the software as

The headless integrations for Subclipse and Subversion contain plug-ins has licenses which prohibits them from being redistributed from Eclipse.org. Instead, we distribute them from Cloudsmiths website. The update site can be found at http://download.cloudsmith.com/buckminster/external. (page 233)

When I worked with Eclipse 3.6M4, I used the site http://download.eclipse.org/tools/buckminster/updates-3.6 instead of http://download.eclipse.org/tools/buckminster/updates-3.5

Now I cannot install all three of the above into the same eclipse.

I cannot install both the Buckminster SVN Support (Subclipse) from http://download.eclipse.org/tools/buckminster/updates-3.5 and the headless SVN Subclipse client from http://download.cloudsmith.com/buckinster/external. This problem does not depend on the order in which I install them.

To get the exmple to work I need Buckminster and the headless SVN Subclipse client.

Buckminster, headless SVN Subclipse client, Buckminster SVN Support (Subclipse)

If I install Buckminster, then the headless SVN Subclipse client, and then try (fail) installing Buckminster SVN Support (Subclipse), I get the following error.

Cannot complete the install because of a conflicting dependency.
Software being installed: Buckminster - Subclipse support 1.0.0.r11055 (org.eclipse.buckminster.subclipse.feature.feature.group 1.0.0.r11055)
Software currently installed: Buckminster - Subclipse based SVN support for headless operation 1.0.0.r10759 (org.eclipse.buckminster.subclipse.headless.feature.feature.group 1.0.0.r10759)
Only one of the following can be installed at once:
Buckminster Subclipse Support Plug-in 1.0.0.r10356 (org.eclipse.buckminster.subclipse 1.0.0.r10356)
Buckminster Subclipse Support Plug-in 1.0.0.r11055 (org.eclipse.buckminster.subclipse 1.0.0.r11055)
Cannot satisfy dependency:
From: Buckminster - Subclipse support 1.0.0.r11055 (org.eclipse.buckminster.subclipse.feature.feature.group 1.0.0.r11055)
To: org.eclipse.buckminster.subclipse [1.0.0.r11055]
Cannot satisfy dependency:
From: Buckminster - Subclipse based SVN support for headless operation 1.0.0.r10759 (org.eclipse.buckminster.subclipse.headless.feature.feature.group 1.0.0.r10759)
To: org.eclipse.buckminster.subclipse [1.0.0.r10356]
 

Buckminster, Buckminster SVN Support (Subclipse), headless SVN Subclipse client

If I install Buckminster, then the Buckminster SVN Support (Subclipse), and then try (fail) installing the headless SVN Subclipse client, I get the following error.

Cannot complete the install because of a conflicting dependency.
Software being installed: Buckminster - Subclipse based SVN support for headless operation 1.0.0.r10759 (org.eclipse.buckminster.subclipse.headless.feature.feature.group 1.0.0.r10759)
Software currently installed: Buckminster - Subclipse support 1.0.0.r11055 (org.eclipse.buckminster.subclipse.feature.feature.group 1.0.0.r11055)
Only one of the following can be installed at once:
Buckminster Subclipse Support Plug-in 1.0.0.r10356 (org.eclipse.buckminster.subclipse 1.0.0.r10356)
Buckminster Subclipse Support Plug-in 1.0.0.r11055 (org.eclipse.buckminster.subclipse 1.0.0.r11055)
Cannot satisfy dependency:
From: Buckminster - Subclipse support 1.0.0.r11055 (org.eclipse.buckminster.subclipse.feature.feature.group 1.0.0.r11055)
To: org.eclipse.buckminster.subclipse [1.0.0.r11055]
Cannot satisfy dependency:
From: Buckminster - Subclipse based SVN support for headless operation 1.0.0.r10759 (org.eclipse.buckminster.subclipse.headless.feature.feature.group 1.0.0.r10759)
To: org.eclipse.buckminster.subclipse [1.0.0.r10356]

What I need for the example

The example consists of creating an rmap and a cquery and then bringing up the cquery in the Component Query Editor and selecting Resolve and Materialize. For this Resolve and Materialize to work I need Buckminster and the headless SVN Subclipse client installed.

If I install just Buckminster and Buckminster SVN Support (Subclipse) and try to Resolve ad Matrialize, I get an the following error.

ERROR [0001] : No suitable provider for component org.demo.hello.xml.world was found in resourceMap http://www.eclipse.org/buckminster/samples/rmaps/demo.rmap
ERROR [0001] : No suitable provider for component org.demo.hello.xml.world was found in searchPath default
ERROR [0001] : Rejecting provider svn(http://dev.eclipse.org/svnroot/tools/org.eclipse.buckminster/trunk/org.eclipse.buckminster/demo/{0}): No component match was found
ERROR Unable to load default SVN Client
Errors and Warnings
E [0001] : No suitable provider for component org.demo.hello.xml.world was found in resourceMap http://www.eclipse.org/buckminster/samples/rmaps/demo.rmap
E [0001] : No suitable provider for component org.demo.hello.xml.world was found in searchPath defaultE [0001] : Rejecting provider svn(http://dev.eclipse.org/svnroot/tools/org.eclipse.buckminster/trunk/org.eclipse.buckminster/demo/{0}): No component match was found: Unable to load default SVN Client

Results of running the example

First of all, note that I am installing Buckminster and the headless SVN (Subclipse) client. To run the example, you must Resolve and Materialize the cquery. Three projects are created: org.demo.hello.xml.world, org.demo.xml.provider, and org.demo.worlds. Then, run org.demo.hello.xml.world as an Eclipse application.

If I do this on my Mac with Eclipse 3.6M4, I get the following error when I try to Resolve and Materialize.

If I do this on my Mac with Eclipse 3.5.1, I can Resolve and Materialize, but I fail when I try to run the example as an Eclipse application. I get the following error. This may not be so unreaonable because the Mac is a 64-bit machine.



If I do this on Linux with Eclipse 3.5.1 (my Linux is running vitutally on my Mac under Parallels), it actually works. Here's what the example look like when running in the runtime workbench as an Eclipse application.




Reproducing the example

If I delete (projects and contents) of the three created projects and then Resolve and Materilize, I get the following error.

ERROR [0001] : CSpec se.tada/tada-sax has no action, group, or local artifact named java.binary.archives
CSpec se.tada/tada-sax has no action, group, or local artifact named java.binary.archives
TAG-ID 0001 = Query for org.demo.hello.xml.world

Can I fix this? Sort of. I tried first by reinstalling Eclipse, but this did not solve the problem. If I delete the workspace and make a brand new one, even remaking the project with its rmap and cquery files, the example works. Apparently just deleting the projects is not enough. Even going into the workspace directory and cleaning it out with command lines apparently is not enough.




1/15/2010 11:50:44 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, January 14, 2010

So I want to try out Buckminster. I got the book, Eclipse Buckminster, The Definitive Guide by Hendrik Lindberg (affectionately called the Bucky Book). It's a pdf downloadable from the Buckminster site, http://www.eclipse.org/buckminster/ . It's at version 0.6, but hasn't been updated since July, 2009.

I'm running Eclipse 3.6M4 on a Mac with Snow Leopard. To get Buckminster, go to the Buckminster site and click on Downloads. You get the screen below. I took the Buckminster updates-3.6 for the 3.6 bleeding edge.




Then, go to Help -> Install New Software and put in the Buckminster update site.




What follows is a record of my running the example in Chapter 13 of the Bucky Book. This example builds a p2 update site for a simple plugin.

Create a plugin (File New Other Plugin Project) called org.demo.demoplugin and a feature (File New Other Plugin Development Feature Project) called org.demo.demofeature and choose org.demo.demoplugin as the plugin for the feature.

But then the key seems to be that you make another Feature Project called org.demo.demosite for the update site. This describes the update site. This feature (called the site feature) does not itself get published.

For the site feature,

  • Specify the Included Features to include org.demo.demofeature.
  • Add category lines to this feature's build.properties.
category.id.org.demo.democategory=Cool Features (demo)
category.members.org.demo.democategory=org.demo.demofeature
category.description.org.demo.democategory=Cool stuff build in a Buckminster demo

  • Create a buckminster.properties file. I added the file to the project org.demo.demosite.
# Where all the output should go
buckminster.output.root=${user.home}/BuckyFiles/BuckyDemo/demosite
# Where the temp files should go
buckminster.temp.root=${user.home}/BuckyFiles/BuckyDemo/tmp/demosite.tmp
# How .qualifier in versions should be replaced
qualifier.replacement.*=generator:lastRevision

Then, create the update site by right-clicking on org.demo.demosite, selecting Buckminster Invoke Action and pointing action properties to buckminster.properties, then choosing site.p2 as the action.



Click OK.




The update site gets made at /Users/ted/BuckyFiles/BuckyDemo/demosite/org.demo.demosite_1.0.0-eclipse.feature/site.p2.

Then, you can use the new p2 update site by pointing to file:/Users/ted/BuckyFiles/BuckyDemo/demosite/org.demo.demosite_1.0.0-eclipse.feature/site.p2/. Note that the / after site.p2 is important.




Click Next, then Finish. I get a warning that I am installing unsigned content. Click OK. Restart Eclipse, and when it comes up, do a Window -> Show View -> Other and choose the Demoplugin View.



 

This is the default Plugin with a View. To uninstall it, go to Help ->Install New Software and click on already installed. Then, select Demofeature and click Uninstall. Confirm the Uninstall Details and click Finish. Restart Eclipse.


1/14/2010 12:15:54 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, January 12, 2010

I want to get ECF code from the Eclipse CVS repository. First, open up a CVS Repositories view and create a new repository location. I choose pserver (for anonymous checkout) and leave the password field blank. If you're a committer, you choose extssh and enter your name and password.

Or sometimes, you're a committer and you just want to use pserver. Note, however, that there is a time lag between extssh and pserver. Usually this is irrelevant. But you might miss the very latest checkins if they are close to when you checkout with server. And sometimes this can cause a build to fail.

The reason there is this time lag is so that extssh can be more performant.



Then, from the CVS Repositories view, checkout org.eclipse.ecf.releng. The result is that there is a org.eclipse.ecf.releng project shown in Package Explorer.

Right click in Package Explorer and choose Import .... Select Team Project Set and click Next. Then, in the window that appears, click the Browse button beside File name: and browse to the file projectSet-anonymous.psf.

Click Finish. A window appears asking if you want to overwrite org.eclipse.ecf.releng. Choose No (although it really doesn't matter).

A bunch of projects get checked out. I make a run configuration and call it Eclipse ECF. For Location, I put in ${workspace_loc}/../runtime-Eclipse_ECF. For Program to Run, I choose Run a product and specify the product as org.eclipse.sdk.ide. Then, I click Run.



 

The runtime workbench comes up. I can customize the perspective to show the ECF menu. This is cool. However, if I drop down the ECF menu and try to connect to Eclipse IM, XMPP, or XMPPS, I get an error. It does not accept my credentials. I think this is a known bug, namely https://bugs.eclipse.org/bugs/show_bug.cgi?id=291797

The IRC provider works just fine.




Click Finish. No password is needed.




1/12/2010 11:37:55 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, December 24, 2009

Example: Building a Plugin

I've been reading Practical Eclipse Rich Client Platform Projects by Vladimir Silva. I've read the first two chapters and skimmed the rest (there are 10 chapters). The first chapter is called “Foundations of Eclipse RCP,” but it doesn't discuss RCP. There is an introduction to creating a plugin with eclipse, which is certainly something you need to understand before building an RCP application.

The book has a copyright of 2009 (this year barely) but uses Eclipse 3.4. I'm using 3.6M6, and eclipse has changed a bunch, specifically in the way one installs/uninstalls plugins. With 3.5 we started to use the p2 updated sites. Copying a bunch of plugins into your plugins directory is no longer the way.

It's disappointing that a book with a 2009 date is so out of date. I do want to stick with Eclipse 3.6 and figure out how to do these installations and navigate the new UI because 3.6 is where it's at.

Each chapter ends with a hands-on exercise preceded by a discussion of the tools needed for the exercise. Sometimes the tools discussion reads like a group of unrelated facts with code snippet examples. The examples often seem out of context ... yes, there's this xml or this java code, but how does it fit into a working application. The hands-on exercise is supposed to provide that context, but in my opinion seldom succeeds.

Now what I said may sound that I am disappointed in the book, but I'm not. As I've said, I've only read the first two chapters and skimmed the rest. I will read the rest. I want to know how to make a standalone RCP application, but my skimming seems to show how only to run that RCP application from within eclipse. Maybe not, we'll see.

I'm using a Mac Book Pro with Snow Leopard.

The Hands-On from Chapter 1

I struggled with this, but I think my issues were mostly due to me and not the book. I downloaded the source code. Just looking at it was not enough for me. I had to import the project into my workspace. Once I did that, I could build my own identical project.

I'm thankful that this first project is not trivial. It actually does show stuff that I think will turn out to be useful later in the book. Here's a quote that describes what the first exercise is.

... you will write a plug-in to embed a tiny Jetty web server that uses Equinox to define a simple servlet class that returns the headers of the HTTP request.

Sticking Points

Here are some sticking points I had. I'm not faulting the book on these points. When you read the book carefully, these problems are answered. 

  • The project doesn't come with a run configuration. Does it, and I don't know how to see it? I made my own.

When I tried to run this example, I got a permission denied error. I think this is because Jetty wants to start on port 80, but where that is specified I don't know. The way to fix this (and the book has a note on this, but says the note is specific to Linux and does not mention the Mac) is to add the following VM argument to the run configuration: -Dorg.eclipse.equinox.http.jetty.http.port=8080

I did not want to run as root (a bad thing). On the Mac, I don't know how to have eclipse run as root when I run by clicking my icon. I have to become root in a command line and start up eclipse from the command line.

  • I kept running the example as I changed things and got a “port already in use” error. I needed to click on that red Terminate button in the console window before trying again. Yes, this is something I should have known.

  • I didn't understand why I didn't see an osgi prompt in my console window (the prompt is osgi in lowercase). The way to fix not seeing the prompt is to add the Program argument -Console to the run configuration. This is actually mentioned in the book, but it says that Console starts the OSGi console. I was foolish enough to think that the Program argument -consolelog or the default VM argument -Dosgi.noShutdown=true did this. The book says that this VM argument is useful for examining the OSGi framework ... don't you need the osgi prompt for that?

  • I didn't see the output. Wow, guess what ... you have to start up an external browser and point it to http://localhost:8080/servlet. That servlet is the alias which appears under Extension Element Details, and it isn't the default.

  • I wasn't including enough bundles in the run configuration's target platform. I unselected all the bundles under Target platform and then selected only those I had included in the Required Dependencies under the Dependencies tab in the Manifest editor. The correct way to do this is to deselect everything under Target platform, ensure that only the correct workspace is selected and then click the Add Required Bundles button.

    It is beneficial to select the Only show selected bundles checkbox. There are (in my configuration) 375 possible bundles. They don't fit on the screen, and you have to scroll to see what is selected. This method shows that 23 bundles are selected, a lot more than those four that I put into the manifest.

How the Application Looks When It Runs

Here's how the application looks when run. I did an ss at the osgi prompt to display its registered bundles. At this prompt you can start and stop bundles. To stop ch01a_1.0.0, issue stop 27. To start it, issue start 27.

Here's the output from http://localhost:8080/servlet1. Yes, I changed my alias from servlet.




Here's how it looks from within eclipse.




 

How to Configure the Project 

  1. File -> New Project and choose Plug-in Project. I called it ch01a (my imported project from the source download was ch01). Even in Eclipse 3.6M4, you select the Eclipse version 3.5; 3.6 is not in the dropdown because 3.6M4 is still a milestone release.
  2. Click Next. I removed the .qualifier from thePlug-in version, just because it wasn't in the book's figure.
  3. Ensure that “This plug-in will make contributions to the UI” is unchecked.
  4. Click Next. The Manifest editor opens up.
  5. Click on the Dependencies tab and add the plugins: javax.servlet, org.eclipse.equinox.http.jetty, org.eclipse.equinox.http.registry, org.eclipse.equinox.http.registry, and org.eclipse.equinox.http.servlet. Note that the selection window that comes up is blank, but bundles appear when you type in the “Select a Plug-in” box.
  6. Click on the Extensions tab. Add the extension point org.eclipse.equinox.http.registry.servlets. A class name and alias appears on the right under Extension Element Details. Change the alias.
  7. Click on class. In the window that appears, type in javax.servlet.http.HttpServlet for the superclass.
 

The Source Code

I'm not going to show the code. It's not my code. It's available in the source code download from http://www.apress.com. Although the book recommends Apache Log4j, the example uses the Commons Logging service that comes with eclipse.

Good stuff to learn by reading it. There are two java files: Activator.java and Servlet1.java (the book has Servlet.java).

Other References

I found the link http://www.eclipse.org/equinox-portal/tutorials/server-side/ which is helpful. It has a similar but simpler example.

 | Eclipse
12/24/2009 2:58:06 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, December 23, 2009

How do Java projects made with Eclipse work outside of Eclipse?

I usually work within Eclipse, but sometimes I get questions like can you run an application built with Eclipse from the command line? And you can. It's pretty straightforward, and I don't know if I'm doing it in the best way. But here is what I did. I have two examples.

First Example: Hello World

The first is just a Hello World. I'm using Eclipse 3.6M4 on the Mac. I made a Java project with File-> New -> Java Project. I called the project com.ted.hello. I made an empty package in the project and then added a class called Hello. Run it as a Java Application from within Eclipse, and it looks like the following. It prints out “hello java” to the console.



 

My workspace is /Users/ted/EclipseProjects/work36M4RCPA. Don't ask why the workspace is called that. I was just trying out some RCP applications earlier and used an existing workspace.

To run this Hello Java program from the command line, go into the directory /Users/ted/EclipseProjects/work36M4RCPA/com.ted.hello/bin. The structure under bin looks like

newtricks:bin ted$ find .
.
./com
./com/ted
./com/ted/hello
./com/ted/hello/Hello.class
newtricks:bin ted$

Run the application as

newtricks:bin ted$ java com.ted.hello.Hello
hello java
newtricks:bin ted$

Second Example: Using Log4j

Yes, I wanted to use Apache Log4j. This lets me address the classpath issue ... like finding the log4j.properties file and the log4j jar. Here's how it looks when run from within Eclipse.




I'm using the 1.2.15 version of log4j, which is the stable version that most people use. You download it in a zip that contains the log4j-1.2.15.jar. The later versions are alpha and beta, and you have to get them from apache's svn repository and build it yourself.

Add log4j-1.2.15.jar to the project's Java Build Path. Right click the project, choose Properties, choose Java Build Path, select the Libraries tab, click the Add External JARs button, and browse to the jar's location. I also had to tell the project how to find log4j.properties. I did this by adding a resource filter. Right click the project, choose Properties, choose Resource Filters, and click the Add button. Select the radio buttons Include and Files. Then, type log4j.properties in the Pattern: textbox.

To run this Logging program from the command line, go into the directory /Users/ted/EclipseProjects/work36M4RCPA/com.ted.log/bin. The structure under bin looks like


newtricks:bin ted$ find .
.
./com
./com/ted
./com/ted/log
./com/ted/log/Logging.class
./log4j.properties
newtricks:bin ted$

I have to set my CLASSPATH variable to point to the log4j.jar and my current directory (which is where the log4j.properties is). Mac has the bash shell so here is the command for that (I originally forgot to export).

newtricks:bin ted$ CLASSPATH=/Users/ted/Downloads/Log4j/apache-log4j-1.2.15/log4j-1.2.15.jar:.
newtricks:bin ted$ export CLASSPATH

newtricks:bin ted$ env |grep CLASS
CLASSPATH=/Users/ted/Downloads/Log4j/apache-log4j-1.2.15/log4j-1.2.15.jar:.

newtricks:bin ted$ pwd
/Users/ted/EclipseProjects/work36M4RCPA/com.ted.log/bin

newtricks:bin ted$ java com.ted.log.Logging
0 [main] INFO com.ted.log.Logging - hello log
write hello
1 [main] INFO com.ted.log.Logging - goodbye log

Summary

So running the Java application form the command line is as you would suspect pretty straightforward. You just have to be in the right directory, use the navigation from your package, and in the case of the second example, set the classpath correctly.


12/23/2009 6:10:57 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |  Trackback