Proper Tomcat Resource configuration for MySql

Lately, I was faced with a mysql error when configured as a Resource in the tomcat server.xml configuration file.

The error looked the following:

STACKTRACE:

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: Broken pipe

STACKTRACE:

java.net.SocketException: Broken pipe
	at java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)

The problem was that I was not using the validationQuery parameter to be sure that the connection is still alive. So the parameter I neede absolutely were :

    validationQuery="select current_date()" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="false" initialSize="3"

Here is part of the server.xml file


     <Engine name="Catalina8680" defaultHost="localhost8680">
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 resourceName="UserDatabase"/>
          <Host name="localhost8680"  appBase="webapps8680"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
                <Context reloadable="true" displayName="myapp" docBase="/opt/apache-tomcat-6.0.20/webapps8680/myapp" path="/myapp" workDir="work/Catalina8680/localhost8680/myapp">
                
                <Resource name="jdbc/myapp_ds_0409085721" auth="Container" type="javax.sql.DataSource"
                   maxActive="10" maxIdle="3" maxWait="10000"
                   username="myapp_db" password="myapp_prod" driverClassName="org.gjt.mm.mysql.Driver"
                   url="jdbc:mysql://localhost:3306/myapp" 
                   validationQuery="select current_date()" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="false"
                   initialSize="3"/>

...


Build App with Aurelia in Visual Studio 2015

This is a quick How-To open the Aurelia Skeleton project in Visual Studio 2015. (The bad thing for now CTP6, is that it does not support ES6 syntax).

(UPDATE : Soon after writing this, I cam across this post which you should prefer when wanting to start with Aurelia : post from Scott Allen on Aurelia an Asp.net 5)

First follow these instruction to get up and running with an Aurelia Development environment : Aurelia get started cheat sheet – installation steps

1.Then create a new Project in Visual Studio : An Asp.net Web application

aurelia-1

choose the Empty Template

aurelia-2

2.This project should be created where you extracted the aurelia skeleton project (for me : C:_temp\GitHub\aurelia-playground)

aurelia-3

3.Copy (Cut and Paste) the content of the aurelia skeleton project (C:_temp\GitHub\aurelia-playground\aurelia-skeleton-v-0.12) to the new Asp.net project (C:_temp\GitHub\aurelia-playground\Aurelia.Skeleton)

4.edit the project.json file and change the web root to be the root folder :

    "webroot": ".",

5.Now you can just hit F5 and see chrome starting with the aurelia-skeleton nav project running.

6.or better from the Task Runner Explorer you can start the Task tdd and watch and start coding.

aurelia-4

Aurelia get started cheat sheet – installation steps

This post briefly lists the step you must do to start coding an Aurelia powered app. for the long story go to Aurelia Get started page.

  1. install node or update to the latest version . this step is important.

  2. install gulp globaly :
    npm install -g gulp
    
  3. install jspm globaly:
    npm install -g jspm
    
  4. configure jspm with github credentials : (follow instructions)
    jspm registry config github
    
  5. download the skeleton app : https://github.com/aurelia/skeleton-navigation/releases and extract it to a folder of your choice

  6. navigate to the root of the app :

    cd C:\_temp\GitHub\aurelia-playground\skeleton-navigation-0.12.0
    
  7. launch npm and jspm install
    npm install
    jspm install -y
    
  8. launch the command to start a webserver that listens on : http://localhost:9000/
    gulp watch
    

History :

12/04/2015 : tested with v0.12

jasmine test with configurable angular services

This post is just a jasmine braindump :

When testing angularjs services that needs to be configured, this is the way to configure it

 beforeEach(module('angular-toolkit-auth', 
                         function (authProvider, openIdProvider) {
     authProvider.setAuthenticationType('Bearer');
 }));

if you need more than one module to be instantiated for your test:

beforeEach(function(){
    module('angular-toolkit-storage');
    module('angular-toolkit-auth');
});

// or you can call them one after the other like so

beforeEach(module('angular-toolkit-auth'));
beforeEach(module('angular-toolkit-auth-config'));