Giter VIP home page Giter VIP logo

mmuminiproject's Introduction

MMU Mini Project Website

Setup

You'll need Netbeans, Apache Tomcat and MySQL. Tomcat and MySQL is bundled with XAMPP. When connecting Tomcat with Netbeans, just point Netbeans to the tomcat folder in your XAMPP installation. Be sure to turn off Tomcat (you can do this from XAMPP control panel) when doing this as Netbeans writes a username and password to tomcat/conf/tomcat-users.xml.

Prior to launching the website in your localhost, you need to start MySQL server from XAMPP control panel. Netbeans will launch Tomcat for you. A database called mmuminiproject will be created (if it doesn't exist) and be populated with tables and initial data before running.

Important Dev Notes

  • ERD.mwb is a MySQL Workbench file (https://www.mysql.com/products/workbench/). We use this to generate our migrations via "Database > Synchronize Model...". Workbench generates SQL with database name inside, so to keep things simple make sure all databases have the same name (in OpenShift, it means project name = database name).
  • Project relies on Struts2 (https://struts.apache.org/) and Struts2 Convention Plugin to utilize MVC. Controller (called actions in Struts2) and model files are located in source packages under the app package. View files (*.jsp) are under Web Pages, in WEB-INF/content.
  • Migrations (a series of SQL files) are handled by FlywayDb (http://flywaydb.org/), and are located under source package src/main/resources/db/migrations. In Netbeans, you find this under "Other Sources".
  • Before adding a SQL migration from Netbeans, shut down Tomcat server first, otherwise the blank SQL file will be automatically executed.
  • Try not to edit applied migration files, but if you have to, all databases that is created and modified by these migrations (yours, those that you are collaborating with, the database in OpenShift) must be wiped out before launching your application again, or your website and those collaborating with you might not even start from localhost (fail to launch at context error) and at openshift (it will just fail to deploy).
  • ORM (Object Relational Mapping) is handled by JPA (Java Persistence API), implemented by Hibernate.
  • Each time you add/remove an entity, you need to add a class node in persistence.xml under the OpenShift persistence unit, like so: <class>app.model.Toothbrush</class>, should you forget to do this, you will be receive an error that only appears during deployment: java.lang.IllegalArgumentException: Unknown entity. Inconvenient, but I wasn't able to get hibernate.archive.autodetection to work in OpenShift despite my best efforts ):
  • Dependencies are handled by Maven; to add new libraries, look for them in http://mvnrepository.com/ and add the dependency into pom.xml.
  • If persistence.xml, web.xml, or the MigrateDb.java, is not set properly, OpenShift doesn't give much indication aside a Failed deployments: ./ROOT.war error.
  • File uploads only work locally as of this writing.
  • You cannot have a REST controller and a package name of the same name in the same parent package.

Tips

  • To make the project structure look tidy, view your java project as a reduced tree: right click a blank area near your project, select View Java Package As..., and select Reduced Tree.

Note-So-Important Dev Notes

  • Automatic creation of the database, as well as auto-migrating is handled by a ServletContextListener core.listener.MigrateDb.
  • (Only for localhost) If you decide to make changes to database name, user or password, you need to edit core.listener.MigrateDb and persistence.xml (located in src/main/resources/persistence.xml under "Other Sources").

Deploy to OpenShift

  1. Add a new application. Choose JBoss Application Server 7. Set a URL that you want, and leave the source code blank so that OpenShift creates a git repo for you.
  2. Add MySQL catridge.
  3. (optional) Add PhpMyAdmin catridge. This will allow you to see and modify the contents of the database.
  4. git clone the source code via the SSH URL they gave.
  5. Copy paste this maven project (source project) to that directory (deployment project), excluding the target and .git folder.
  6. Now your project is ready to be pushed to the cloud!

mmuminiproject's People

Contributors

arshadalwi avatar bruceoutdoors avatar redzrex avatar

Watchers

 avatar  avatar  avatar

Forkers

arshadalwi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.