Difference between revisions of "Create a new Mavenized gCube GWT Portlet Guide"

From Gcube Wiki
Jump to: navigation, search
(Project creation)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
<!-- CATEGORIES -->
 +
[[Category:Developer's Guide]]
 +
<!-- END CATEGORIES -->
 
== Preface ==
 
== Preface ==
 
This guide is mostly about '''how to make''' the '''Google Eclipse Plugin''', '''Eclipse''' and '''Maven''' work '''together'''. Which could not be trivial.
 
This guide is mostly about '''how to make''' the '''Google Eclipse Plugin''', '''Eclipse''' and '''Maven''' work '''together'''. Which could not be trivial.
Line 52: Line 55:
 
* Open your entrypoint class and make it compile by :
 
* Open your entrypoint class and make it compile by :
 
**  deleting this line: private final Messages messages = GWT.create(Messages.class);
 
**  deleting this line: private final Messages messages = GWT.create(Messages.class);
** inserting explicit stings in the sendButton constructor and setText methos as shown below:
+
** inserting explicit stings in the sendButton constructor and setText method as shown below:
  
 
[[File:Emoty.png]]
 
[[File:Emoty.png]]
Line 86: Line 89:
 
the project can be imported in your eclipse by using svn with this URL:  
 
the project can be imported in your eclipse by using svn with this URL:  
 
* https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/my-vres
 
* https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/my-vres
 +
 +
== Make your GWT Maven Application a gCube Portlet ==
 +
 +
All the steps suggested in the Developing gCube Portlet guide (Parent of this Guide) applies, except that with maven the xml files and jsp are no longer in the /war folder they need to be put under this folder: '/src/main/webapp' (see picture below).
 +
 +
[[File:Explode.png]]
 +
 +
Within eclipse you can use the 'Deployed Resources' folder directly, highlighted in the example below:
 +
 +
[[File:Deployed.png]]
 +
 +
== Troubleshooting when deploying on Liferay Portal ==
 +
 +
I decided to add this section as the exception thrown from Liferay in the following  could make you 'go nuts' if you use a GWT Mavenized Portlet. So, you're happy your web application works fine on eclipse, you add the portlet descriptor files and decide to deploy the war on Liferay.. but it doesn't work because Liferay throws the following exception:
 +
 +
''' ERROR [MinifierFilter:136] java.lang.NullPointerException '''
 +
 +
Here's the possible causes identified so far that might cause it:
 +
 +
* Open your .gwt.xml, the rename-to attribute value of <module> for some unknown reason '''must be lowercase''', example <module rename-to='mywidgetname'>
 +
* If the above didn't work also having the same gwt-module name and the portlet class name would make the Minifier crashing.
 +
* If none of the above worked also having the same gwt-module name and portlet id name (in WEB-INF xml files) would make the Minifier crashing.

Latest revision as of 12:39, 29 January 2016

Preface

This guide is mostly about how to make the Google Eclipse Plugin, Eclipse and Maven work together. Which could not be trivial.

This guide was tested with Eclipse 3.7 Indigo EE (3.7+ is supported), on MacOS 10.6.8 with Java 6.

The Google official Notes on working with GWT, Maven, and Google Plugin for Eclipse are available at this link. Use it for Troubleshooting and to get an overview of what you're going to do.

What you need

Maven Plugin for Eclipse (m2e)

Install the following plugins on your Eclipse:

I am using the latest stable releases from eclipse.org although the current WTP integration is still in incubation… but works.

Talking numbers, these are the version numbers I used:

  • m2e – Maven Integration for Eclipse 1.2.0.20120903-1050
  • m2e-wtp – Maven Integration for WTP (Incubation) 0.16.0.20120914-0945
  • m2e connector for mavenarchiver pom properties 0.15.0.201207090125-signed-201209140800

Google Plugin for Eclipse (GPE)

Google Plugin for Eclipse (GPE) makes it easy to import Maven projects using GWT and App Engine. To get started, first install GPE and the additional Eclipse plugins required for your version of Eclipse (remember that only Indigo+ is supported)


Project creation

Create a new maven project, when prompted for selecting the archetype type 'org.codehaus.mojo' and select the gwt-maven-plugin as shown in the picture below (select 2.4.0 is you use GWT 2.4) :

Archetype1.png

Click next and enter the maven coordinates for your artifact, see below for an example:

Archetype.png

Hit finish and the gwt-maven-plugin will create a sample gwt project for you. If you use Indigo at a certain point it will fail creating the goal i18n and the goal generateAsync, this should not happen with Eclipse Juno. Don't worry, you don't need Juno just do the following:

  • open your pom.xml, locate the GWT Maven Plugin <plugin> node and delete the goals generating errors (generateAsync, i18n) see picture below:

Goals.png

  • Open the GreetingService interface and generate its related ServiceAsync:

Async.png

  • Open your entrypoint class and make it compile by :
    • deleting this line: private final Messages messages = GWT.create(Messages.class);
    • inserting explicit stings in the sendButton constructor and setText method as shown below:

Emoty.png

Project first run

Now if you try to Run your project as a web application you will notice that also the web.xml is not complete, add what is suggested by the console n web.xml and everything should work fine, click the button and make sure the servlet communication works:

Fine.png

Maven Goals (Create your Web Archive)

  • goal gwt:compile
    • GWT Compile mode In order to gwt:compile your portlet create a Maven Build Configuration and enter gwt:compile on the goal text box.
  • goal package
    • package will generate the war for you in the target folder.
  • goal deploy
    • to use the deploy goal please refere to the gCube Maven Guide as you would need to create a distro folder with specific files in it.

Working example

An actual working example, that could be helpful for you, is the following project:

   <groupId>org.gcube.portlet.user</groupId>
  <artifactId>my-vres</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <type>war</type>

the project can be imported in your eclipse by using svn with this URL:

Make your GWT Maven Application a gCube Portlet

All the steps suggested in the Developing gCube Portlet guide (Parent of this Guide) applies, except that with maven the xml files and jsp are no longer in the /war folder they need to be put under this folder: '/src/main/webapp' (see picture below).

Explode.png

Within eclipse you can use the 'Deployed Resources' folder directly, highlighted in the example below:

Deployed.png

Troubleshooting when deploying on Liferay Portal

I decided to add this section as the exception thrown from Liferay in the following could make you 'go nuts' if you use a GWT Mavenized Portlet. So, you're happy your web application works fine on eclipse, you add the portlet descriptor files and decide to deploy the war on Liferay.. but it doesn't work because Liferay throws the following exception:

ERROR [MinifierFilter:136] java.lang.NullPointerException

Here's the possible causes identified so far that might cause it:

  • Open your .gwt.xml, the rename-to attribute value of <module> for some unknown reason must be lowercase, example <module rename-to='mywidgetname'>
  • If the above didn't work also having the same gwt-module name and the portlet class name would make the Minifier crashing.
  • If none of the above worked also having the same gwt-module name and portlet id name (in WEB-INF xml files) would make the Minifier crashing.