Skip to content

Local JBoss AS 7.1 Environment

Andrew Simpson edited this page Oct 30, 2015 · 7 revisions

Operating System

JDK install

  • sudo apt-get install openjdk-7-jdk

java -version

  • java version "1.7.0_75"
  • OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~trusty1)
  • OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

Install JBoss AS 7.1 Server

Install Eclipse Kepler 4.3

Add JBoss Tools to Eclipse

Create ~/git

Create .ssh keys

Import Remote OpenShift App into Eclipse

  • Import->OpenShift->Existing Application (e.g. mysiwtapi)
  • Click option to allow easy publishing
  • configure public and private key created in above step to Eclipse/JBoss Tools

Import project from GIT

Manually migrate code into OpenShift Application

  • delete existing src and pom.xml from imported OpenShift application
  • copy src directory and pom.xml into their place (e.g. git/mysiwtapi)
  • cp -r switapi/.openshift into OpenShift application

Configure Eclipse Project Facets

  • CDI 1.0
  • Dynamic Web Module 3.0
  • Java 1.7
  • JavaScript 1.0
  • JAX-RS (Rest Web Services) 1.1
  • JBoss Maven Integration 1.0
  • JPA 2.0

Add Hibernate Run Configuration

  • Menu->Run->Run Configurations
  • Hibernate Console Configuration->New
  • enter configuration name, e.g. 'mysiwtapi'
  • select 'mysiwtapi' project
  • set JPA (JDK 1.5+) and Hibernate 4.0
  • Ignore direct run error on 'run'

Check Eclipse JPA Settings

  • Platform: Generic 2.0
  • JPA Implmentation: Disable Library Configuration
  • Connection: None (will generate warnings)
  • Discover annotated classes automatically

Suppress JAX-RS Error in Eclipse

  • Update behaviour for 'Configure Problem Severity for preference 'Missing Provider Implementation'
  • Update behaviour from 'Error' to 'Ignore'

Check Eclipse Hibernate Settings

  • Enable Hibernate Support
  • Default Hibernate Console configuration: mysiwtapi
  • Details : Main : Type:JPA; Version:4.0; Project:mysiwtapi; DB Connection: [JPA Project Configured]

Prune Failed Maven Downloads

  • If Maven complains about failed downloads, this command will prune failed items from repository

    find ~/.m2 -name "*.lastUpdated" -exec grep -q "Could not transfer" {} ; -print -exec rm {} ;

Update local AS 7.1 server modules

  • RestEasy 3.0.9
  • HTTPComponents 4.3.x
  • MySql 5 Connector
  • cp -r ~/git/mysiwtapi/.openshift/config/modules/* ~/apps/jboss-as-7.1.1.Final/modules

Create an SSL certificate and keystore for local server

Update local server Configuration to support HTTPS

  • cd ~/apps/jboss-as-7.1.1.Final/standalone/configuration
  • backup standalone.xml
  • edit standalone.xml
  • add https connector referencing created keystore

Around line 260

 <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
            <ssl password="passw0rd" protocol="TLSv1" verify-client="false" 
             certificate-key-file="/home/ams10961/apps/
                    jboss-as-7.1.1.Final/standalone/configuration/keystore"/>
   </connector>
   <virtual-server name="default-host" enable-welcome-root="true">
      <alias name="localhost"/>
   </virtual-server>
 </subsystem>

Update local server JDBC drivers

  • remove unused example data source
  • include H2 and MySql JDBC XA Drivers

Around line 95

    <subsystem xmlns="urn:jboss:domain:datasources:1.0">
        <datasources>
          <drivers>
            <driver name="h2" module="com.h2database.h2">
              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
            </driver>
            <driver name="com.mysql" module="com.mysql">
              <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
            </driver>
          </drivers>
        </datasources>
    </subsystem>

Update arquillian path

  • /mysiwtapi/src/test/resources/arquillian.xml

      <property name="jbossHome">/home/ams10961/apps/jboss-as-7.1.1.Final</property>
    

Install local MySql 5 Server

  • sudo apt-get install mysql-server
  • record admin username/password

**Setup local SQL Client

  • setup an SQL client, e.g. http://squirrelsql.org
  • download, e.g. squirrel-sql-3.6-standard.jar
  • java -jar squirrel-sql-3.6-standard.jar
  • note password, e.g. 'passw0rd'
  • start with ~/apps/squirrel-sql-3.6/squirrel-sql.sh, lock to launcher
  • add Driver
  • name 'jboss-mysql'
  • example URL jdbc:mysql://<hostname>[,][<:3306>]/[?<param1
  • add class path
  • browse to ~/git/api11/.openshift/config/modules/com/mysql/main/mysql-connector-java-5.1.28.jar
  • list drivers, select 'com.mysql.jdbc.Driver'
  • add Alias
  • select 'jboss-mysql', url 'jdbc:mysql://localhost:3306', user:root, password:passw0rd
  • create persistent SQL databases: siwtapi and siwtapi_test

Create Twitter Credentials Directory

  • mkdir ~/app-root
  • chmod 700 ~/app-root
  • mkdir ~/app-root/data
  • chmod 700 ~/app-root/data

Build and run tests

  • sudo apt-get install maven
  • make sure ~/app-root/data/twitter.properties contains keys and secrets
  • mvn clean test -Parq-jbossas-managed

Import local self-signed certificate into browser

Add localhost to truststore

Clone this wiki locally