Skip to content

How to Setup WISE: Local Development Environment using Eclipse

Hiroki Terashima edited this page Jan 21, 2015 · 45 revisions

Table of Contents

Introduction

It is strongly recommended that you've stepped through the "Stable Deployment Model" (https://github.com/WISE-Community/WISE/wiki/How-to-Setup-WISE:-Stable-Deployment-Model) to familiarize yourself with WISE concepts and project layout before setting up your local development environment.

If you'd like to contribute to the open source effort or ask questions to developers about programming or about this page, email us here: http://groups.google.com/group/wise-dev

What You'll Need

JDK 7+

You'll need JDK7 or later. If you don't have it already, go download it.
For Windows users, you'll need to add C:\the path to JDK\bin\javaws to your System PATH. Once you've installed Eclipse in the next section, add it to your "installed JRE's" (in Windows->Preferences->Java->Installed JRE).

MySQL 5.5+

1. Download and install MySQL Community Server from here http://www.mysql.com/downloads/mysql/
2. For Mac, make sure to install the MySQLStartupItem so that MySQL starts up automatically when your computer starts

Eclipse

  1. Get "Eclipse IDE for Java EE Developers" here: http://www.eclipse.org/downloads/. (NOTE: At the time of this writing, Eclipse was at version 4.4, 'Luna'.
  2. You might want to increase max heap size available to Eclipse by editing the eclipse.ini file: http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F
    Here are some recommended minimum settings:
...
-XX:MaxPermSize=512m
...
-Xmx1024m

