Hey everyone,
this is the second part of my tutorial on how to set up a development environment for 3 tier web application development. This post is just a collection of step by step instructions until now. In the next days I will add some more descriptive text, but right now I'm pretty busy at work ;)
Nevertheless, I hope you can draw something useful from these step by step instructions until then.
Assumptions:
this is the second part of my tutorial on how to set up a development environment for 3 tier web application development. This post is just a collection of step by step instructions until now. In the next days I will add some more descriptive text, but right now I'm pretty busy at work ;)
Nevertheless, I hope you can draw something useful from these step by step instructions until then.
Assumptions:
- Installed JDK (1.7.x)
- Windows 7
- You've read the previous post about setting up Eclipse for seamles Angular JS Web Development
Installing and configuring :
- MongoDB 2.6.x
- MonjaDB
- EclipseLink 2.5
Instructions:
How to setup MongoDB
- Go to http://www.mongodb.org/downloads -> Download Windows 64bit (32bit)msi installer
- Run the installer -> Next -> check License Agreement -> Next -> Custom -> Choose your favorite install location -> Next -> Install -> Finish
- Go to your installation directory and create the folder structure "/data/db".
- Go to your installation directory and create a folder named "log".
- In the installation directory create a file named "mongod.cfg" -> open file -> type the mongod.cfg snippet (see below)
- In the installation directory create a file named "mongoStart.bat" -> open file (e.g. with notepad) -> type "C:\path\to\mongo\bin\mongod.exe --config C:\path\to\mongo\mongod.cfg"
- DB Startup: doubleclick mongoStart.bat
- DB Shutdown: in command prompt type CTRL+C -> J -> Enter
- All log files are created in the log directory and can be read with notepad or a text editor
- (optional) If you are running Windows7 AND you are getting Errorcode 33 while running MongoDB -> Installhttp://support.microsoft.com/kb/2731284
How to install MonjaDB Eclipse Plugin
- Install MonjaDB Plugin
- Help -> Eclipse Marketplace -> type "MonjaDB" -> Install -> Confirm -> I accept the terms of the license agreement -> Finish (Installs Monja DB for easier DB development)
- Window -> Perspectives -> Other -> MonjaDB (opens the perspective for Monja DB. One can switch back to the normal perspective by clicking on "JavaEE" in the right top corner of Eclipse)
- To connect to a running MongoDB click on the leftmost icon of the "DB Tree" view -> ConnectionType=Normal / No SSH Configuration / Host=127.0.0.1 / Port=27017 / Database=test -> OK
How to configure a DynamicWebProject for MongoDB + EclipseLink
- Setup MongoDB and EclipseLink
- R-Click project -> Maven -> Add Dependency -> org.eclipse.persistence.jpa / org.eclipse.persistence.nosql / mongo-java-driver / org.apache.tomcat servlet api / javax javaee-api
- R-Click on "src" folder -> New -> Other -> General -> Folder -> Name it "META-INF"
- R-Click on "META-INF" folder -> New -> Other -> File -> Name it "persistence.xml" (This is where you are configuring )
- insert persistence.xml snippet (see below)
Snippets:
mongod.cfg
systemLog:
destination: file
path: 'C:\\path\\to\\mongo\\log\\mongo.log'
storage:
dbPath: 'C:\\path\\to\\mongo\\data'
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd" version="2.0">
<persistence-unit name="<unitname>" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
<property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"/>
<property name="eclipselink.nosql.property.mongo.port" value="<xxxxx>, 27017"/>
<property name="eclipselink.nosql.property.mongo.host" value="<host1>, localhost"/>
<property name="eclipselink.nosql.property.mongo.db" value="<dbname>"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
References
- http://martinfowler.com/articles/nosql-intro-original.pdf (Sehr gute Einführung zu NoSQL... Was ist das und warum?)
- http://docs.jboss.org/hibernate/ogm/4.1/reference/en-US/html/index.html (Dokumentation zu Hibernate OGM, falls man eine Graphdatenbank verwenden will (Neo4J))
- http://www.dotnetrdf.org/blogitem.asp?blogID=35 (MongoDB als RDF Triple Store)
- http://www.jumperz.net/index.php?i=2&a=0&b=9 (MonjaDB - Plugin für Eclipse für MongoDB)
- http://en.kodcu.com/2013/08/nosql-with-jpa/ (Tutorial für EclipseLink und MongoDB mit benötigten Maven Dependencies)
- http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/ (Setup Mongo DB on Windows)
- http://docs.mongodb.org/manual/reference/configuration-options/ (Configuration File Options for Mongo DB - used for windows service creation)
- http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/NoSQL/Persistence_Units (Einstellungen für NoSQL Datenquellen in EclipseLink)
- http://www.eclipse.org/eclipselink/documentation/2.5/solutions/nonrelational_db002.htm (EclipseLink JPA Annotation für NoSQL Datenbanken ... es gibt nicht wirklich viele)
- http://wiki.eclipse.org/EclipseLink/Examples/JPA/NoSQL (Beispielprojekt für die Verwendung von EclipseLink mit MongoDB)
- http://stackoverflow.com/questions/7862700/best-practice-to-get-entitymanagerfactory (Best Practice to setup EntityManager in JEE Context without EJB support)