Simple Library Application using JavaEE 7 Technology (NOTE: This is an over engineer example)
- Apache Maven (3.3.9)
- MariaDB (10.0.29)
- Wildfly (10.1.0.FINAL)
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';
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
Create mysql datasource with JNDI name: java:jboss/datasource/libraryDS
-
@stateless: is EJB which is manage our transactional in jpa, we don't need to manage transaction, commit, rollback. etc. -
Watchout using
@SessionScopein JSF, make sure to use fromjavax.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 -
@XmlTransientin 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@XmlRootElementand@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
- web.xml deployment descriptor
- Java Logging
- Logback Configuration
- JSF @ManagedBean deprecated, used CDI @named
- JavaEE descriptor
- JavaEE PetStore
- Lightweight JavaEE
- JavaEE Structure
- How to Tacke JavaEE
- Configure JavaEE with Wildfly
- Best Practice JPA
- JAAS in Wildfly 10
- Form Based Authentication
- JDBC Realm
- JavaEE Authentication
- Edit Page in JSF
- ViewScoped in CDI