Tomcat 8

  1. Download Core (.zip or .tar.gz) from here: http://tomcat.apache.org/download-80.cgi
  2. Unzip/Untar it. From here onward, we will refer to the unzipped/untarred directory as $CATALINA_HOME.
  3. Allocate appropriate memory for Tomcat to use. At the bottom of $CATALINA_HOME/bin/setclasspath.sh (or setclasspath.bat if you're on Windows), add the line below:
  # *unix:
  JAVA_OPTS="$JAVA_OPTS -Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m"
  # windows:
  set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m

Set Up WISE Development Environment

Add Tomcat 8 Server to Eclipse

  1. In Eclipse, open the "Servers" tab (should be near the bottom). (If you don't see it, you can open it by going to "Window"->"Show View"->"Other..." then click the down arrow next to the "Server" folder and then select "Servers" and click "OK")
  2. Right click in the blank space within the tab pane and click on "New"->"Server..."
  3. Open the "Apache" folder, and select "Tomcat v8.0 Server". Click Next.
  4. Specify the Tomcat installation directory. This is the root folder of the unzipped/untar'ed tomcat folder from above.
  5. For JRE version, choose Java 7+
  6. Click Finish. Now the Tomcat server should show up in the Servers tab in Eclipse.
  7. Double click on the Tomcat server in the Servers tab. This will bring up the server settings.
  8. For "Server Locations", select "Use Tomcat installation (takes control of Tomcat installation).
  9. For "Deploy path:", you should see "wtpwebapps". Change this to "webapps".
  10. Save the file.

Create folders for Curriculum and Student Uploads in Tomcat/webapps

Create curriculum and studentuploads directory in $CATALINA_HOME/webapps. This is where curriculum files and files uploaded by students will go.

  $ cd $CATALINA_HOME/webapps 
  $ mkdir studentuploads curriculum

Checkout source files

  1. In Eclipse, go to Window->Open Perspective->Other..., and select "Git".
  2. In the "Git Repositories" tab, click on the icon to "Clone a Git Repository". This will popup a window titled "Clone Git Repository".
  3. In the popup, fill in https://[email protected]/WISE-Community/WISE.git for URI. The rest of the form should be filled out automatically. You may want to save the password also.
  4. Click Next until the end, and click Finish. When this is done, you should see WISE repository in the Git Repositories tab.
  5. Right click on WISE, and click on "Import Projects"...Click on "Import Existing Projects", and Click Finish. This will import the project to your Eclipse workspace and start the build of the project.
NOTE: during the build process, Eclipse will download maven dependencies and might hang with the message "Refreshing Maven Model" because of the large amount of dependencies that the WISE project has. If it does, right click on the WISE project and click on "Maven->Update Maven Dependencies".

Create and edit wise.properties

Go to the Java EE perspective by clicking on the "Java EE" button at the top right corner of the window. You should see the WISE project there now.

In the WISE project, copy src/main/resources/wise_sample.properties to src/main/resources/wise.properties and edit wise.properties to match your settings. See comments within file for details.

Note 1: Be sure to change curriculum_base_dir to point to the absolute path to your $CATALINA_HOME/webapps/curriculum directory.
Note 2: If you want to specify your own database username/password/schema name, be sure to specify them in this file and note them for later step.

Add WISE project to server

In eclipse's Server tab, right click on the "Tomcat 8.0" and click on "Add and Remove...". Add the "wise" project. Click Finish.

Create schema and add default users to MySQL

1. Create new user and database in MySQL. For this example, we'll create a new mysql user username/password=wise4user/wise4pass. The database will be named "wise_database". Be sure to use the same username/password/database name as the ones that you specified in your wise.properties file.
NOTE: If you try to run the mysql command and receive this message "-bash: mysql: command not found", you must add the mysql bin folder to your PATH variable. Instructions on how to do so can be found here http://dev.mysql.com/doc/refman/5.0/en/setting-environment-variables.html

   # log in as root
   $ mysql -u root -p     
   # create new user wise4user, password wise4pass
   mysql> create user 'wise4user'@'localhost' identified by 'wise4pass';
   # create new database
   mysql> create database wise_database default character set=utf8;
   # give wise4user access to the new database
   mysql> grant all privileges on wise_database.* to 'wise4user'@'localhost' identified by 'wise4pass'; 
   mysql> flush privileges;  
   mysql> exit;

Initialize the database by reading in the src/main/resources/wise_db_init.sql file

  $ cd path_to_wise_checkout_dir/src/main/resources/
  # replace db name and db_username as needed below to create tables for the wise_database
  # and load it with initial values.
  $ mysql wise_database -u wise4user -p < wise_db_init.sql

Start the server

In Eclipse's Server tab, click on the Green "Play" icon, or right click on the "Tomcat 8.0" and click Start.

Check that it works

Open your browser and go to http://localhost:8080/wise/index.html

Increase heap size for Tomcat

  1. In Eclipse's Run Configurations Window (Run->Run Configurations...), specify a larger heap size limit for Tomcat in the VM arguments section, for example, by adding
-Xms256m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m

Pulling updates from remote repository

To pull in changes from the remote repository into your checkout, follow these steps:

  1. In Eclipse, right click on the project (e.g. WISE)
  2. Select "Team..."->"Pull"

Extra Resources

How to enable memory monitor on Eclipse

  1. Start Eclipse
  2. Click on the Eclipse menu
  3. Click Preferences...
  4. Go to the General tab
  5. Click the checkbox next to “Show heap space”

Changing Logging output Levels in Tomcat

For Tomcat v8.0, change conf/logging.properties. For individual webapp, change its WEB-INF/classes/logging.properties.

see: http://tomcat.apache.org/tomcat-8.0-doc/logging.html

Useful Videos

Become a Javascript Console Power-User http://www.youtube.com/watch?v=4mf_yNLlgic

Troubleshooting:

General Solution (try this first)

Sometimes the maven dependencies do not get picked up by eclipse, for various reasons.

Run these commands:

cd git_checkout_of_wise;
mvn clean compile -Dwtpversion=2.0 eclipse:clean eclipse:eclipse
then refresh the WISE project in Eclipse, clean published files on tomcat (Servers tab->right click on tomcat->Clean...), and try again.

Troubleshooting: java.lang.ClassNotFoundException: net.sf.sail.webapp.spring.impl.CustomContextLoaderListener

When you see an error in the log like this:

SEVERE: Error configuring application listener of class net.sf.sail.webapp.spring.impl.CustomContextLoaderListener
java.lang.ClassNotFoundException: net.sf.sail.webapp.spring.impl.CustomContextLoaderListener
				  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
				  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
				  at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
				  at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
				  at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
				  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
				  at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
				  at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
				  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
				  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
				  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
				  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
				  at java.lang.Thread.run(Thread.java:680)
Nov 9, 2011 6:23:11 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class net.sf.sail.webapp.presentation.web.listeners.PasSessionListener
java.lang.ClassNotFoundException: net.sf.sail.webapp.presentation.web.listeners.PasSessionListener
				  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
				  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
				  at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
				  at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
				  at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
				  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
				  at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
				  at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
				  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
				  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
				  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
				  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
				  at java.lang.Thread.run(Thread.java:680)
Nov 9, 2011 6:23:11 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Nov 9, 2011 6:23:11 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Nov 9, 2011 6:23:11 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/wise] startup failed due to previous errors

This is a problem in the WISE project. Resources (such as .class files and jar files) are not being published correctly to Tomcat. Follow these steps:

1. Stop tomcat.

2. Open your terminal, and in your WISE project checkout directory, run this series of commands:

mvn clean; mvn compile; mvn resources:resources

3. Go back to Eclipse and refresh the wise project.

4. Republish WISE and restart tomcat.

Troubleshooting: wise.properties

If you see an error like this in your log:

Nov 9, 2011 6:26:14 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class net.sf.sail.webapp.spring.impl.CustomContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterChainProxy' defined in class path resource [configurations/applicationContexts/pas/acegiSecurity.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter' defined in class path resource [configurations/applicationContexts/tels/overrides.xml]: Cannot resolve reference to bean 'wiseproperties' while setting bean property 'wiseProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wiseproperties': Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [wise.properties] cannot be opened because it does not exist
							 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
							 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
							 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
							 at java.security.AccessController.doPrivileged(Native Method)
							 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
							 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
							 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
							 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
							 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
							 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
							 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
							 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
							 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
							 at net.sf.sail.webapp.spring.impl.CustomContextLoader.createWebApplicationContext(CustomContextLoader.java:105)
							 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
							 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
							 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
							 at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
							 at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
							 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
							 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
							 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
							 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
							 at java.lang.Thread.run(Thread.java:680)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter' defined in class path resource [configurations/applicationContexts/tels/overrides.xml]: Cannot resolve reference to bean 'wiseproperties' while setting bean property 'wiseProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wiseproperties': Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [wise.properties] cannot be opened because it does not exist
       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
       at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)
       at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:884)
       at org.springframework.security.intercept.web.FIDSToFilterChainMapConverter.<init>(FIDSToFilterChainMapConverter.java:54)
       at org.springframework.security.util.FilterChainProxy.afterPropertiesSet(FilterChainProxy.java:119)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
       ... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wiseproperties': Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [wise.properties] cannot be opened because it does not exist
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
       at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
       ... 40 more
Caused by: java.io.FileNotFoundException: class path resource [wise.properties] cannot be opened because it does not exist
       at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
       at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:182)
       at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
       at org.springframework.beans.factory.config.PropertiesFactoryBean.createInstance(PropertiesFactoryBean.java:98)
       at org.springframework.beans.factory.config.PropertiesFactoryBean.afterPropertiesSet(PropertiesFactoryBean.java:69)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
       ... 50 more
Nov 9, 2011 6:26:14 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Nov 9, 2011 6:26:14 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/wise] startup failed due to previous errors
Nov 9, 2011 6:26:14 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Nov 9, 2011 6:26:14 PM org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
Nov 9, 2011 6:26:14 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/wise] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Nov 9, 2011 6:26:14 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/wise] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
Nov 9, 2011 6:26:14 PM org.apache.coyote.AbstractProtocol start
This means that you do not have the wise.properties file in the WISE project. Go create one and edit it.
Clone this wiki locally