Setting Up SOS as Maven project in eclipse

First Step: Download, install and configure the required software

Required software and plugins

This tutorial is based upon the following software:

Eclipse IDE for Java EE developers 3.6 Helios: You can download the Eclipse IDE at http://www.eclipse.org/downloads/

m2eclipse 1.x: Eclipse -> Help -> Eclipse Marketplace..., Type 'm2eclipse' in the 'Find' text field, install 'Maven Integration for Eclipse'.

Eclipse SVN plugin: A how to install, configure and get the SOS sources can be found on the SvnSos page.

The following software is required to deploy the SOS and installation and configuration instructions cabe fount in the SosTutorial.

Apache Maven 2.2.1/3.0.x: Download Apache Maven from http://maven.apache.org/download.html and follow the instuructions given there.

Java SDK 6.0: You can download the Java SDK at http://java.sun.com/javase/downloads/index.jsp.

Apache Tomcat 6.0: The Apache Tomcat could be downloaded at http://tomcat.apache.org/download-60.cgi. Some hints on Apache Tomcat installation using Windows 7 (64 Bit) can be found at the side ApacheTomcatWindows

PostgreSQL DBMS 8.4: The PostgreSQL database management system could be downloaded at http://www.postgresql.org/download.

Postgis 1.4 or 1.5: The PostGIS spatial extension could be found at http://www.postgis.org/download.

Configure Tomcat

Create a Tomcat user with the following rights and have it's credentials ready to enter into a configuration later. If you do not give the "-script" roles you might get an error message like "The username you provided is not allowed to use the text-based Tomcat Manager."

<user name="[user]" password="[password]" roles="admin-gui,manager-guiadmin-script,manager-script" />,

On Windows you need rights to edit the Tomcat-x/conf/tomcat-users.xml file, so either open the file as administrator or grant regular users rights on the file (Right click > Properties > Security).

Configure Eclipse

Set the used JDK for Eclipse (important to build SOS with maven from Eclipse)
  • Open the eclipse.ini file in the Eclipse folder
  • Add -vm PATH_TO_JDK_BIN. It can be that Eclipse has problems with spaces in the path. Then use the old DOS path design: C:/PROGRA~1/JAVA/JDK16~1.0/BIN = C:/Program Files/Java/jdk1.6.0/bin

Configure m2eclipse

  • Open the Eclipse preferences: Window -> Preferences
  • Go to Maven - Installations tab, if you do not want to use the default Maven installation, press the Add button. Browse to your Apache Maven 2.2.1 installation folder and press OK.
  • Go to Maven - User Settings. Press the browse button for User settings an go to the [user home]\.m2\settings.xml (see the SOS tutorial: https://wiki.52north.org/bin/view/SensorWeb/SosTutorial#Configure_Maven)

Check out the SOS sources from SVN

Check out the SOS sources from SVN as a Project in the General tab. A detailed description can be found on the SvnSos side.

Set up the SOS project

  • right click in the Package Explorer window or click File
  • Import -> Maven -> Existing Maven Projects
  • Select the SOS sub modules you want to import -> Finish
  • m2eclipse imports the selected modules as separate Maven/Java projects.

Set up the database

See the SosTutorial steps Installing PostgreSQL and PostGIS and Creating a PostGIS Database and SOS table structure.

The .sql file you have to execute can be found in the folder <workspace location>/52n-sos/db

Second Step: Build and deploy the SOS from Eclipse

Configure the build.properties

Create a new deployable war file

  • Create a new Maven configuration: Run > Run Configurations... > Maven Build
  • Base directory: SOS project (use Browse Workspace)
  • Goals: install
  • If you run Maven from command line, this effectively runs for example mvn install
  • A deployable .war file is created in the directory /52n-sos/52n-sos-service/target/

Create server settings and profile for remote deplyoment

  • Go to the [USER_HOME]\.m2 directory and open the settings.xml file. If the file does not exists, you can copy the from your Apache Maven installation or use this template.
    • Add a new server setting to <servers> like this (you can define several server), add the user credentials for the user above:
      • <server>
        <id>loho</id>
        <configuration>
        <cargo.remote.username>[user]</cargo.remote.username>
        <cargo.remote.password>[password]</cargo.remote.password>
        </configuration>
        </server>
    • Add a new profile to <profiles> like this (you can define several profiles):
      • <profile>
        <id>ploho</id>
        <properties>
        <conf.sos.build.properties>${project.parent.basedir}/local.build.properties</conf.sos.build.properties>
        <conf.sos.server.settings>loho</conf.sos.server.settings>
        <conf.sos.remote.server>localhost</conf.sos.remote.server>
        <conf.sos.remote.port>8080</conf.sos.remote.port>
        <conf.sos.deploy.containerId>tomcat7x</conf.sos.deploy.containerId>
        </properties>
        </profile>
        • <conf.sos.build.properties> is optional, if you created a sutomized build.properties at another location

Deploy the SOS

  • Create a new Maven configuration: Run > Run Configurations... > Maven Build
  • Base directory: SOS project (use Browse Workspace)
  • Goals: install
  • Add profile with-deploy and the defined profile from settings.xml to Profiles, e.g. ploho at the same time like this: ploho,with-deploy
  • Click Apply and close or directly Run.
If Apache Tomcat and the PostgeSQL database are started, the SOS is build an will be deployed to the Apache Tomcat directly.

(Alternatively, use the command line described in the SosTutorial: https://wiki.52north.org/bin/view/SensorWeb/SosTutorial#Deploy_the_web_application)

Third Step: Remote debugging with Eclipse and Tomcat

Configure Tomcat settings

Add the following properties to the Tomcat Java Options and restart the Tomcat:
  • -Xdebug
  • -Xrunjdwp:transport=dt_socket,address=11111,server=y,suspend=n

Create a new Remote Debug Configuration

  • Open Debug Configurations and create a new Remote Java Application
  • Host: localhost (or any other Tomcat server URL/IP)
  • Port: 11111

Troubleshooting

  • Not hot code replacement because of error "hot code replace failed - scheme change not implemented" -- DanielNuest - 2012-07-06
    • This error can happen when Tomcat runs in a different JDK than Eclipse/Maven, i.e. the compiler is a different Java version than the one running in the Tomcat. This could for example happen if you select "use platform binaries/optimized version" when installing the Tomcat.
    • Sources one and two
    • Solution: Use the same JDK to run Eclipse (eclipse.ini), in JAVA_HOME (for Maven) and for Tomcat.
      • In Windows: Set JAVA_HOME, open the Tomcat configuration > Java > check "use default".
-- CarstenHollmann - 2011-04-01

This topic: SensorWeb > SensorObservationService > SosEclipseJavaProject
Topic revision: 20 Aug 2012, EikeJuerrens
Legal Notice | Privacy Statement


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback