Eclipse

Install Eclipse & Plugins

A preinstalled eclipse can be found at our [file server] Projects/Magnolia-Development/Eclipse

Install Eclipse (3.5)

Download the Java EE edition which includes WTP (web tool project).

Subversive (Subversion Plugin)

Install the plugin

  1. Help / Install New Software ..
  2. select: Galileo - http://download.eclipse.org/releases/galileo
  3. select: Collaboration/Subversive SVN Team Provider

Note: to get the latest stable version you will better use the project's url. I had to do that because eclipse started to block on startups otherwise.

Connectors
You also have to install a connector. Subversive will prompt you on the first usage.

  1. open "SVN Repository" perspective (Window -> Open perspective)
  2. select SVNKit 1.3
  3. proceed installation

Maven integration (M2Eclipse)

Plugin

  1. Help -> Install New Software ..
  2. Add... (to add a new site)
  3. http://m2eclipse.sonatype.org/sites/m2e

WTP Integration

  1. Help -> Install New Software ..
  2. Add... (to add a new site)
  3. http://m2eclipse.sonatype.org/sites/m2e-extras
  4. select: Maven Integration for WTP

Subversive Integration

  1. Help -> Install New Software ..
  2. Add... (to add a new site)
  3. http://www.polarion.org/projects/subversive/download/integrations/update-site/
  4. select: Subversive Integration for M2Eclipse

FreeMarker IDE (optional)

Register the following URLs in Help / Software Updates

  1. http://download.jboss.org/jbosstools/updates/JBossTools-3.0.3.GA
  2. select: FreeMarker IDE

Any Edit (optional)

Used for tab to space transformations and other cleanup on save

  1. http://andrei.gmxhome.de/eclipse
  2. select: AnyEditTools

JIRA integration (optional)

  • Check Mylyn Extras and select JIRA integration

Maven Repository

Be aware of the fact that the magnolia artifacts are hosted in our own repository. You have the following options:
  • register the repository in your maven settings.xml file
  • register the repository in your project pom

The repositories are:

settings.xml
The file is found in your home directory under ~/.m2/settings.xml

Example:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <!-- needed for http access -->
    <server>
      <id>magnolia.enterprise</id>
      <username>****</username>
      <password>****</password>
    </server>
  </servers>

  <profiles>
    <profile>
      <id>my-default-profile</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>

      <repositories>
        <repository>
          <id>magnolia</id>
          <url>http://repo.magnolia-cms.com/m2</url>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>magnolia.enterprise</id>
          <url>http://repo.magnolia-cms.com/enterprise</url>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>

    </profile>
  </profiles>
</settings>

Add SVN Repository

You will have to register our SVN repository in case you want to checkout magnolia modules/projects

  1. open SVN Repository Exploring Perspective
  2. add repository location
  3. http://svn.magnolia-cms.com/svn

Create/Checkout a Project

New Checkout

  1. open "SVN Repository" perspective (Window -> Open perspective)
  2. select module/project to check out
  3. click "Check out" in the context menu

Importing a already checked out project from file system

Sometimes it is more convenient to checkout a project manually and then use the eclipse import function. This is especially helpful if the module to be imported has submodules.

  1. File -> Import
  2. in the import dialog select 'Maven Projects'

Setup the Server (Tomcat)

Create a Server

If not yet done create a server.

Deploy the Webapp project

Open Server Edit Pane

Doubleclick on the server item 

Disable publishing

Make sure that the option Serve modules without publishing is selected. This ensures that the classes are taken from the target directories. 

Freemarker specific settings

tld's

FreeMarker won't search the classpath for finding the tlds but uses only WEB-INF/lib and the entries defined in web.xml directly. There exist mainly the following two workarounds:

A) register the tlds in web.xml

edit web.xml and add the following lines:

<jsp-config>
   <taglib>
      <taglib-uri>cmsfn-taglib</taglib-uri>
      <taglib-location>cmsfn-taglib.tld</taglib-location>
    </taglib>
</jsp-config>

And copy the files to webapp/WEB-INF

B) put minimal jars into WEB-INF/lib

1. in the webapp folder execute:

  mvn war:inplace

