Tag: java

SSLProtocolException in SE7 & SE8: “handshake alert: unrecognized_name”

Caused by: com.sun.jersey.api.client.ClientHandlerException: 
javax.net.ssl.SSLProtocolException: handshake alert:  
unrecognized_name at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle (URLConnectionClientHandler.java:151) 
at com.sun.jersey.api.client.Client.handle(Client.java:648) 
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680) 
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) 
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:5 68) 

This exception is from an SSL check in SE7 and above that checks that your SSL certificate matches your domain name. For development, if you’re using a self-signed SSL certificate for testing which does not match your domain name, you can turn off the check and ignore the error with:


(Page views: 44)

EE6 and EE7 Maven deps for JBoss AS7 and WildFly8

For EE7 on WildFly8.x, use:

Full profile:


Web profile:


For EE6 on JBoss AS7.x, use:


Info from JBoss’s EE spec Git repo here and referenced from this question here.

(Page views: 24)

JSF 2.x Conditional error messages

To conditionally show a Twitter Bootstrap styled DIV with a list of error messages, use the rendered property on panelGroup to check whether messageList has messages to be displayed, and if so, render the enclosed content.

layout=”block” displays the output as a DIV, and row is one of the Bootstrap classes for row display.


Set messages to display from your Backing Bean with:

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("your message");

(Page views: 50)

JSTL notes

A few notes for a few common JSTL things so I don’t forget:


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>



String replace using replace function:

${fn:replace(foo, '"', '\"')}


This next tip for using a loop varStatus to build HTML ids is from: http://stackoverflow.com/questions/6600738/use-jstl-foreach-loops-varstatus-as-an-id


This unexpectedly gives:

To get the actual varStatus id you need to use:


(Page views: 26)

Useful Java ME 8 Embedded code snippets

Collection of ME 8 Embedded code snippets:

  • Using java.util.TimerTask and Timer – for scheduling periodic tasks (reading a sensor, checking a status etc eg
MyTimerTask myTimerTask = new MyTimerTask();
Timer timer = new Timer();
timer.schedule(myTimerTask, millisBeforeStarting, millisBetweenExecution);
  • Opening a GPIO pin:
this.pin = PeripheralManager.open(this.pinId); 
this.pin.setValue(true); // true = on, false = off
  • Adding an EventListener to a switch:
GPIOPinConfig config = new GPIOPinConfig(this.portId, this.pinId,
    GPIOPinConfig.DIR_INPUT_ONLY, PeripheralConfig.DEFAULT,
this.pin = PeripheralManager.open(config);

… where this implements PinListener and valueChanged() method:

public void valueChanged(PinEvent event) {
    GPIOPin eventPin = event.getPeripheral();
  • Opening an I2C device for input/output:
I2CDeviceConfig config = new I2CDeviceConfig(i2cBus, address, addressSizeBits, serialClock);
myDevice = PeripheralManager.open(config);
  • Read from a UART device:
this.uart = PeripheralManager.open(UART_DEVICE_ID);

InputStream is = Channels.newInputStream(uart);
this.serialBufferedReader = new BufferedReader(new InputStreamReader(is));
  • Read using Generic Connection Framework:
CommConnection conn = (CommConnection)Connector.open("comm:/dev/ttyAMA0;baudrate=9600");
InputStream inputStream = conn.openInputStream();
this.serialBufferedReader = new BufferedReader(new
  • Open and write to a record store:
this.store = RecordStore.openRecordStore(storeName, true);
byte[] dataBytes = data.getBytes();
recordNum = store.addRecord(dataBytes, 0, dataBytes.length);

(Page views: 20)

Debugging JAXB unmarshalling issues

JAXB appears to fail silently in some cases if the XML it’s attempting to unmarshall to mapped classes doesn’t have the necessary mapped properties.

You can get additional output by adding the following:


- displays information during JAXB initialization

Before you call unmarshall() on your Unmarshaller, call setEventHandler() and add a DefaultValidationEventHandler as follows:

Unmarshaller um = jaxbContext.createUnmarshaller();
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());

- this will output additional failure information about missing mappings for xml elements, useful if your mapped class ends up with missing values.

(Page views: 23)

Maven settings.xml config for default Sonar db server

If you want to set a default Sonar configuration for all your Maven projects to run against, you can add your settings as a profile in the profiles section in your default settings.xml in either your ~/.m2 dir or your maven_install_dir/conf dir (depending which you’re using)

                <!-- MySQL -->


(Page views: 45)

Maven packaging notes

maven-dependency-plugin: Copy dependent jars into a /lib/ dir to be bundled with the package goal (note that you can’t have jars within jars and have them accessible on the classpath, so this just helps package the jars with your distribution):






(Page views: 9)

JSF 2.0 namespaces

Here’s the namespace declarations for the JSF 2.0 tags:

<h:html lang="en" xmlns="http://www.w3.org/1999/xhtml"

For JSF 2.2 the URLs have changed. See post here.

(Page views: 9)

Deploying a Maven-based web project from Eclipse

Here’s the problem: you start with a Web project in Eclipse, created via one of the Wizards. At some point you convert it to a Maven project, but when you deploy the project from Eclipse, your web content in /src/main/webapp is not deployed, because Eclipse is not aware of the Maven folder structure.

I’ve done this multiple times in the past and usually work out a way to build a ear/war and manually deploy it to my server or via a script instead, because I can’t work out how to get a converted project to deploy in Eclipse :-)

The magic to get this to work is to add the maven-war-plugin to your Maven pom.xml file:



(Page views: 59)