Mittwoch Jan 13, 2010

Maven & SVN Plugins for Eclipse Galileo

Today I installed the Maven M2 and Subversive Plugins in my Eclipse Galileo Installation.

This is a little bit tricky because the M2 Plugin needs some additional Plugins if the Plugin should work together with the Subversion Plugin Subversive.

These are the steps I go through the Eclipse Update Manager to get all things work:

First I added the Suversive SVN Team Provider provided from the Galileo Download Site. This Site is available in the Eclipse "Install new Software" Dialog. Select the Option:

"Collaboration->Suversive SVN Team Provider"

 

After restarting Eclipse the SVN Plugin will ask for a Subversive Connector. This is a new cool feature so you did not add an Updite URL for these plugins manually. I selected only the option SVN Kit 1.3.0:

 

...the wizard will select two additional plugins to be installed next...

 

In the next step I added an additional Plugin which is needed to get a better Maven/SVN Integration.

Therefore I added in the Eclipse Install Dialog the following new Update site:

 http://download.eclipse.org/technology/subversive/0.7/update-site/

From This site I selected only(!) the Plugin 

"Subversive SVN Team Provider (Incubation)"

 

 After Restarting Eclipse I add now the "SVN Maven Support" provided by the following Update Site:

http://www.polarion.org/projects/subversive/download/integrations/update-site/

This is an additional Plugin needed to get better SVN Support. I select the "Subversive Integration for the M2Eclipse Project" Plugin:


Now finally its time to add the Maven Integration Plugin itself form the Update Site:

 http://m2eclipse.sonatype.org/update/

You should not(!) select the Maven SCM Integration if you followed my recommanded installation steps.

So I select the MavenEmbeder, Pom Editor and Maven Central Repository:


 

 After restarting Eclipse Galileo once more you can now Checkout a Maven Project from any SVN Repository with the option "Check out as maven Project..."  and use the M2 Integration Plugin Features like the POM Editor.

 

 

If anybody knows an easier way to get Maven and SVN Integration for Eclipse Galileo installed please let me know...

Samstag Mai 23, 2009

Eclipse JSF/Faclet Support in a Maven Web Project

In the following section I will describe how to configure a Maven Web Module in Eclipse Ganymede to get full support of Content assist, Hover Help and code completion for JSF and Facelets.

These features are supported by the Eclipse Web Tool Platform (WTP). So it seams not to be so difficult to configure a existing web project. But as Maven have some different in building a classpath and updating project configuration in Eclipse you need to be careful to reconfigure a Maven project. I spent a lot of time to find out why it sometimes did not work. So I hope my following walk-through will be helpful to you.

The Situation:

I have an existing Maven Web Project which I checked out from a code repository into my eclipse workspace. Therefor I used the Maven Plugin and the Maven SVN Integration Plugin.

The Maven Project I am working with is a JEE Web module with JSF and Faclets support and also uses the JBoss RichFaces JSF components.So the goal is to get content assist when editing a .xhtml faclets file in my web project.

The Facelets Plugin

To get things run I need first to install the faclets plugin for eclipse.  The reason for adding this plugin is that a faclets application typical uses .xhtml pages to represent the jsf resources. The Eclipse WTP did not support .xhml files per deault so the faclets plugin will add the JSF features to also .xhtml files. Additional the plugin includes some wizzards and a new WTP Facete.

You can download the plugin from here. Extract the file and copy the jars into your /plugin folder of your Eclipse Ganymede. Next restart Eclipse!

Adding a JSF Implementation and Server Runntime

Next step is to add a JSF Implementation into you Eclipse Workspace. You can use any Implementation. I take the JSF Implementation form my Glassfish server.  There is a Blog where  Cay Horstmann explains the details:
http://weblogs.java.net/blog/cayhorstmann/archive/2007/07/jsf_support_in.html

So open the Eclipse preferences dialog and go to Web->JavaServer Faces->Libraries.

Create a new JSF library and name the library "GlassfishJSF-impl". Add only the jsf-impl.jar file. This file is located in the /glassfish/lib folder from your glassfish installation.



Important: Make sure that the option "is JSF Implementation" is checked!

Next add the Server Runtime. Select the Server Node and add your JEE Server (in my case glassfish)

 

Now Restart you Eclipse!

Add the Server and JSF Libraries to the Java Build Path

Next check the "Java Build Path" settings of your Web Project. You need now to add two libraries to your project.

The Server Runtime Library of Glassfish and the JSF Implementation which added before to the workspace environment.

Click "Add Library..." and select "Server Runtime"

 

Choose the Glassfish Server from the Server Runtime list. Click finish.

Next I add the JSF Library created before. So click again "Add library..." and add a JSF Library and select you GlassfishJSF-Impl created before:

 

Finally your project library settings should look like this

Add the JSF and Faclets Facets

Next you need to add the Project Facets for JSF 1.2 support and Facelet 1.0. A Facet is a WTP specific feature which adds additional tools and features to a web project. The Facelet 1.0 Facete is an additional feature added by the Facelet plugin I added before.

To add a new Facete you open the preference dialog for your web project and select the "Project facets" node.

If this Node is not present in you project preferences Eclipse has not recognized your Maven web project as a Eclipse Web Project. So you need first to add the WTP Nature to your project manually.

  1. Switch in the "Navigator" View
  2. open the file ".project"
  3. add the nature
      <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
  4. save the .project file

Now you can add the different facets in the following order:

  1. Select Java 5.0
  2. Select Dynamic Web Module 2.5
    after that you can see the link "Further configuration available" - open the dialog




    As I am working in a maven project I change the Content and Java Source Directory into
    /src/main/webapp
    /src/main/java
    which are the default maven source folders
    Also I unchecked the "Generate deployment descriptor" as my maven project still have the necessary descriptors.




  3. Next Select "JavaServerFaces 1.2".
    Again there is "Further configuration required"
    You can select the option "Server Supplied JSF Implementation"



    Choose the "Next" Button to switch through the different config pages.

  4. Finally add the "Facelet 1.0 " support.
    Again there is "Further configuration available"



    I disabled all options as my maven project is well configured

  5. Finally restart eclipse

Now you should have the content assist and hover help in your xhtml files.
Eclipse is parsing all necessary libraries so also my RichFaces tags are now known by Eclipse!

The first time you get the content assist from Eclipse it will take some time as Eclipse needs to analyze the tag libraries. 


If it did not work...

In some cases this did not work. Then the main reason seams to be that the Eclipse java build classpath is not well configured. Check the Java Build Path settings. Remove and add some Libraries - this will help Eclipse to update the Workspace settings and restart Eclipse. Also wait some time after restart until Eclipse have finished all inizalizing.

Samstag Mrz 28, 2009

Eclipse: maven install from runAs menu fails

A few days ago I updated my eclipse Ganymede via the update manager. After that I was unable to build my Maven projects with from the "runAs -> maven install" context menu:

I got the following error when I try to build my EAR module

 [INFO] org.imixs.callcenter.ear .............................. FAILED [0.634s]
[INFO] ------------------------------------------------------------------------
[ERROR]

The following mojo encountered an error while executing:
Group-Id: org.apache.maven.plugins
Artifact-Id: maven-ear-plugin
Version: 2.3.1
Mojo: ear
brought in via: packaging: ear

While building project:
Group-Id: org.imixs.examples
Artifact-Id: org.imixs.callcenter.ear
Version: 0.0.2
From file: /home/rsoika/eclipse-ganymede/sywapp/org.imixs.callcenter/org.imixs.callcenter.ear/pom.xml
Reason: Cannot copy a directory: /home/rsoika/eclipse-ganymede/sywapp/org.imixs.callcenter/org.imixs.callcenter.web/target/classes; Did you package/install active project artifact:
artifact = org.imixs.examples:org.imixs.callcenter.web:war:0.0.2:compile;
project: MavenProject: org.imixs.examples:org.imixs.callcenter.web:0.0.2 @ /home/rsoika/eclipse-ganymede/sywapp/org.imixs.callcenter/org.imixs.callcenter.web/pom.xml?



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run with the -e flag
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILED

 

I can build all modules separately and it seams to be an known issue form the  m2eclipse plugin (http://jira.codehaus.org/browse/MNGECLIPSE-1173)

The problem  seams to be the "Resolve Workspace artifacts" option. My workarround was to use my own "run as" configuration.

 

When I use these settings (see "Resolve Workspace artifacts" is disabled!) everything works fine for me.

But I did not find out how to change the "Resolve Workspace artifacts" option in general for eclipse.


Donnerstag Sep 18, 2008

RichFaces & Maven - easy setup!

The last days I read a lot about RichFaces and saw this cool live demo. RichFaces sparks my interest. As the JSF Framework RichFaces from JBoss supports much more components as other frameworks and also really cool Ajax features, I started to build my first jee web module using RichFaces.
First I read this quick guide which shows how to build a JEE Webmodul using RichFaces in general. But as I planed to integrate my first example into an existing JEE project build on maven I search a lot to find out how to setup a Maven Web module with RichFaces Support.

Here is my personal quick guide to setup a maven web app with RichFaces:

1.) Add the JBoss Maven repository to your Maven Installation:

first you need to add the following repository description into your setup.xml file located in your Maven root directory:

 	<!-- JBoss RichFaces Repository -->
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>repository.jboss.com</id>
<name>Jboss Repository for Maven</name>
<url>
http://repository.jboss.com/maven2/
</url>
<layout>default</layout>
</repository>
</repositories>

So later maven will be able to download the necessary components. (I don't know why this framework is not included into the standard maven repository)

2.) Add the RichFaces Dependencies

the next (and final) step is to add the RichFaces Dependencies into your Maven Web Module (I assume that you know how to build a web module with maven).
To find out the right dependencies takes me the most time as I did not found an example on the JBoss RichFaces Homepage. But finally I found these dependency configuration which works fine:

   <dependencies>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>3.2.1.GA</version>
</dependency>
</dependencies>

So add these three dependencies into your pom.xml.

That's really all!

I completed my first integration test with the Simple Ajax Echo example at it works perfect !

Now I begin to love RichFaces :-)

Samstag Aug 23, 2008

Turbo Eclipse

These days I started a new Eclipse Project: Turbo Eclipse

The idea behind turbo eclipse is to provide a small and easy to use eclipse distribution for maven developers based on Eclipse Ganymede. 

The goals of Turbo Eclipse are

  • minimum amount of Plugins
  • Full Maven support using Maven IDE Plugin
  • Full Subversion support using subclipse
  • Facelets Support using the Eclipse Facelets Project

The Project is hosted at dev.java.net:

https://turbo-eclipse.dev.java.net/

Feedback and Tips are welcome. If you would like to join the project contact me or request a project role on dev.java.net


Samstag Aug 16, 2008

Eclipse Ganymede - Maven2 - Facelets

I invested a lot of hours to find out how to configure Eclipse Ganymede in a way where it works well in a JEE Facelets Project. Currently development of Facelets Web apps is not supported by the Eclipse IDE and WebToolPlattform (WTP). I am not sure but maybe the Eclipse WTP Team did not like Facelets developers. It is not easy to get things like code completion for xhtml files to run out of the box.
So this is my story how I configure a Eclipse Workspace to work with a JEE facelets  web project.

I am using Eclipse Ganymede, Glassfish V2 and Maven2. These are the steps I go through:

1.) Install the Eclipse Facelets Plugin

The Eclipse Facelets Plugin is the key to develop xhtml files in eclipse. But it is brand new and - in the moment - not available trough  the eclipse update manager.
The Plugin allows you to work in xhtml files like in JSP files. You got code completion and also some nice template wizzards. This plugin is very useful if you want to develop a JEE Web Facelets Application.
If you are interessted in the project - this is the project homepage:
http://wiki.eclipse.org/JSF_Facelets_Tools_Project
And in this webinar you can see the cool features of the plugin:
http://live.eclipse.org/node/225

But in the moment it is very difficult to get the plugin. If you are not familiar with plugin development, checkout plugin source code from eclipse, compile and export plugins it become very hard.... :-(

So I download the sources and compiled the plugin code with the eclipse IDE. If you don't want to go this way you can download the plugin from here.
Extract the file and copy the jars into your /plugin folder of your Eclipse Ganymede. Next restart Eclipse!

2.) Setup Workplace for JSF Support

Now you need to do some configurations to support Eclipse with the necessary Server Environment and JSF Libraries. This is not a project specific configuration but a workspace specific! So if you start in a new Workspace you need to repeat these steps.

First add your Glassfish Server to the Server list. Switch to the Server View and add a Glassfish V2 Server. You need this server environment (target runtime) later in your web project.

Next stp is to add the JSF Implementation form Glassfish to your Web JSF Configuration. This is explained also by Cay Horstmann's Blog:
http://weblogs.java.net/blog/cayhorstmann/archive/2007/07/jsf_support_in.html

So open the Eclipse preferences dialog and go to Web->JavaServer Faces->Libraries.

Create a new JSF library and name the library "GlassfishJSF-impl". Add only the jsf-impl.jar file. This file is located in the /glassfish/lib folder from your glassfish installation.




