Giter Site home page Giter Site logo

gamification-1's Introduction

Gamification API Project

This project have been realized for the OSF module, which take part of Master of Science in Engineering at HES-SO.

The goal is to implement a Gamification API with Java EE and the architectural style REST. Additionaly, we added remote access through JNDI.

Repository of our professor.

Team

  1. Alexandre Perusset [email protected]
  2. Gaël Jobin [email protected]
  3. Thomas Moegli [email protected]

Changelog

Since the first presentation, we've done some modifications and improvement (due to our Technical POC project and professor comments), listed below :

  • Integration of application notion and security checks for the whole entities (only with application id, an application has no secret for the moment).
  • Add remote access to the services.
  • Split into two main projects : a jar packaged library and the web application.
  • The APIary document has been updated, completed and is now more comprehensive.

Codes and projects structure

To get a working copy of the current version of our code, simply clone it with Git:

git clone https://github.com/aperusset/Gamification.git

There is severals Netbeans projects, so you need to install Netbeans for Java EE and Java EE SDK with Glassfish 4.0.

Once you have cloned the source code, you can import these two projects into NetBeans :

  • GamificationLib
  • GamificationAPI

You have to add a maven dependency of GamificationLib into GamificationAPI with compile scope. Normally, the dependency is present but can be problematic for a new import in Netbeans.

The GamificationLib project, which is JAR packaged, is here for remote access to our API via JNDI. You can use the JAR into some Java projects to call remotly Gamification API functionnalities.

We have done another project which use the Gamification library from a Play! application : Call EJB from Play! Technical Proof of Concept. Do not hesitate to consult this project to get an overview of how remote calls are made from another Java environment with JNDI.

The two others NetBeans projects, GamificationClientEE and GamificationClientJS, are here to show how to connect remotly to our Gamification API from a Java Entreprise and Java Standard environnement.

Run Instructions

First, clean and build GamificationLib.

You have to create a database for the API. To create a database from Netbeans, use Services tab > Databases > Right Click on Java DB > Create Database. Enter these informations :

Database Name : gamification
User Name : gamification
Password (and confirmation) : gamificationpw

Il you want to enter another informations, please modify as you want the glassfish-resources.xml. You can also edit the persistence.xml configuration file as you wish.

Then clean, build and play GamificationAPI. Your browser is automatically opened at the Gamification API root webpage, which show our APIary documentation.

Now, let's start to use the API ! If you want to test the functionnalies, you can use Postman extension for Google Chrome.

API Documentation

Currently, we have three differents documentations:

  1. APIary documentation
  2. Visual analysis (Domain model, REST diagram)
  3. Comments in the code :-)

Enjoy and dont hesitate to comment our work !

Known bugs

When you request our API to give you a JSON payload to big (for example, when you have more than 2000 users for one application and try to retrieve the leaderboards), Glassfish will return a HTTP 500 Internal Error. Here's a piece of the stacktrace:

StandardWrapperValve[ch.heigvd.gamification.services.exposed.RESTAPI]:
Servlet.service() for servlet
ch.heigvd.gamification.services.exposed.RESTAPI threw exception
java.lang.NullPointerException
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierBase.copy(ClassCopierBase.java:131)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl$17.copy(ClassCopierOrdinaryImpl.java:810)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl.copy(ClassCopierOrdinaryImpl.java:1008)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl.doCopy(ClassCopierOrdinaryImpl.java:1128)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierBase.copy(ClassCopierBase.java:129)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl$17.copy(ClassCopierOrdinaryImpl.java:810)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl.copy(ClassCopierOrdinaryImpl.java:1008)
    at
org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl.doCopy(ClassCopierOrdinaryImpl.java:1128)
...

The "solution" found is to increase the stack size of the JVM for glassfish (-Xss512m for example). No more exception.

But if you set the stack size too low (-Xss160k), it will appear another exception, different from the previous one.

WARNING:   StandardWrapperValve[ch.heigvd.gamification.services.exposed.RESTAPI]: Servlet.service() for servlet ch.heigvd.gamification.services.exposed.RESTAPI threw exception
java.lang.StackOverflowError
	at java.security.AccessController.doPrivileged(Native Method)
	at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$4.loadClass(OSGiModuleImpl.java:430)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:238)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
...

gamification-1's People

Contributors

aperusset avatar

Watchers

 avatar  avatar  avatar

Forkers

diogenesjf

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.