All Projects → karlnicholas → Dukes Forest

karlnicholas / Dukes Forest

Port of dukes-forest to Wildfly 9 and MySql 5.6.

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Dukes Forest

Sqldef
Idempotent MySQL/PostgreSQL schema management by SQL
Stars: ✭ 762 (+15140%)
Mutual labels:  mysql
Privesc
A collection of Windows, Linux and MySQL privilege escalation scripts and exploits.
Stars: ✭ 786 (+15620%)
Mutual labels:  mysql
Geek Framework
基于SpringBoot+Shiro+Redis+Jwt+Thymeleaf+MyBatis 开发的后台用户、角色、权限、会员管理、RestFul、Token和前台用户登录注册以及前后台用户分离的脚手架,技术交流请加QQ群:805442966
Stars: ✭ 804 (+15980%)
Mutual labels:  mysql
Dble
A High Scalability Middle-ware for MySQL Sharding
Stars: ✭ 774 (+15380%)
Mutual labels:  mysql
Funpyspidersearchengine
Word2vec 千人千面 个性化搜索 + Scrapy2.3.0(爬取数据) + ElasticSearch7.9.1(存储数据并提供对外Restful API) + Django3.1.1 搜索
Stars: ✭ 782 (+15540%)
Mutual labels:  mysql
Mysqltools
一个用于快速构建大规模,高质量,全自动化的 mysql分布式集群环境的工具;包含mysql 安装、备份、监控、高可用、读写分离、优化、巡检、自行化运维
Stars: ✭ 795 (+15800%)
Mutual labels:  mysql
Bookshelf
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
Stars: ✭ 6,252 (+124940%)
Mutual labels:  mysql
Sqltabs
Rich SQL client for Postgresql, MySQL, MS SQL, Amazon Redshift, Google Firebase (Firestore)
Stars: ✭ 809 (+16080%)
Mutual labels:  mysql
Fluentpdo
A PHP SQL query builder using PDO
Stars: ✭ 783 (+15560%)
Mutual labels:  mysql
Newbee Mall
🔥 🎉newbee-mall 项目(新蜂商城)是一套电商系统,包括 newbee-mall 商城系统及 newbee-mall-admin 商城后台管理系统,基于 Spring Boot 2.X 及相关技术栈开发。 前台商城系统包含首页门户、商品分类、新品上线、首页轮播、商品推荐、商品搜索、商品展示、购物车、订单结算、订单流程、个人订单管理、会员中心、帮助中心等模块。 后台管理系统包含数据面板、轮播图管理、商品管理、订单管理、会员管理、分类管理、设置等模块。
Stars: ✭ 8,319 (+166280%)
Mutual labels:  mysql
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+15400%)
Mutual labels:  mysql
Pymysql
Pure Python MySQL Client
Stars: ✭ 6,694 (+133780%)
Mutual labels:  mysql
Kingbus
A distributed MySQL binlog storage system built on Raft
Stars: ✭ 798 (+15860%)
Mutual labels:  mysql
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (+15240%)
Mutual labels:  mysql
Ezsql
PHP class to make interacting with a database ridiculusly easy
Stars: ✭ 804 (+15980%)
Mutual labels:  mysql
Usql
Universal command-line interface for SQL databases
Stars: ✭ 6,869 (+137280%)
Mutual labels:  mysql
Ghchat
📱A chat application for GitHub. React + PWA + Node(koa2) + Typescripts + Mysql + Socket.io
Stars: ✭ 791 (+15720%)
Mutual labels:  mysql
Hospital Management System
"Health Care hospital" Management System is designed for manage details about hospital patient,employee and rooms(10). Designed by using HTML / CSS / JS / JQUERY/ PHP (procedural php) / MYSQL.
Stars: ✭ 5 (+0%)
Mutual labels:  mysql
Demo Scene
👾Scripts and samples to support Confluent Demos and Talks. ⚠️Might be rough around the edges ;-) 👉For automated tutorials and QA'd code, see https://github.com/confluentinc/examples/
Stars: ✭ 806 (+16020%)
Mutual labels:  mysql
Schemats
Generate typescript interface definitions from SQL database schema
Stars: ✭ 799 (+15880%)
Mutual labels:  mysql

Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.

You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://java.net/projects/javaeetutorial/pages/BerkeleyLicense

Please find the Oracle dukes-forest tutorial documentation at Duke's Forest Case Study Example

dukes-forest tutorial example.

This document is divided into Installation and running and Notes on changes to the original source