Now Restart you Eclipse! (I beleve this is a important step).

3.) Setup your Web Project

Now this is the most critical part. And I am not sure if every step is really necessary but it seems to work for me.

So open your Web Project (or create a new one) and open the project properties. Go to "Project Facets".

Here you can now add the "JSF 1.2" and also the new "Facelets 1.0" support:

 

You will see a link "Further configuration required". Click on it and configure the dialog like this using the server configuration from Glassfish:




You will not see this configuration page again after you close the property dialog! So be carefull. The only way is to disable the Faclets and JSP Support - apply the settings - and re enable the settings again! (It seems to me that this is a plan from the WTP Developers to craze JEE Developers)

Next check the "Java Build Path" settings of your Web Project. You need to add two libraries to your project.

The Server Runtime Library of Glassfish (automatical created during adding the Glassish Server to the Server list before) 

Click "Add Library..." and select "Server Runtime"

 

Choose the Glassfish Server from the Server Runime list. Click finish.

Next you need to add the JSF Library created before. So click again "Add library..." and add a JSF Library and select you GlassfishJSF-Impl created before:

 

Finaly your project library settings should look like this (Maven Dependencies is only visible if you work in Maven2 project as I do)


 Next check the Order of the Libs! This seems also to be very important:


Make sure that the Maven Entry is at the end of the list!

Now restart your Eclipse! If you are lucky you can now edit xhtml files with code completion support :-)




If it did not work...

But! When you work with Maven2 Projects and your xhtml files did not support code completion you need to check some things. I did not know while the project settings will not work after first configuration. I followed these additional steps:

1.) update you maven configuration of your web project
     ->maven->update project configuration
2.) check the order of the libraries
3.) check if you have added the a target runtime for glassfish and also the glassfish JSF-Impl. You can select the glassfish Server as your project target.
3.) Restart Eclipse and wait as long as all background jobs are finished before you test you xhtml editor.

So I hope this will helpe someones - every comments are wellcome!

Mittwoch Jul 09, 2008

Eclipse Ganymede - Maven

Today I installed new Eclipse version Ganymede. The Update Center have changed and I need Subversion Team support and also maven2 for my projects.

So these are the steps I go through plugin installation:

Subversion Team Support

Eclipse supports now subversion integration ”subversive”. You can install this additional plugins using the update manager

 

Switch to the tab "Available Software" and expand the "Ganymede" section. There you will find the "SVN Team Provider Plugin" under "Collaboration Tools"

I need further (maybe as I am using Linux ?) to follow these instructions:

http://blog.punchbarrel.com/2008/06/30/using-the-new-subversion-integration-in-eclipse-ganymede/

So I installed the SVNKit 1.1.7 - this works perfect. I don't think that this step is necessary under Windows.

Maven2 Plugin

The next part for me was to add Maven2 Plugin support into my Eclipse.

General Informations about this Plugin can be read here:
http://m2eclipse.codehaus.org/

As the Maven Plugin Repository is not included in the Update Manager per default you need to add the Update Site manually.

So in the Update Manager switch to the tab "Available Software" and add the following Update Site to the Update Manager using the function "Add site"

http://m2eclipse.sonatype.org/update/

 

You can now select the following Features from this Update Site:

  • Maven Integration
    • Maven Integration for Eclipse
    • Maven POM XML Edtior
    • Maven: The Definitive Guid book
  • Maven Project Configurators
    • Maven Integration for WTP
  • Optional Components 
    • Nexus index for Centra Maven repository

After that you need a additional plugin to checkout Maven Projects from a Subversion Repository (using the  context menu "check out as maven project"). These Subversive Integration is not included in the sonatype upates site. But it can be taken from the following update URL:

http://www.polarion.org/projects/subversive/download/integrations/update-site/

Again you need to add the Update Site manually.

 

After that you can add the Plugin

  • "Subversive Integration for the M2Eclipse Project"

to your eclipse IDE.

After all my new Eclipse Ganymede seems to be very cool.  Maven and Subversion works as perfect.

It's a pity that Eclipse Ganymede dos not integrate the Maven Plugin more easily....


Samstag Jun 28, 2008

Maven: How to exclude EJB jars from a War Module

It happened to me that when I build my multi-module maven project and deploy it to my glassfish server I receifed server errors like this:

[#|2008-06-28T23:26:31.815+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|
_ThreadID=14;
_ThreadName=Timer-7;_RequestID=dffabadc-2951-492d-9b98-88ada568fd33;
|Annotations processing failed for
/opt/glassfish/domains/domain1/applications/j2ee-apps/org.imixs.shareyourwork.ear-0.7.3/
org.imixs.shareyourwork.ejb-0.7.3_jar|#]
[#|2008-06-28T23:26:32.218+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|
_ThreadID=14;_ThreadName=Timer-7;_RequestID=dffabadc-2951-492d-9b98-88ada568fd33;
|Class org.imixs.workflow.jee.ejb.WorkflowServiceManagerImplementation is annotated with
@WebService and @Stateless but is packaged in a WAR. If it is supposed to be an EJB endpoint,
it should be packaged in a JAR; Deployment will continue assuming this class to be just a POJO
used by other classes in the WAR being deployed symbol: javax.jws.WebService

 This happens because the EJB modules which are included using a dependency tag in my war module are also added into the WEB-INF/lib directory.

And this is not allowed or necessary because the EJB jars are available in the EAR / EJB modul.

So the solution to avoid this error message was to add the folling tag to the dependency tag of the war module:

<scope>provided</scope>    

This means that the JARs of this dependency are not included into the /lib folder of the war module. So the deployment process will proceed without error messages.

Sonntag Jun 22, 2008

Eclipse - JavaServer Faces - Configuration

In some cases it can happen that your Eclipse Web Project did not support code completion in a JSP or JSF page.
This happens to me in a JSF Project with MyFaces and Facelets Support. I build up the project using Maven so the project build was sucessfull and the project works well on my server but typing code with Eclipse JSP Editor war extreamly annoying as Eclipse did not support my with code completion.

The reason was that the project facets for my project where broken and also MyFaces Support was not added to Eclipse correctly. Indeed it is necessary to configure the myfaces support in Eclipse manually and I am not sure if I was not intelligent enough or the Eclipse WTP is not so easy to use as I should be.

So follow these steps if you run into a similar problem  :

  1. create a MyFaces Folder localy on your computer (e.g: /home/user/myfaces)
  2. move the MyFaces libs and tomahawk libs into a subfolder lib/ (e.g:/home/user/myfaces/lib)
    • commons-beanutils-x.x.x.jar
    • commons-codec-x.x.x.jar
    • commons-collections-x.x.jar
    • commons-digester-x.x.jar
    • commons-discovery-x.x.jar
    • commons-logging-x.x.x.jar
    • myfaces-api-x.x.x.jar
    • myfaces-impl-x.x.x.jar
    • tomahawk-x.x.x.jar
  3. move the tld Files for myfaces and tomahawk in a /tlds subfolder (e.g./home/user/myfaces/tlds)
    • myfaces-impl-x.x.x-tlddoc.jar
    • tomahawk-x.x.x-tlddoc.jar
  4. Edit the JavaServer Faces LIbraries
    1. open Window->Preferences
    2. go to Web and XML > JavaServer Faces Tools > Libraries
    3. add a new library "MyFaces" with all the jar files moved before to your myfaces/lib folder
    4. add a new library "MyFacesTLD" with all the jar files moved before to myfaces/tlds folder
  5. Next edit the Project Facets of your Web Project (Select your project and open >Project Properties  > click modify )
    1. if there is allready available a JavaServerFaces Support - remove JavaServerFaces 1.2
    2. add JavaServerFaces 1.2. support and press "next" button
    3. select option "Sever supplied JSF Implemenation" and add the component libraries configured before in the right part of the selection. This is the importend part! And I did not found this dialog after clicking on "finish"

 After this stepps code competion works for my JSF Project. Notice that I work with maven and Maven integration in Eclipse is currently not the best. But maybe this instruction will help you...

Samstag Jun 21, 2008

Maven EAR Artefacts - web modul missing

I build a new Maven multi modul project with EJB, WEB and EAR Artifacts.

I was sure that I have added all necessary dependencies to my pom.xml files. But each time I try to install my EAR Artefact I receifed an error like this one:

....
Error message: Missing:
----------
1) org.imixs.myproject.web:jar:1.0.0
----------
1 required artifact is missing.
.....

The reason was that maven searches per default for a .jar artifact even if you try to add a WEB Modul! 

So the solution was to change the dependency in my pom.xml of my ear artifact. I just added the <type> tag to the dependency with the value "war".

Also make sure that you add the type "ejb" to each ejb artifact you add to your ear artifact!

Now maven build succeeds :-)