PHP System Variables

System variables in Java are pretty straight forward: add them with the -D parameter when you start the JVM (/bin/java -Dcom.example.prod=true). However in an interpreted language like PHP, it’s a little different: you update the php.ini file with your environment-specific key-value pairs.

So in PHP if you want to set com.example.debug=true, then you’d simply place it in the php.ini file, and restart the Apache that serves the PHP files.

I do not fully understand why yet, but to get the standard php.ini variables (e.g. post_max_size) you use the function ini_get(“post_max_size”), but if you want to retrieve a custom variable, you should use get_cfg_var(“my.custom.var”).

The reason you would want to use “System Variables” instead of a global value is that System Vars are pertinent at a higher level than the code. You would want to let the code know which environment it is running in at startup, outside of the code.

PHP Test Frameworks

I’ve got a PHP project that desperately needs some basic Unit Testing. I am a huge fan of building automated tests as I develop code, and (mostly) before I even write the implementations. “How do we test this?” is one of the 2 most important questions in software development. (The other being “How do we define ‘done'”)

JUnit has been amazing for my Java development, so having a PHP test framework that is similar, or based off of its ideas is a big plus if I can get it.

There are a lot of good options out there that look good, but I have not had a chance to review all of them yet. The main ones considered at this point are:

  1. SimpleTest
    • PROS: easy to get up and running, just download the tar.gz file, unzip, and go. It is also very JUnit like in the Java world (TestSuites, run functions that start with the word “test”, etc.).
    • CONS: latest version was released in 2012
  2. Testify.php
    • PROS: easy to get up and running
    • CONS: not updated since August of 2014, and does not seem to be as JUnit-like as I’d prefer, but maybe that is due to the lack of documentation, and my lack of time to research it
  3. PHPUnit – The PHP Testing Framework
    • PROS: most up-to-date and seems very enterprise ready (latest version was released about a week ago as of this writing)
    • CONS: install is not as easy as the others. It requires a PHAR file (not a real big issue), but it is not as easy as the others to get going in a Windows environment (again, not a huge problem, but it is more involved than the others)

In the end I decided to go with SimpleTest because its first few tutorials were very easy to get up and running, and it is very JUnit-like. The code base is also only running PHP 5.3.3, so it is on an older version of PHP, and the fact that SimpleTest (and Testify.php) were a little dated is not as big of an issue, and probably easier (as to not mix features of newer PHP versions) at this point in time.

At some point I should at least go through the Testify.php tutorials to see if it is a viable option.

2006 Dodge Grand Caravan wheel stud/rear assembly replacement

Rear Assembly with Replacement stud The wife’s van had a flat tire, and while taking the lug nuts off one of them decided to get stuck and break off the wheel stud. Once I got the caliper, drum, parking break, etc. all off I at first was going to try just replacing the wheel studs, but this process was very slow, and in the end I decided to just replace the entire rear assembly.

I could not have done it without the links below, and a few other things to keep in mind:

  • use a sledge hammer to get the roter off if it is tough to get off (but only hit near the studs. If replacing just one or two of the studs (and not the whole assembly), put lug nuts over the good studs to help protect them from errant hits with the sledge hammer
  • if replacing studs, use a stack of washers to pull the stud into the assembly, and a screwdriver against other studs, or through the holes of open holes of the assembly to stabilize the assembly while tightening the stud
  • do NOT put the rear assembly on before doing the parking brakes first. Put a couple of the rear assembly bolts in and zip ties in the other holes to hold the backing plate on, assemble the parking brakes, carefully cut the zip ties, then put the rear assembly on
  • to put the bottom parking brake spring on, grab the center of the spring with some pliers and pull it to the other hole
  • when putting the spacer on the rear brakes in, grab both sides of the parking brake with pliers, pull apart while someone else places the spacer in the bottom of the brakes

How to change rear brakes and rotors 2006 DGC – DodgeForum.com

install 2005 dodge caravan rear wheel bearing and parking brake pads – YouTube

install 2005 dodge caravan rear wheel bearing and parking brake pads – YouTube

install 2005 dodge caravan rear wheel bearing and parking brake pads – YouTube

Mysql connects via command line, but not through client

I thought I had installed MySql so that it was available to the outside world (at least locally), but I kept getting the exception through SquirrelQL:

java.util.concurrent.ExecutionException: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:202)

at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:171)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
… 5 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
… 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
… 21 more

I knew I had to of done something wrong in the install (probably forgot to check the allow remote connection option). The original mysql.ini (which was wrong) looked like this:

[client]

pipe
socket=mysql

[mysql]

default-character-set=latin1

# SERVER SECTION
# ———————————————————————-
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

skip-networking
enable-named-pipe

# The Pipe the MySQL Server will use
socket=mysql

#Path to installation directory. All paths are usually resolved relative to this.
basedir=”C:/Program Files (x86)/MySQL/MySQL Server 5.1/”

#Path to the database root
datadir=”C:/ProgramData/MySQL/MySQL Server 5.1/Data/”

I changed the section to the following, and then my clients were able to connect to the localhost db:

[client]

port=3306

[mysql]

default-character-set=latin1

# SERVER SECTION
# ———————————————————————-
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306

#Path to installation directory. All paths are usually resolved relative to this.
basedir=”C:/Program Files (x86)/MySQL/MySQL Server 5.1/”

#Path to the database root
datadir=”C:/ProgramData/MySQL/MySQL Server 5.1/Data/”

Git failure due to http vs. https

Somehow I either saved the URL wrong, or the URL changed (more likely), and caused git to fail when the URL should have been secure:

C:\dev\git\myCode>git push origin master
fatal: unable to access 'http://sean@dev1.company.com/stash/scm/inf/myCoolApp.git/': Empty reply from server

update .git/config to be https URL

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
	hideDotFiles = dotGitOnly
[remote "origin"]
	url = https://sean@dev1.company.com/stash/scm/inf/myCoolApp.git/
	fetch = +refs/heads/*:refs/remotes/origin/*

Been a busy first few months of the year

Over the past couple of years, we were passively looking to move to a more rural area, and the wife was fortunate enough to come across a property that was a 4 bedroom, 3 bath on 5 acres not too far from town.  Moving out of the old house was pretty sad, but being out in the open spaces has been amazing.

Right before all of this went down, I decided to move the site from bluehost.com to godaddy.com. Bluehost.com is awesome, but I was paying for more than what I needed for this simple site. GoDaddy offered a cheaper price for just WordPress, which is all I really use (for now).

Now that we are pretty much settled into the new house, I hope to get back into posting some of the more interesting aspects of software that I come across, much like I did last year.  In my free time, I have been working on some PHP projects for fun, and hope to get more into that space on this blog in addition to the new things in Java that I do by day.

I have also been managing the [Everything IT near Waco](http://www.meetup.com/Everything-IT-near-Waco/) Meetup.  This area has been interesting in that it has a lot of IT people, but few seem to be as interested in networking with other IT-ers in the area.  Maybe it’s just me.  Either way I’ve paid for a year’s worth of Meetup fees, so I’ll persist on, and re-evaluate next winter.

My goal is to have at least 2 posts per month for the rest of the year, starting in May.  It’s now on the web for all 4 of the bots that hit this page to see, which means I must not disappoint them, and make it happen.

2014 Blog recap

I made 34 blog posts this year (including this one). For my first full year of maintaining my Living Resume, my goal was to average one post per week, and while I fell short of this goal, I did maintain this blog throughout the year. If I would have made time to complete all of my posts that are in-progress, I would have come pretty close to achieving the 52 post goal.  But then again, that’s just an excuse.  Hopefully I’ll do better next year.

Books of 2014

I read a ton this year, but I did not read as many books as my record setting 2013 of 20 books. I read many more technical articles and Longreads than anything else. While all of that is tough to track, I did make time to read 9 different books:

  1. Hatching Twitter: A True Story of Money, Power, Friendship, and Betrayal
  2. Parenting with Love and Logic: Teaching Children Responsibility
  3. A Higher Call: An Incredible True Story of Combat and Chivalry in the War-Torn Skies of World War II
  4. Exploding the Phone: The Untold Story of the Teenagers and Outlaws who Hacked Ma Bell
  5. Catching Fire (Hunger Games Trilogy, Book 2)
  6. Mockingjay: Movie Tie-In Edition (The Hunger Games)
  7. Sex, Drugs, and Cocoa Puffs: A Low Culture ManifestoChuck Klosterman.
  8. George Washington’s Secret Six: The Spy Ring That Saved the American Revolution
  9. Death to the BCS: Totally Revised and Updated: The Definitive Case Against the Bowl Championship Series eBook: Dan Wetzel, Josh Peter, Jeff Passan: Books

Fix WebSphere OutOfMemory error during deployment

Deployments within the WebSphere v7 environment were randomly failing with OutOfMemory (OOM) errors. We initially thought it was due to a very large EAR file being deployed, but after a while, this theory was inconsistent because OOMs occurred with small and large EARs alike. Within the SystemOut.log, we found this error:

[1/10/14 06:17:51:553 CST] 00000000 AbstractShell E   WASX7120E: Diagnostic information from exception with text "com.ibm.websphere.management.application.client.AppDeploymentException: com.ibm.websphere.management.application.client.AppDeploymentException [Root exception is java.lang.OutOfMemoryError]
java.lang.OutOfMemoryError: java.lang.OutOfMemoryError " follows:

 com.ibm.websphere.management.application.client.AppDeploymentException [Root exception is java.lang.OutOfMemoryError]
    at com.ibm.ws.management.application.client.AppInstallHelper.getAppDeploymentInfoGenericRead(AppInstallHelper.java:520)
    at com.ibm.ws.management.application.client.DefaultBindingHelper.prepareTask(DefaultBindingHelper.java:216)
    at com.ibm.ws.scripting.AdminAppClient.createPreferences(AdminAppClient.java:2885)
    ...
    at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
    at org.eclipse.core.launcher.Main.run(Main.java:981)
    at com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:341)
    at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:111)
Caused by: java.lang.OutOfMemoryError
    at org.objectweb.asm.Type.getDescriptor(Unknown Source)
    at com.ibm.ws.amm.scan.util.info.impl.InfoImpl.getClassName(InfoImpl.java:217)
    at com.ibm.ws.amm.scan.util.info.impl.InfoImpl.getClassInfo(InfoImpl.java:158)
    ...

From the install script, we saw this error:

[1/10/14 06:17:52:941 CST] 00000000 AbstractShell A   WASX7093I: Issuing message: "WASX7017E: Exception received while running file "/websphere/utilities/scripts/installNewApplication.py"; exception information: com.ibm.websphere.management.application.client.AppDeploymentException: com.ibm.websphere.management.application.client.AppDeploymentException [Root exception is java.lang.OutOfMemoryError]
java.lang.OutOfMemoryError: java.lang.OutOfMemoryError

We knew we had to increase the heap size of the deployment manager, but that turned out to be a little less obvious then anticipated.

The Python script used to kickoff the install eventually calls the Profile’s (Dmgr) script: /websphere/AppServer/profiles/Dmgr/bin GenPluginCfg.sh

#!/bin/sh
binDir=`dirname ${0}`
. ${binDir}/setupCmdLine.sh
${WAS_HOME}/bin/GenPluginCfg.sh "$@"

The last line of the profile’s GenPluginCfg.sh calls the cell’s version of GenPluginCfg.sh, which is where the heap can be adjusted as needed (-Xmx):

"$JAVA_HOME/bin/java" -Xmx1024m 
  -Dserver.root="$WAS_HOME" 
  $CLIENTSAS 
  -Dws.ext.dirs="$WAS_EXT_DIRS" 
  $USER_INSTALL_PROP 
  $WAS_LOGGING 
  -classpath "$WAS_CLASSPATH" com.ibm.ws.bootstrap.WSLauncher 
  com.ibm.websphere.plugincfg.generator.PluginConfigGenerator "$WAS_HOME" "$CONFIG_ROOT" "$WAS_CELL" "$WAS_NODE" $@

Don’t forget to backup any script you plan to alter before making updates. No reason to make a fat-finger mistake that causes a cryptic error message and takes forever to figure out.

Stash, Bamboo, Jira. How do they fit together?

My current client has bought into Atlassian products pretty hard this year, and I am loving it. Prior to the migration to Atlassian they had a home-grown solution that was less than ideal for software project management. It is nice when software just “works”. Especially when it is software specifically for software projects, written by a company whose sole purpose is to write software to manage software projects.

The language can get a little confusing if you are new to modern software project management, but at a high level these are the Atlassian products we are using, and how they related to each other:

Jira

JIRA is many things. At its most basic level, it is a way to track “issues” (aka tasks) for a given project, regardless of what type of project it may be: TODOs for support projects, project managers to track Agile projects, and everything in between. At a very high level JIRA allows you to create an “issue” for a given project and assign it to someone with a given priority. An issue can be anything, but is most likely to be a: Bug, Improvement, Task, or some variation of one of these. Issue types are highly customizable, so you are not limited to just these options.

Stash

Stash provides a visual way to manage your git repository, much like GitHub, but for the corporate world.

Bamboo

Bamboo is a Continuous Integration (CI) and build server. It will connect to Stash (i.e. git), and build the deliverable (i.e. artifact). The artifact will likely be an EAR, WAR, or JAR file in the Java world. Bamboo will also provide the deployment to the respective environments (Dev, UAT, Prod, etc.).

Combine them all

One of Jira’s most powerful features is that it allows you to create an issue in JIRA, associate it with a new branch in Stash, and a deployment within Bamboo. So if a user sees an issue with the Order Processing app, he can create an issue for this app and assign it to the project lead for the app. JIRA can then track the developer’s progress on this issue, and all collaboration between interested parties via comments in Jira to ensure the issue is fixed properly. Everyone will see that the build has been performed in Bamboo, and the newest version (e.g. 1.3.12) has fixed a list of issues, including the original issue reported.

There is a lot more available with these Atlassian products, but if interested, dial in to one of their many free webinars to better understand how they can help you.