Mar 212013
 

Днес, 21.03.2013 г, ще се проведе семинар на тема “Eclipse plug-in development” пред българската Java потребителска група (BG-JUG). Семинарът ще бъде в зала 299 на ФМИ с начало19:00 ч.

eclipse-plugin-development-poster

Повече за семинара

На семинара ще бъдат разгледани следните въпроси:

  1. Кратка история и развитие на платформата Eclipse
  2. OSGi и реализация в Eclipse
  3. Архитектура и основни компоненти на платформата Eclipse
  4. Структура на Eclipse
  5. Разработване на плъгини за Eclipse

По време на семинара ще се наблегне и на новостите в e4.

Лектори

Лектори на семинара ще бъдат Мартин Тошев и Дмитрий Александров.

Това е обявата на събитието и на сайта на BG-JUG.

Share Button
Sep 102011
 

With no doubt for the Java web-applications development the Eclipse and Tomcat are default choices. I usually prefer to use preinstalled Tomcat, configuring Eclipse to use the already installed instance. In this case though, by default, Tomcat logging does not work. This in most of the cases is quite anoying, as we don’t want to return in the dark ages of System.out.println() (which adds another argument to Misho’s request for improving the integration between Eclipse and Tomcat).

Enabling the Logging under Tomcat, managed by Eclipse

In order to enable the logging under Tomcat, which is managed by Eclipse, are required the following steps:

  • Prepare the configuration file log4j.properties, storing it in the appropriate directory [LOG4J_PROPS_LOCATION]
  • In Eclipse, select the server in the “Servers Window” (see the picture bellow)
  • Open (F3) > Open launch configuration > Arguments > VM arguments:
  • As last argument should be added the following instructions:
-Djava.util.logging.config.file="[LOG4J_PROPS_LOCATION]/logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

Tomcat’s Configuration Files Location

When I’m configuring Tomcat, I prefer the configuration files to be located in the server’s directory. When the server is launched by Eclipse though, it’s not that easy.

When a server is “created” under Eclipse, using independent Tomcat installation, the physical location of its configuration files is the following directory “[ECLIPSE_WORKSPACE]/.metadata/.plugins/org.eclipse.wst.server.core". In this directory, under separate subdirectories are kept the configuration files for each of the servers “created” by Eclipse. Subdirectories are named with tmp[i], where [i] is the consecutive number of the server, depending of the order in which the servers are created. For example for the following servers:

there are the following configuration directories:

drwxrwxrwx   1 user     group           0 Aug 22 08:54 tmp0
drwxrwxrwx   1 user     group           0 Aug 22 08:55 tmp1
drwxrwxrwx   1 user     group           0 Aug 29 17:23 tmp2

Each of the folders has structure similar to the default Tomcat installation folder:

d:eclipse-workspace.metadata.pluginsorg.eclipse.wst.server.coretmp2>ls -al
total 0
drwxrwxrwx   1 user     group           0 Aug 29 17:23 .
drwxrwxrwx   1 user     group           0 Aug 29 17:23 ..
drwxrwxrwx   1 user     group           0 Aug 29 17:23 conf
drwxrwxrwx   1 user     group           0 Aug 29 17:23 logs
drwxrwxrwx   1 user     group           0 Sep  9 19:37 temp
drwxrwxrwx   1 user     group           0 Aug 29 17:23 webapps
drwxrwxrwx   1 user     group           0 Aug 29 17:23 work
drwxrwxrwx   1 user     group           0 Sep  9 13:18 wtpwebapps

Again, similarly to the standard Tomcat installation, we place the Log4J configuration file log4j.properties in the folder conf, perform the steps from the previous section and voilà, the logging is enabled.

Share Button
Aug 202011
 

Sooner or later, after a couple of reinstallations of the operating system, each of us reaches the conclusion that the user applications should be installed to a partition/hard-disk, different from the system one. On the other hand, the default configuration of most of the applications by default rely on the fact that the installation of that program is done on the system partition (at least under Windows). That’s the case of Eclipse and Maven as well.

Changing Maven Local Repository Location

Even Maven to be installed on a partition different from the system one, by default the Mavel local repository is expected to be on the system partition:

  • for Windows (Vista/7) it is at  C:\Users\<WINDOWS_USERNAME>\.m2\repository
  • for  Linux – at ~/.m2/repositoy

If we want to change the local repository location, to be on a partition other than the system one for example, the only what is needed is to be changed the Maven configuration file – settings.xml, located in the Maven installation directory. For the purpose, uncomment the tagg localRepository and add the path to the new directory, which will be used for new local repository:

<settings>
...
<localrepository>/path/to/local/repo/</localrepository>
...
</settings>

In my case, the change looks in the following way:

<settings>
...
<localrepository>D:/config/maven/.m2/repository</localrepository>
...
</settings>

Eclipse and the New Maven Location

By default Eclipse uses its own Maven instance. For local Maven repository, it uses the following folders:

  • for Windows (Vista/7) at  C:\Users\<WINDOWS_USERNAME>\.m2\repository
  • for Linux at ~/.m2/repository

If we install Maven in a location different from the one by default and we configure the local repository to be on a directory different by the one indicated by default, what we could expect is the installation of the generated by Maven archives (jar, war, etc.) in the local repository, to be placed on the newly defined place.

If we don’t reflect these changes in Eclipse, it will use its own Maven installation and its own configuration for the local Maven repository. Respectively, if Eclipse does not find the folder.m2/repository in the current user’s directory (user.home) usually on the system partition/hard-disk, Eclipse creates that folder and install the generated archives for the built Maven projects in it. Thus, the building and installtion (in the terms of Maven) of the same projects from the command line and Eclipse will cause the creation of archives on two different locations.

Moreover, not always the Maven version, which Eclipse uses (M3 in the case of Eclipse 3.6.1 for example) coincide with the one, which is used for the current project (M2 for the project, which I am working on at the moment). As we know, because of the improvements of Maven in version M3 with regards to the optimisation of its performance, the Maven projects, built with this version are incompatible with M2 and vice versa.

So, we can isolate the following problems when we change the local Maven repository and installation, but not reflecting this change in Eclipse:

  • Again we save user generated files on the system partition/disk (the ones generated by Eclipse).
  • We don’t have synchronization when we build and install the Maven projects through the command line and the IDE (the projects built and installed via the command line does not bring changes in Eclipse).
  • It’s possible the archives generated via command line and Eclipse to be incompatible.

In order to avoid all these drawbacks, is required to apply two changes to the Eclipse default configuration. Open the menu Window > Preferences and change:

  • Indicating in Eclipse to use the new Maven installation: Maven > Installations > Add... and chose the directory, %MAVEN_HOME%, which points to the new Maven installation and which will be used through the command line.
  • Configure Eclipse to use the new Maven repository: Maven > User Settings > User Settings > Browse and chose the location indicated in settings.xml configuration file of Maven, which describes where is located to the new local repository (explained in the prvious section).

In that way we unify the Maven versions and local repository used via the command line and Eclipse.

Share Button