Total Pageviews

Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Friday, November 08, 2013

Hit Ctrl+F9 in Intellij IDEA when JRebel does not work as expected

Often the solution for a problem is so damn easy when you know the cause of the problem ...
Intellij IDEA doesn't have an autocompile feature similar to Eclipse. So if you want your new code to be generated as a class file you have to hit Ctrl+F9 manually.
Well, the same is true when using JRebel. This great piece of software can only detect a change in a class file if the changed class file is generated by a compiler first.
So in case you are using IDEA in conjunction with JRebel and you wonder, why the heck this new code isn't replaced by JRebel on the fly you must hit Ctrl+F9 to generate a new class version and to trigger JRebel afterwards.

One other thing to keep in mind when working with WAR or EAR artifacts in IDEA is to deploy those artifacts as exploded ones!


Wednesday, May 22, 2013

Essential resources when building Android Apps using Maven (and Eclipse)

If you plan to build your Android application on a build server like Jenkins, Hudson, etc ... you should switch from building your project with your IDE (in my case Eclipse) to a build system like Maven or Gradle.

I tried Gradle (using the new Gradle Build export in Eclipse ADT plugin) because the new Android Studio preview release by Google supports Gradle builds, but was totally disappointed by the poor performance of Gradle on my Jenkins CI build server. So I decided to use maven instead and found out about these resources which you have to read and understand:

  1. Maven Android Plugin:
    You need the plugin to build android projects using maven. With Android API 17 the latest stable release 3.5.3 doesn't work. You have to pull the plugin's source from GitHub and build version 3.5.4-SNAPSHOT by yourself.
  2. Android SDK Deployer:
    "Typically artifacts are available in Maven Central, however only the platform versions available in the Android Open Source Project are published to Maven Central. Newer versions of the platform as well as the compatibility package and proprietary extensions like the Google Maps support are not available there and need to be published to your Maven repository, if you want to use them in your Android project.
    The artifacts published to Maven central are available as dependencies under the groupId com.google.android with the artifactId android and android-test.
    The Maven Android SDK Deployer has been created to publish artifacts from the Android SDK into your local repository or repository server when using components that are not available in Central."


    I have taken this from the online book Maven - The Complete Reference by Sonatype.
    With Android API 17 you might run into the same bug like described above. So before building this project you must build version 3.5.4-SNAPSHOT of the Maven Android Plugin
  3. m2e-android:
    In case you use Eclipse, you can use this m2e plugin to add maven support to your Eclipse Android project.

Thursday, September 20, 2012

m2e and generating classes using jaxws-maven-plugin solved

Since m2e 1.0 (Maven integration for Eclipse) developers are complaining about issues with the jaxws-maven-plugin.

See here and here.

The m2e wiki offers documentation describing the issue and proposing solutions. For me, none of those suggestions worked.
The classes were not generated and I had to generate the classes using Maven from the command line and refresh the Eclipse workspace. Since upgrading m2e in my Eclipse 3.7 even that doesn't work anymore.

Googling around I found this project hosted on github solving all problems. After downloading and extracting the projects zip file to my computer I installed the connector plugin in Eclipse using the local directory on my computer as update site.
After restarting Eclipse, updating the Maven project configuration and doing a clean rebuild of the project all sources from the WSDL were generated and the project compiled without errors.

Friday, August 17, 2012

Go and check out the Eclipse Memory Analyzer in case of OutOfMemory exceptions

I have to mention this great tool once again: The Eclipse Memory Analyzer is an awesome tool to analyze heap dumps and to find problems very fast. Especially the "Leak Suspects" feature is very useful for determining memory leaks in your application.

Friday, April 13, 2012

How to edit UTF-8 resource properties in Eclipse

Editing resource properties files in Eclipse is easy - as long as you don't need characters beyond the ISO-8859-1 encoding.
Characters that cannot be directly represented in this encoding can be written using Unicode escapes.
I really don't know all Unicode escapes for german umlauts and I don't want to waste my time with those things when editing properties files.

The first solution I tried was to create my properties file with an UTF-8 encoding using Notepad++. This works pretty well as far as you don't touch this file ever again with Eclipse :-(
Any change of the file using Eclipse converts this file back to ISO-8859-1 encoding and native umlauts like "ä" and "ü" will display strangely in your application.

Note: In Eclipse Preferences every encoding setting (Workspace, CSS, HTML, JSP, XML) was set to UTF-8. In this Stackoverflow question someone tried even the option of specifying -Dfile.encoding=UTF-8 in eclipse.ini. Still not working.

BTW, if you prefer creating and maintaining UTF-8 properties files (maybe you don't work with Eclipse or use another IDE/Editor which is capable of editing UTF-8 property files) you have to check out this stackoverflow posting. Both code examples of reading resource bundles in UTF-8 format work like a charm.

For me, this is not an option because I want to stick to Eclipse and I don't want to edit the properties files with a different tool.

What finally really did the trick was the Resource Bundle Plugin for Eclipse mentioned in this stackoverflow answer. The plugin converts native non ISO-8859-1 characters on the fly to Unicode escapes and frees you from typing the Unicode escapes manually.
All in all a pretty good solution and a very handy plugin.




Sunday, April 08, 2012

Using Eclipse 3.7 and GlassFish 3.1.2 server runtime plugin under Windows to control GlassFish servers

I installed GlassFish 3.1.2 Open Source Edition on my Windows 7 box and wanted to manage the GlassFish instance from Eclipse 3.7 using the GlassFish server runtime plugin.
I installed the plugin via the eclipse marketplace and found out that the version from the marketplace doesn't support GlassFish 3.1.2.
So I googled around and found out about this blog post describing how to install the GlassFish server runtime plugin properly on Eclipse 3.7. There is also a great stackoverflow question describing the problems with multiple "internal GlassFish servers" each time you start Eclipse after you have installed the server runtime plugin for GlassFish 3.1.2.
The later problem only occurs on Windows machines!

Tuesday, March 20, 2012

Solution for "Sniffers with type [connector] and type [ejb] should not claim the archive at the same time"

In case you are using GlassFish it may happen you run into this error

"java.lang.IllegalArgumentException: Sniffers with type [connector] and type [ejb] should not claim the archive at the same time. Please check the packaging of your archive" 

In my case it happens when I deployed a web archive out of Eclipse directly into a running GlassFish instance on my machine using the GlassFish plugin. 
I tried a Google search for this error and found a blog posting by Adam Bien describing this error and a solution. Well, indeed my packaging was wrong. I accidentally bundled the artifact glassfish-embedded-all into my WAR archive and this was causing the trouble.
The solution is very simple: Either change the scope in your pom.xml to "provided" or - in case you don't need the dependency - remove it from the dependency section of your pom.
In my case it turns out that the dependency was not necessary anymore and I deleted it.

Thursday, October 23, 2008

Important Eclipse shortcuts

Recently I switched from being an IntelliJ IDEA user to become an Eclipse user. Although Eclipse refactoring features are not as good as IDEAs I really, really like the Maven integration m2eclipse in Eclipse. Those guys from Sonatype do a fantastic job there.
Together with Nexus - which also is developed by Sonatype - it is a wonderful combination of working development tools.
And no, I do not work for Sonatype ;-)
Now back to what really puzzles me in Eclipse.... the shortcuts and some missing features. One of the really important features I heavily used in IDEA was "Go To Implementation". If you are working on an interface and you would like to know which classes implement this interface you select "Go To Implementation" and IDEA shows you all the implementations of that interface.
Unfortunately I really couldn't find this feature in Eclipse until I stumbled up on this blog entry. This entry almost saved my life as a developer ;-)
Okay, to make it short: The shortcut for "Go To Implementation" in Eclipse is "Ctrl-T" and not F3!
Here is a small summary of very important Eclipse shortcuts:
  • Using Interfaces if you want to see implementation press Ctrl–T and not F3.

  • Ctrl-O in a class definition brings up Quick Outline. Start typing a member name and hit return when it’s unambiguous.

  • Ctrl-F6 can be used to switch to the editors. The order of the editors is quite user friendly as most recently used on the top. Same way Ctrl-F7 to switch to Views and Ctrl-F8 for Perspective.
  • And maybe the most important one: Ctrl-Shift-L shows you a list of all possible shortcuts available in the current context.

Important Eclipse shortcuts

Recently I switched from being an IntelliJ IDEA user to become an Eclipse user. Although Eclipse refactoring features are not as good as IDEAs I really, really like the Maven integration m2eclipse in Eclipse. Those guys from Sonatype do a fantastic job there.
Together with Nexus - which also is developed by Sonatype - it is a wonderful combination of working development tools.
And no, I do not work for Sonatype ;-)
Now back to what really puzzles me in Eclipse.... the shortcuts and some missing features. One of the really important features I heavily used in IDEA was "Go To Implementation". If you are working on an interface and you would like to know which classes implement this interface you select "Go To Implementation" and IDEA shows you all the implementations of that interface.
Unfortunately I really couldn't find this feature in Eclipse until I stumbled up on this blog entry. This entry almost saved my life as a developer ;-)
Okay, to make it short: The shortcut for "Go To Implementation" in Eclipse is "Ctrl-T" and not F3!
Here is a small summary of very important Eclipse shortcuts:
  • Using Interfaces if you want to see implementation press Ctrl–T and not F3.

  • Ctrl-O in a class definition brings up Quick Outline. Start typing a member name and hit return when it’s unambiguous.

  • Ctrl-F6 can be used to switch to the editors. The order of the editors is quite user friendly as most recently used on the top. Same way Ctrl-F7 to switch to Views and Ctrl-F8 for Perspective.
  • And maybe the most important one: Ctrl-Shift-L shows you a list of all possible shortcuts available in the current context.

Thursday, October 16, 2008

Problem solved: Eclipse with Cypal Studio, m2eclipse running GWT Hosted Mode under Linux