2. delete all jars except the taglib jars in src/main/webapp/WEB-INF/lib

3. minimize the taglib jar

 zip -d magnolia-taglib-cms-4.1.1-SNAPSHOT.jar /info/*
 zip -d magnolia-taglib-utility-4.1.1-SNAPSHOT.jar /info/*

Auto completion

Freemarker templates do not provide automatically auto completion of the provided objects.

The provided objects like ctx, stk or mgnl must be declared to the IDE, that they can be auto completed.

There for a configuration file must be provided in each project in your workspace. The file is named '.freemarker-ide.xml'. I have attached it to this page without the dot at the beginning, or I can't upload it on the Mac otherwise (hidden).

The important part of this configuration file is the declaration of the objects the auto completion should know. I think these four declarations I use make sense:

<value key="mgnl" object-class="info.magnolia.module.templating.MagnoliaTemplatingUtilities"/>
<value key="ctx" object-class="info.magnolia.context.MgnlContext"/>
<value key="stk" object-class="info.magnolia.module.templatingkit.util.STKUtil"/>
<value key="state" object-class="info.magnolia.cms.core.AggregationState"/>

Configure Code Style

If you are an internal developer or a contributor please follow the instructions found here: Code style and configure AnyEdit as follows:

Tips and Tricks

Get the sources or a linked jar / module

  • select the jar (in the Maven Dependencies library)
  • right click -> Maven -> Download Sources

Dependencies

The dependencies are resolved inside the workspace. This is quite helpful. But this will only work if the version you reference in the project and the version of the module you checked out has the same version. In some cases you will have to adapt the pom files locally (to point to the current snapshot for instance).

Known Problems

Wrong maven version is used for dependency checks

If the project can't build because of the following message (printed in Maven Console)

[WARN] Rule 0: org.apache.maven.plugin.enforcer.RequireMavenVersion failed with message: Detected Maven Version: 2.1-SNAPSHOT is not in the allowed range [2.0.9,2.0.9].

The expected stacktrace on startup is:

SEVERE: Exception sending context initialized event to listener instance of class info.magnolia.cms.servlets.MgnlServletContextListener
java.lang.NullPointerException
	at info.magnolia.cms.beans.config.PropertiesInitializer.loadAllModuleProperties(PropertiesInitializer.java:92)
	at info.magnolia.cms.beans.config.PropertiesInitializer.loadAllProperties(PropertiesInitializer.java:79)
	at info.magnolia.cms.servlets.MgnlServletContextListener.contextInitialized(MgnlServletContextListener.java:176)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)

You can either add the following to the pluginManagement section in your main project pom to disable the enforcer plugin or select the eclipse profile:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <configuration>
    <skip>true</skip>
  </configuration>
</plugin>

Then clean all projects

To ensure that everything is fine you have to check that magnolia-core/target/classes/mgnl-bean.properties exists.

Freemarker can't find tags (tlds)

See Freemarkerspecificsettings

Project contains duplicate entry

Sometimes the same jar is references twice (by maven and EAR dependencies). This sometimes happens if you open eclipse freshly. To make the project compile again you must remove the ear dependency:

  • right click project -> Java EE -> Update EAR libraries

Class Cast Exception: info.magnolia.cms.filters.MgnlMainFilter

Symptom:

SEVERE: Exception starting filter magnoliaFilterChain
java.lang.ClassCastException: info.magnolia.cms.filters.MgnlMainFilter
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:255)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

Solution: exclude the servlet api jar. Verify that you don't have the servlet api jar in your maven dependencies.

Example:

<dependency>
	<groupId>info.magnolia</groupId>
	<artifactId>magnolia-empty-webapp</artifactId>
	<version>4.0.1</version>
	<type>pom</type>
	<exclusions>
		<exclusion>
		        <groupId>javax.servlet</groupId>
		        <artifactId>servlet-api</artifactId>
		</exclusion>
	</exclusions>
</dependency>

Webapp project doesn't work

  1. make sure that you have only one webapp project open
  2. add the pom dependency (not only the war dependency) otherwise the dependencies defined in the referenced war file won't be seen
  3. use mvn war:inplace to overlay the webapp project (make sure that the WEB-INF/web.xml exists
  4. ensure that you delete WEB-INF/lib after a war:inplace

Trouble shooting step by step

  1. check if there are any build issues denoted in the problem view
  2. check if there are any problems denoted in the pom.xml (missing parents, ..)
  3. check if the project builds in the terminal (by using mvn only)
    • are the parent poms available?
  4. check the maven log in eclipse (select the maven console in the console view)
    • are the logs fine?
    • verify that there is no version conflict thrown by the enforcer plugin
      • if so configure the project to use the eclipse profile in the project settings (maven tab)
  5. clean the project
    • this ensures that maven is used to build the resources
    • verify that the resources have been built (module descriptor in target/classes/META-INF/magnolia
  6. update project configuration
    • right click project -> maven -> update project configuration
    • check the maven console (some errors are not reported to the GUI)

Labels

eclipse eclipse Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jun 09

    Devanshu Chakraborty says:

    I'm getting following error  when I install the project. org.apache.maven....

    I'm getting following error  when I install the project.

    org.apache.maven.lifecycle.LifecycleExecutionException: XDoclet plugin failed: Failed to set property restrictedpath to file://C:\Documents and Settings\PlayBoy\.m2\repository: null

    My Env is Windows XP SP3, myEclipse 8.5 and java 1.5.22

    Can somebody please tell me if I'm wrong anywhere. What shall I do to over come it.

    If you need I can provide full stack trace of the error.

    1. Jun 09

      Grégory Joseph says:

      open the pom.xml file, find the <restrictedpath> property, and try to set ...

      open the pom.xml file, find the <restrictedpath> property, and try to set that to file://C:/Documents+and+Settings/PlayBoy/.m2/repository instead of file://\$\{settings.localRepository}

      If that doesn't help, and if you can, try to change the location of your local Maven repository to a path that does not contain spaces: http://maven.apache.org/settings.html#Simple_Values

      1. Jun 10

        Devanshu Chakraborty says:

        Dear Gregory, Thanks a lot for that quick reply. I'm new to maven technology. I...

        Dear Gregory,

        Thanks a lot for that quick reply. I'm new to maven technology. I was just trying to follow the steps as mentioned by you. But it didn't work out. I did just everything. I formatted my c drive infact and did a new installation in it today. Installed all required software from scratch. and build the projects again. But it failed again on same error.

        Further I've now also moved the repository to a different location: "H:/ProgramFiles/Maven/.m2/repository" with no spaces in it. But just nothing happens. Then I used eclipse 3.5.2 instead of myEclipse 8.5 then also same problem.

        This error is occuring in "magnolia-taglib-utility" and "magnolia-taglib-cms". During install, it gave error for some missing files "magnolia-taglib-cms.jar" in project "magnolia-taglib-utility" and one more project and I installed it to the project with command "mvn install:install-file -DgroupId=info.magnolia -DartifactId=magnolia-taglib-cms -Dversion=5.0-SNAPSHOT -Dclassifier=sources -Dpackaging=java-source -Dfile="/filepath". This problem went away then the same problem of "XDoclet plugin failed: Failed to set property restrictedpath" started on next install.

         Following is the stacktrace of the error:

        Please excuse me if I should not post so long posts here with error stack traces. But m stuck in this for so long that I 'm getting exhausted now...and need some definite help...

        [DEBUG]  The following artifacts were filtered out for plugin: org.codehaus.xdoclet:maven2-xdoclet2-plugin:2.0.7 because they're already in the core of Maven:
        org.apache.maven:maven-plugin-api:jar:2.0:runtime
        org.apache.maven:maven-project:jar:2.0:runtime
        These will use the artifact files already in the core ClassRealm instead, to allow them to be included in PluginDescriptor.getArtifacts().
        [DEBUG] Configuring mojo 'org.codehaus.xdoclet:maven2-xdoclet2-plugin:2.0.7:xdoclet' -->
        [DEBUG]   (s) classname = org.xdoclet.plugin.web.TaglibPlugin
        [DEBUG]   (s) params =

        Unknown macro: {description=CMS Utility Tag Library, destdir=H}

        [DEBUG]   (s) components = [org.codehaus.xdoclet.Component@4f0853]
        [DEBUG]   (s) includes = */.java
        [DEBUG]   (s) configs = [Config{, includes=*/.java, excludes=, resourcesIncludes=*/, resourcesExcludes=*/.java, encoding='Cp1252', addToSources='true', addToResources='true', params={}}]
        [DEBUG]   (f) localRepository = Repository[local|file://H:/ProgramFiles/Maven/.m2/repository]
        [DEBUG]   (s) project = MavenProject: info.magnolia:magnolia-taglib-utility:5.0-SNAPSHOT @ H:\Projects\Magnolia\workspace\magnolia\magnolia-taglib-utility\pom.xml
        [DEBUG]   (f) resourcesOutputDirectory = H:\Projects\Magnolia\workspace\magnolia\magnolia-taglib-utility\target\classes/generated-resources/xdoclet
        [DEBUG]   (f) sourceArtifacts = info.magnolia:magnolia-taglib-*
        [DEBUG]   (f) sourcesOuputDirectory = H:\Projects\Magnolia\workspace\magnolia\magnolia-taglib-utility\target\classes/generated-resources/xdoclet
        [DEBUG] -- end configuration --
        [INFO] [2-xdoclet2:xdoclet
        Unknown macro: {execution}
        ]
        [DEBUG] magnolia-taglib-cms: using locally installed snapshot
        [DEBUG] Config{, includes=*/.java, excludes=, resourcesIncludes=*/, resourcesExcludes=*/.java, encoding='Cp1252', addToSources='true', addToResources='true', params={}}
        [INFO] ------------------------------------------------------------------------
        [ERROR] BUILD ERROR
        [INFO] ------------------------------------------------------------------------
        [INFO] XDoclet plugin failed: Failed to set property restrictedpath to file://H:/ProgramFiles/Maven/.m2/repository: null
        The filename, directory name, or volume label syntax is incorrect
        [INFO] ------------------------------------------------------------------------
        [DEBUG] Trace
        org.apache.maven.lifecycle.LifecycleExecutionException: XDoclet plugin failed: Failed to set property restrictedpath to file://H:/ProgramFiles/Maven/.m2/repository: null
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
            at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:592)
            at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
        Caused by: org.apache.maven.plugin.MojoExecutionException: XDoclet plugin failed: Failed to set property restrictedpath to file://H:/ProgramFiles/Maven/.m2/repository: null
            at org.codehaus.xdoclet.XDocletMojo.execute(XDocletMojo.java:260)
            at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
            ... 17 more
        Caused by: org.picocontainer.PicoInitializationException: Failed to set property restrictedpath to file://H:/ProgramFiles/Maven/.m2/repository: null
            at org.picocontainer.defaults.BeanPropertyComponentAdapter.getComponentInstance(BeanPropertyComponentAdapter.java:79)
            at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstancesOfType(DefaultPicoContainer.java:274)
            at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstancesOfTypeWithContainerAdaptersLast(DefaultPicoContainer.java:377)
            at org.picocontainer.defaults.DefaultPicoContainer.start(DefaultPicoContainer.java:347)
            at org.nanocontainer.integrationkit.LifecycleContainerBuilder.autoStart(LifecycleContainerBuilder.java:52)
            at org.nanocontainer.integrationkit.LifecycleContainerBuilder.buildContainer(LifecycleContainerBuilder.java:45)
            at org.codehaus.xdoclet.XDocletMojo.execute(XDocletMojo.java:251)
            ... 19 more
        Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:592)
            at org.picocontainer.defaults.BeanPropertyComponentAdapter.getComponentInstance(BeanPropertyComponentAdapter.java:77)
            ... 25 more
        Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
            at java.io.WinNTFileSystem.canonicalize0(Native Method)
            at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:395)
            at java.io.File.getCanonicalPath(File.java:531)
            at org.generama.defaults.QDoxPlugin.setRestrictedpath(QDoxPlugin.java:43)
            ... 30 more
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 5 seconds
        [INFO] Finished at: Thu Jun 10 21:31:18 IST 2010
        [INFO] Final Memory: 20M/40M
        [INFO] ------------------------------------------------------------------------

        Please let me know if I'm wrong somewhere.

        Thanks

        Devanshu