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

Sunday, 5 April 2009

Maven Eclipse Tomcat "There are no projects that can be added or removed from the server"

I started to give up my MyEclipse IDE and turn to use a simple Eclipse instead. The main reason is because I found Eclipse actually do what I want it to do, like hot deploy to tomcat. Frankly it's not as good as MyEclipse, but it does the job.

I hit the wall as soon as I start to use it. When I tried to get rid of all eclipse project files (e.g. .project and .classpath) by using mvn eclipse:clean command, I regreted 2 minutes afterward. It was because once the command mvn eclipse:eclipse finished, I switched back to Eclipse, imported the project once again and then added the project to Tomcat, Eclipse prompt me a message "There are no projects that can be added or removed from the server". No matter what I tried to do, like adding "EAR Libraries", "Web App Libraries" and even "Tomcat Server Runtime Library", it does not help a bit. And I could not find a single hint from the net to solve it.

After struggling a whole day, I looked at the eclipse maven plugin. I found the solution.

Since Eclipse is using WTP for web project, and Eclipse needs the WTP configuration in order to recognise it is a web project. If you create a dynamic web project from Eclipse, it works nicely. However, it does not work when you start your project using maven. In order to enable WTP using maven, first we have to add maven-eclipse-plugin and make sure the version of maven-eclipse-plugin is specified (2.6 is the latest version at the moment). Then we have to put a configuration property <wtpversion> and set it to either 1.0, 1.5 or 2.0. Other setting like none or R7 does not work. So here is my setting:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.6</version>
<configuration>
<buildOutputDirectory>src/main/webapp/WEB-INF/classes</buildOutputDirectory>
<downloadJavadocs>true</downloadJavadocs>
<downloadSources>true</downloadSources>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>

There are other settings like <wtpmanifest>, <wtpapplicationxml>, <manifest>. But they are not necessary in order to deploy to Tomcat. This trick also apply on other server like glassfish.

After I put the setting in, it works nice and sweet!

The environment:
Eclipse 3.4
Maven 2.0.8
maven-eclipse-plugin 2.6
Tomcat 5.5, 6.0
Glassfish v3-prelude
MacOSX 10.5

For more information: http://maven.apache.org/plugins/maven-eclipse-plugin/index.html

Friday, 9 January 2009

Eclipse "Dialog refresh" error in Ubuntu 8.x

I have been working on Ubuntu 8.x with Eclipse environment recently. If you are a Eclipse user, you might know that you can search a class file using "Open Type" dialogue by using shortcut "Ctrl+Shift+T" or in the right click menu. However, it started not working since a while ago. It prompt an error dialogue as below:



It has been very frustrating for me that I couldn't use that useful feature. So I started to investigate the problem.

I finally found that the reason that affect Eclipse is the "Assistive Technologies" is turned on. It seems it is unrelated. But it actually affect Eclipse (somehow?!?). So in order to make it works again, the "Assistive Technologies" has to be turned off.

To turn off, choose System->Preferences->Assistive Technologies, uncheck "Enable assistive technologies" as below:



Once finished, restart Gnome, it should work!

Thursday, 25 January 2007

Eclipse out of memory problem

Sometimes eclipse will prompt you an error about out of memory. I am not sure whether it happens in Windows system with nowaday Eclipse 3.2.1. But it does always happen in my Mac machine. So as many blog or information site mention, we can change the eclipse loading parameters. In Mac, you should locate the eclipse.app file inside your eclipse installation folder.

By "right click" to show the menu, choose "Show Package Contents". Then choose Contents -> MacOS. You should see the file eclipse.ini.

Inside elicpse.ini, add/change to the following lines:

-Xms256m
-Xmx512m
-XX:PermSize=128m
-XX:MaxPermSize=256m

Then the out of memory problem should be solved.