Install Eclipse & Plugins
A preinstalled eclipse can be found at our files server Software:/MacOSX/Software/Eclipse
Install Eclipse (3.3.2)
Download the Java EE edition. It must include WTP.
Subversive (Subversion Plugin)
Register the following URLs in Help / Software Updates
- http://download.eclipse.org/technology/subversive/0.7/update-site/ (note: this is already part of the Eclipse 3.4 download, so no need to add if you have 3.4)
- http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/
Maven integration
Register the following URLs in Help / Software Updates
JIRA integration
- Check Mylyn Extras and select JIRA integration
FreeMarker IDE
Register the following URLs in Help / Software Updates
- http://download.jboss.org/jbosstools/updates/stable/
- select FreeMarker IDE
Setup Project(s)
Single Module
Checkout
- open "SVN Repository" perspective (Window -> Open perspective)
- select module to check out
- click "Check out" in the context menu
Enable Maven Dependency Management
Configure Project to use the eclipse
maven profile
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.
- File -> Import
- in the import dialog select 'Maven Projects'
- configure the wizard to use the profile
eclipse
(advanced settings)
Using SCM checkout wizard
Create New Project
Select New / Other (not Project)
Select Maven checkout from SCM
Provide subversion URL
1. http://svn.magnolia-cms.com/svn/community/magnolia/trunk/
2. Enable eclipse profile in the advanced settings
Check if you got all the projects (the sub modules)
Setup the Container (Tomcat for instance)
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
For using the tag libs with freemarker you will need to edit web.xml and add the following lines:
<jsp-config> <taglib> <taglib-uri>cms-taglib</taglib-uri> <taglib-location>cms-taglib.tld</taglib-location> </taglib> <taglib> <taglib-uri>cms-util-taglib</taglib-uri> <taglib-location>cms-util-taglib.tld</taglib-location> </taglib> </jsp-config>
And copy the files to webapp/WEB-INF
Configure Code Style
If you are an internal developer or a contributor please follow the instructions found here: Code style
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 if 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 if magnolia-core/target/classes/mgnl-bean.properties exist.
Freemarker can't find tags (tlds)
Freemarker searches explicitly only in WEB-INF/lib for the tld files to load. But normally if you develop by using eclipse the jars won't lay there. A valid workaround is to copy the needed tld files to the WEB-INF folder and to edit the web.xml to make the tlds available.
<jsp-config> <taglib> <taglib-uri>cms-taglib</taglib-uri> <taglib-location>cms-taglib.tld</taglib-location> </taglib> <taglib> <taglib-uri>cms-util-taglib</taglib-uri> <taglib-location>cms-util-taglib.tld</taglib-location> </taglib> </jsp-config>
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
- make sure that you have only one webapp project open
- add the pom dependency (not only the war dependency) otherwise the dependencies defined in the referenced war file won't be seen
- use war:inplace to overlay the webapp project
- ensure that you delete WEB-INF/lib afterwards
Trouble shooting step by step
- check if there are any build issues denoted in the problem view
- check if there are any problems denoted in the pom.xml (missing parents, ..)
- check if the project builds in the terminal (by using mvn only)
- are the parent poms available?
- 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)
- clean the project
- this ensures that maven is used to build the resources
- verify that the resources have been built (module descriptor in
taget/classes/META-INF/magnolia
- update project configuration
- right click project -> maven -> update project configuration
- check the maven console (some errors are not reported to the GUI)