Installation and running procedures.

  • Date 02/2106

  • Clone git repository git clone https://github.com/karlnicholas/dukes-forest.git.

Database procedures.
  • Create a schema in MySQL named forest in lowercase. I used the workbench.

  • Create the database user and password in your MySQL server. Give this user full privileges to the forest schema. This username and password will need to be added to your Forest datasource.

  • Create the schema. There is an issue with having JPA auto create the schema and load the data. It works, but it works for both dukes-shipment and dukes-store. The create sql script won't create the database twice, but the load sql script will load twice, so let's just do it by hand because I have commented out the create and load properties in the entities persistence.xml file. The create.sql script is in entities/src/main/resources/META-INF/sql/create.sql.

  • Load the default data. The load data.sql script is in entities/src/main/resources/META-INF/sql/data.sql.

Wildfly procedures.
  • Pick a Wildfly configuration file to work with: Be sure you are running the standalone-full version., or at least have JMS messaging enabled ( I used the standalone-full.xml, I don't know the exact configuration needed, but standalone-full.xml worked).

  • You can either edit and run the wildfly-commands.cli command line file found in dukes-forest/wildfly-commands.cli, you can can manually do each step below.

  • Add XA mysql jdbc driver module to Wildfly if you have not already done so. See Example MySQL XA Datasource for example.

  • Add a XA datasource and driver to wildfly. See Example MySQL XA Datasource for example. Set the jndi-name java:jboss/ForestXADS and name ForestXADS. This can be done through the management console, or by copying and pasting the XML snippet shown in the notes below. Be sure the datasource is enabled and you can sucessfully test the connection from the wildfly management console.

      <datasources>
         <xa-datasource jndi-name="java:jboss/ForestXADS" pool-name="ForestXADS" enabled="true">
         <driver>com.mysql</driver>
         <xa-datasource-property name="URL">jdbc:mysql://localhost:3306/forest</xa-datasource-property>
         <security>
           <user-name>forest</user-name>
           <password>forest</password>
         </security>
       </xa-datasource>
       <drivers>
         <driver name="mysql" module="com.mysql">
           <datasource-class>com.mysql.jdbc.Driver</datasource-class>
           <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
         </driver>
       </drivers>
     </datasources>
    

    and ...

      <driver name="mysql" module="com.mysql">
          <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
      </driver>
    
  • Add a message queue wildfly named OrderQueue, as per specs below.

      <jms-queue name="OrderQueue">
          <entry name="java:global/jms/queue/OrderQueue"/>
          <durable>true</durable>
      </jms-queue>
    
  • Add a security-domain to wildfly named dukes-forest, as per specs below. Note that on unix systems the queries are case sensitive.

      <security-domain name="dukes-forest" cache-type="default">
          <authentication>
              <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
                  <module-option name="dsJndiName" value="java:jboss/ForestXADS"/>
                  <module-option name="rolesQuery" value="select NAME as 'ROLES', 'Roles' as 'ROLEGROUP' from forest.GROUPS g inner join forest.PERSON_GROUPS pg on g.ID = pg.GROUPS_ID join forest.PERSON p on p.EMAIL = pg.EMAIL where p.EMAIL = ?"/>
                  <module-option name="hashAlgorithm" value="MD5"/>
                  <module-option name="hashEncoding" value="HEX"/>
                  <module-option name="principalsQuery" value="select PASSWORD from forest.PERSON where EMAIL=?"/>
              </login-module>
          </authentication>
          <authorization>
              <policy-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
                  <module-option name="dsJndiName" value="java:jboss/ForestXADS"/>
                  <module-option name="rolesQuery" value="select NAME as 'ROLE', 'ROLES' as 'ROLEGROUP' from forest.GROUPS g inner join forest.PERSON_GROUPS pg on g.ID = pg.GROUPS_ID join forest.PERSON p on p.EMAIL = pg.EMAIL where p.EMAIL = ?"/>
                  <module-option name="hashAlgorithm" value="MD5"/>
                  <module-option name="hashEncoding" value="HEX"/>
                  <module-option name="principalsQuery" value="select PASSWORD from forest.PERSON where EMAIL=?"/>
              </policy-module>
          </authorization>
      </security-domain>
    
dukes-forest steps.
  • Run mvn clean verify from the dukes-forest directory. This will build 3 jar files and 3 war files, events.jar, entities.jar, dukes-resources.jar, and dukes-payment.war, dukes-shipment.war, and dukes-store.war, in that order.

  • Run mvn install from the dukes-forest directory, so that the jars will be put into your repository.

  • Deploy dukes-payment, dukes-shipment, and dukes-store to wildfly. This can be done by running mvn wildfly:deploy from each subdirectory, or by copying the .war files to the wildfly-9.0.2.Final/standalone/deployments directory, or by using Eclipse Run->Run on Server. There was an issue here. See Schema not generated if Entities and Persistence.xml in another jar. Since dukes-forest has its entities in the entities.jar, the database create scripts would not get executed if you deployed from maven or copied the .war files manually. Only Run on Server from Eclipse worked. There was also a problem because both the dukes-shipment.war and the dukes-store.war have the entities.jar in them. The entities.jar has the persistence.xml file, which was configurated to tell the server to create the database and load the default data. That means it was done twice, which was problematic. The issue doesn't apply because the created the schema was created and loaded manually as per the database procedures above.

  • Open http://localhost:8080/dukes-store to run dukes-store. You will need the built-in administrator account to login to dukes-shipment, which is username=[email protected] and password=1234.

  • Refer to the Duke's Forest Case Study Example tutorial for further information on using the example.

Notes on changes to original source for porting to Wildfly 9.

Port of Dukes-Forest tutorial to Wildfly 9 and MySql 5.6.

  • Date: 10/2015

  • Created projects for jboss developer studio 9.0 ga, eclipse 4.5 (Mars). dukes-payment, dukes-resources, dukes-shipment, dukes-store, entities, events.

  • Changed entities/src/main/resources/META-INF/persistence.xml to comment out the drop-create properties.

  • Fixed up Database scripts and model. I used the dukes-forest-model.mwb, the MySQL workbench EER Diagram. The diagram was out of sync with the entities/src/main/resources/META-INF/sql/create.sql script. Mostly the differences included auto increment of indexes, non-null fields, and, more importantly, the length of various var-char fields. Also, there was an issue with a Foreign Key Index on the Product table being named the same as the Foreign Key.

  • Changed entities/src/main/resources/META-INF/persistence.xml to use java:jboss/ForestXADS instead of java:global/ForestXADS.

  • Added java:jboss/ForestXADS datasource and mysql driver in standalone-full.xml.

      <datasources>
         <xa-datasource jndi-name="java:jboss/ForestXADS" pool-name="ForestXADS" enabled="true">
         <driver>com.mysql</driver>
         <xa-datasource-property name="URL">jdbc:mysql://localhost:3306/forest</xa-datasource-property>
         <security>
           <user-name>forest</user-name>
           <password>forest</password>
         </security>
       </xa-datasource>
       <drivers>
         <driver name="mysql" module="com.mysql">
           <datasource-class>com.mysql.jdbc.Driver</datasource-class>
           <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
         </driver>
       </drivers>
     </datasources>
    

    and ...

      <driver name="mysql" module="com.mysql">
          <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
      </driver>
    
  • Created appropriate queue in Wildfly and made Eclipse run Wildfly with standalone-full.xml so that JMS services would be available.

      <jms-queue name="OrderQueue">
          <entry name="java:global/jms/queue/OrderQueue"/>
          <durable>true</durable>
      </jms-queue>
    
  • Changed dukes-shipment/src/main/java/com.forest.shipment.ejb.OrderBrowser to use jboss compatible jndi name for jms message queue.

      @Resource(mappedName = "java:global/jms/queue/OrderQueue")
    
  • Changed dukes-store/src/main/java/com/forest/ejb/OderJMSManager.java to use jboss compatible jndi name for jms message queue.

      name = "java:jboss/jms/queue/OrderQueue",
      @Resource(mappedName = "java:global/jms/queue/OrderQueue")        
    
  • Removed src/main/webapp/WEB-INF/glassfish-web.xml in dukes-payment, dukes-shipment and dukes-store projects. Added jboss-web.xml set to dukes-forest security domain in WEB-INF directory.

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
          <security-domain>dukes-forest</security-domain>
      </jboss-web>
    
  • Added dukes-forest security-domain in standalone-full.xml. Added both authentication and authorization sections.
    Had to work out the correct rolesQuery and principalsQuery sql statements to use the database for authentication.

      <security-domain name="dukes-forest" cache-type="default">
          <authentication>
              <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
                  <module-option name="dsJndiName" value="java:jboss/ForestXADS"/>
                  <module-option name="rolesQuery" value="select NAME as 'ROLES', 'Roles' as 'ROLEGROUP' from forest.GROUPS g inner join forest.PERSON_GROUPS pg on g.ID = pg.GROUPS_ID join forest.PERSON p on p.EMAIL = pg.EMAIL where p.EMAIL = ?"/>
                  <module-option name="hashAlgorithm" value="MD5"/>
                  <module-option name="hashEncoding" value="HEX"/>
                  <module-option name="principalsQuery" value="select PASSWORD from forest.PERSON where EMAIL=?"/>
              </login-module>
          </authentication>
          <authorization>
              <policy-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
                  <module-option name="dsJndiName" value="java:jboss/ForestXADS"/>
                  <module-option name="rolesQuery" value="select NAME as 'ROLE', 'ROLES' as 'ROLEGROUP' from forest.GROUPS g inner join forest.PERSON_GROUPS pg on g.ID = pg.GROUPS_ID join forest.PERSON p on p.EMAIL = pg.EMAIL where p.EMAIL = ?"/>
                  <module-option name="hashAlgorithm" value="MD5"/>
                  <module-option name="hashEncoding" value="HEX"/>
                  <module-option name="principalsQuery" value="select PASSWORD from forest.PERSON where EMAIL=?"/>
              </policy-module>
          </authorization>
      </security-domain>
    
  • Changed /src/main/java/webapp/WEB-INF/web.xml for dukes-shipment and dukes-shop projects to use dukes-forest security domain for login.

      <!--Defining security constraint for type of roles available -->     
      <security-constraint>
          <web-resource-collection>
              <web-resource-name>Secure Pages</web-resource-name>
              <description/>
              <url-pattern>/admin/*</url-pattern>
          </web-resource-collection>
          <auth-constraint>
              <role-name>ADMINS</role-name>
          </auth-constraint>
      </security-constraint>
      <!--Defining security constraint for type of roles available -->
      <!--Defining type of authentication mechanism -->
      <login-config>
          <auth-method>FORM</auth-method>
          <realm-name>dukes-forest</realm-name>
          <form-login-config>
              <form-login-page>/login.xhtml</form-login-page>
              <form-error-page>/login.xhtml</form-error-page>
          </form-login-config>
      </login-config>
      <!--Defining type of authentication mechanism -->
      <!--Defining security role -->    
      <security-role>
          <role-name>ADMINS</role-name>
      </security-role>
      <!--Defining security role -->
    
  • Changed /src/main/java/webapp/WEB-INF/web.xml for dukes-payment project to security-contraints for login.

      <security-constraint>
          <web-resource-collection>
              <web-resource-name>Secure payment service</web-resource-name>
                  <description/>
              <url-pattern>/*</url-pattern>
              <http-method-omission>GET</http-method-omission>
          </web-resource-collection>
          <auth-constraint>
              <role-name>USERS</role-name>
          </auth-constraint>
      </security-constraint>
      <login-config>
          <auth-method>BASIC</auth-method>
      </login-config>
      <security-role>
          <role-name>USERS</role-name>
      </security-role>
    
  • Changed entities/src/main/java/com/forest/entity/Person.java to make fetch of groupsList EAGER instead of LAZY, which is was by default.

      @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER )
      protected List<Groups> groupsList;
    
  • Commented out the "data-source" from web.xml for dukes-store project.

  • Changed com.forest.handlers.PaymentHandler to use "Basic " instead of "BASIC " for the "Authorization" header. See WildFly issue HTTP Authentication Basic header is case sensitive.

  • Added @JsonIgnore to com.forest.entity.CustomerOrder.setCustomer(Person person) because it was a duplicate signature with CustomerOrder.setCustomer(Order order) and causing problems with JSON serialization.

      @JsonIgnore
      public void setCustomer(Person person) {
          this.customer = (Customer) person;
      }
    
  • Added fetch=FetchType.EAGER to orderDetailList in com.forest.entity.CustomerOrder because lazy initialization was failing when used CustomerOrder was being used as a service by dukes-shipping.

      @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerOrder", fetch=FetchType.EAGER)
    
  • Added code to com.forest.ejb.UserBean in dukes-store project to add USERS role to new users, otherwise new users would not be able to sign in.

      Query createNamedQuery = getEntityManager().createNamedQuery("Groups.findByName");
      createNamedQuery.setParameter("name", "USERS");
      if (createNamedQuery.getResultList().size() > 0) {
          customer.getGroupsList().add( (Groups)createNamedQuery.getSingleResult());
          super.create(customer);
          return true;
      } else {
          return false;
      }
    
  • Issues about upper/lower case table and field names in MySQL when running on UNIX. COnverted everything to UPPERCASE. Tried lowercase, but hiberate generated names in uppercase.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].