I am developing a GWT application on my laptop which runs on Ubuntu 8.
I am using Eclipse 3.4 with the m2eclipse plugin (my project is built using Maven 2) and Cypal Studio as GWT plugin. So far, nothing fancy one should think.
But there are a few things to overcome with:
  1. When you import your Maven project using m2eclipse the web project containing the GWT code will not be configured correctly to work with Cypal Studio. I haven't figured out yet the reason why, but a workaround to this problem is to generate the eclipse project files for the web project by executing "mvn eclipse:eclipse" manually. Now you are able to add a working "Run configuration" for the GWT hosted mode in eclipse.
  2. I started the newly created "Run Configuration" and got an error message stating that a file called "libswt-pi-gtk-3235.so" was missing. So I copied that one from the installed GWT 1.5.2 distribution to my local maven repository into the directory $M2_REPOSITORY/com/google/gwt/gwt-dev/VERSION.
  3. Now, choosing "Run" one would expect to see a starting hosted mode browser (namely Mozilla Firefox). But the only thing I saw was an error message saying "** Unable to find a usable Mozilla install **". Hm, I had installed the latest GWT distribution (1.5.2) and I had configured the path correctly within the Cypal preferences. The dependencies for the web project were all correctly managed by m2eclipse. So what the hell was going wrong?
    Well it turns out to be a problem with the gwt-dev-1.5.2-linux.jar dependency and the way Cypal (or GWT) resolves dependencies.
    The gwt-dev-1.5.2-linux.jar was a dependency of my web project. So Cypal (or GWT) assumes to have a valid GWT distribution and therefore a runnable Mozilla Firefox installed in the directory $M2_REPOSITORY/com/google/gwt/gwt-dev/VERSION. That was obviously not the case.
    So I copied ALL *.so files and the file mozilla-hosted-browser.conf from the GWT distribution directory to the $M2_REPOSITORY/com/google/gwt/gwt-dev/VERSION folder.
  4. The last thing was to edit the mozilla-hosted-browser.conf file and point to the mozilla-firefox installation of the GWT distribution. I did this using absolut path arguments (eg. /usr/local/share/gwt/gwt-1.5.2/mozilla-1.7.12).
  5. Now Cypal starts the GWT Hosted mode with the Mozilla Firefox browser.
I am aware of the fact that this is not the best solution. Poluting the maven directory with shared object files of the GWT distribution is somehow weird. But so far this is the only working scenario I have successfully configured and running with.
If you have a better solution don't hesitate to comment on this entry.

Problem solved: Eclipse with Cypal Studio, m2eclipse running GWT Hosted Mode under Linux

I am developing a GWT application on my laptop which runs on Ubuntu 8.
I am using Eclipse 3.4 with the m2eclipse plugin (my project is built using Maven 2) and Cypal Studio as GWT plugin. So far, nothing fancy one should think.
But there are a few things to overcome with:
  1. When you import your Maven project using m2eclipse the web project containing the GWT code will not be configured correctly to work with Cypal Studio. I haven't figured out yet the reason why, but a workaround to this problem is to generate the eclipse project files for the web project by executing "mvn eclipse:eclipse" manually. Now you are able to add a working "Run configuration" for the GWT hosted mode in eclipse.
  2. I started the newly created "Run Configuration" and got an error message stating that a file called "libswt-pi-gtk-3235.so" was missing. So I copied that one from the installed GWT 1.5.2 distribution to my local maven repository into the directory $M2_REPOSITORY/com/google/gwt/gwt-dev/VERSION.
  3. Now, choosing "Run" one would expect to see a starting hosted mode browser (namely Mozilla Firefox). But the only thing I saw was an error message saying "** Unable to find a usable Mozilla install **". Hm, I had installed the latest GWT distribution (1.5.2) and I had configured the path correctly within the Cypal preferences. The dependencies for the web project were all correctly managed by m2eclipse. So what the hell was going wrong?
    Well it turns out to be a problem with the gwt-dev-1.5.2-linux.jar dependency and the way Cypal (or GWT) resolves dependencies.
    The gwt-dev-1.5.2-linux.jar was a dependency of my web project. So Cypal (or GWT) assumes to have a valid GWT distribution and therefore a runnable Mozilla Firefox installed in the directory $M2_REPOSITORY/com/google/gwt/gwt-dev/VERSION. That was obviously not the case.
    So I copied ALL *.so files and the file mozilla-hosted-browser.conf from the GWT distribution directory to the $M2_REPOSITORY/com/google/gwt/gwt-dev/VERSION folder.
  4. The last thing was to edit the mozilla-hosted-browser.conf file and point to the mozilla-firefox installation of the GWT distribution. I did this using absolut path arguments (eg. /usr/local/share/gwt/gwt-1.5.2/mozilla-1.7.12).
  5. Now Cypal starts the GWT Hosted mode with the Mozilla Firefox browser.
I am aware of the fact that this is not the best solution. Poluting the maven directory with shared object files of the GWT distribution is somehow weird. But so far this is the only working scenario I have successfully configured and running with.
If you have a better solution don't hesitate to comment on this entry.