Skip to content
This repository was archived by the owner on Dec 13, 2021. It is now read-only.

swardana/javaee-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JAVAEE EXAMPLE

Simple Library Application using JavaEE 7 Technology (NOTE: This is an over engineer example)

Tools & Library

  • Apache Maven (3.3.9)
  • MariaDB (10.0.29)
  • Wildfly (10.1.0.FINAL)

Environment

Database

To be able running this project first step is to setup the database, in this project used mariaDB database. Database was named library with username: user, password: password, to make it simple run command below:

CREATE DATABASE IF NOT EXISTS library;
ALTER DATABASE library DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON library.* TO user@localhost IDENTIFIED BY 'password';

Schema & Data

DDL schema and data was stored in src/main/resources/db. For command line user, execute command below from project directory:

mysql --user="user" --password="password" --database="library" < src/main/resources/db/schema.sql
mysql --user="user" --password="password" --database="library" < src/main/resources/db/data.sql

Datasource

Create mysql datasource with JNDI name: java:jboss/datasource/libraryDS

NOTES

  • @stateless: is EJB which is manage our transactional in jpa, we don't need to manage transaction, commit, rollback. etc.

  • Watchout using @SessionScope in JSF, make sure to use from javax.enterprise.context.SessionScoped

  • @Model: is a stereotype for @Named & @SessionScoped in JSF

  • Wildfly App Server as default using SLF4J for logging implementation, so in pom.xml made SLF4J scope as provided

  • Because I put JSF files under folder views, so need to open in browser like this: javaee/views/main.xhtml

  • Entities class need to specified table name with @Table

  • To be able perform get all data, need to made an NamedQuery

  • [ERROR] Caused by: java.lang.IllegalArgumentException: WFLYEE0040: A component named 'xxx' is already defined in this module"}} just perform:

    • wildfly:undeploy
    • clean install
    • wildfly:deploy
  • Building JAX-RS always use JsonArray instead JsonObject

  • WILDFLY 10.1.0 Supported SHA-512, to be able encrypt something run command bellow

    java -cp WILDFLY_HOME/modules/system/layers/base/org/picketbox/main/picketbox-4.9.6.Final.jar org.jboss.security.Base64Encoder <password> <message-digest>
    example:
    java -cp WILDFLY_HOME/modules/system/layers/base/org/picketbox/main/picketbox-4.9.6.Final.jar org.jboss.security.Base64Encoder sukma SHA-512
    
  • @XmlTransient in entity variable will prevent to be serialized as xml or json when using JAX-WS or JAX-WS. At the moment I just know that I need to add @XmlRootElement and @XmlAccessorType(XmlAccessType.FIELD).

  • @XmlAccessorType(XmlAccessType.FIELD) It's very great because we don't need to made an getter and setter, it will automatically generate a xml or json from variable enitity

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors