Recent Posts
Archives

Archive for the ‘long tweets’ Category

PostHeaderIcon (long tweet) How to display / modify Oracle XDB port?

Oracle XDB port runs by default on port 8080… which is quite an issue for Java web developpers, because of the collision with default port used by servlet engines such as Tomcat and Jetty.

To display Oracle XDB port, run:
[sql]select DBMS_XDB.GETHTTPPORT from dual;[/sql]

To change it (for instance to set it on port 9090), run
[sql]exec DBMS_XDB.SETHTTPPORT(9090);[/sql]

PostHeaderIcon (long tweet) Could not find backup for factory javax.faces.context.FacesContextFactory.

Case

On deploying a JSF 2.2 / Primefaces 5 application on Jetty 9, I got the following error:
[java]java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.[/java]

The issue seems linked to Jetty, since I could not reproduce the issue on Tomcat 8.

Quickfix

In the web.xml, add the following block:
[xml] <listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>[/xml]

PostHeaderIcon (long tweet) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB’ at line 1

Stacktrace

[java]org.hibernate.tool.hbm2ddl.SchemaExport – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB’ at line 1[/java]

Quick fix

In JPA configuration, replace:
datasource.dialect = org.hibernate.dialect.MySQLInnoDBDialect
with:
datasource.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
Actually, Java driver for MySQL 5.5+ is not backward compatible with the SQL dialect MySQLInnoDBDialect.

PostHeaderIcon (long tweet) Run MS-DOS command as super user

How to run a MS-DOS command terminal with administrator priviledges, in Windows 7?
Let’s say you need execute cmd with the account admin: launch runas /user:admin cmd.
Windows will ask you to enter the admin password and then will open a CMD prompt in admin mode.

PostHeaderIcon (long tweet) Glassfish / Unsupported major.minor version 51.0

Case

On launching Glassfish 4 under Windows, I got the following error:

[java]asadmin.bat start-domain
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain : Unsupported major.minor version 51.0[/java]

Quickfix

Glassfish 4 is JEE6-compatible, therefore run Glassfish 4 with JRE 7 instead of JRE 6.

As a reminder, here is the list of majors/minor versions:
[java]J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45[/java]

PostHeaderIcon (long tweet) Error injecting: org.codehaus.groovy.eclipse.compiler.GroovyEclipseCompiler

Case

On building a Groovy project with Maven, I got the following error:
[java]Error injecting: org.codehaus.groovy.eclipse.compiler.GroovyEclipseCompiler
java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/CompilerResult[/java]

Quick fix

Downgrade maven-compiler-plugin to version 3.0 instead of branch 2.3.X.

PostHeaderIcon How to know which versions of Xerces and Xalan are run in the JDK?

Run this command:

[java]java com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck[/java]

PostHeaderIcon (long tweet) How to make ChromeOS work in VirtualBox without Wifi?

Case

How to make ChromeOS work in VirtualBox without Wifi, ie on an ethernet/wired local network, or even offline?

Quick Fix

Shutdown the VM > Select it > Settings > Network > Advanced > Adapter Type > select “Paravirtualized Network (virtio-net)”

PostHeaderIcon (long tweet) Virtual Box / PAE processor

Case

On booting ChromeOS Vanilla within Virtual Box, I got the following error:
[java]This kernel requires the following features not present on the CPU: pae
Unable to boot – please use a kernel appropriate for your CPU.[/java]

(Actually, the problem occured with ChromeOS but may have appened with another system)

Quick Fix

In Virtual Box, select the VM > Settings > Processor > check “Enable PAE/NX”.

PostHeaderIcon (long tweet) A story of return in try/catch/finally

A short reminder: in a try/catch/finally section, the block in the finally is always executed. “Always” means “even if a return statement is reached in the try or catch“.

A short piece of code shows more than a long speech. The following JUnit test ends with no error:
[java]package com.stepinfo.poc.cartography;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;

/**
* Created with IntelliJ IDEA 12 "Leda" CE
* User: Jonathan LALOU
* Date: 08/Apr/13
* Time: 22:41
*/
public class TestTryCatchFinally {

public static final String TRY = "try";
public static final String CATCH = "catch";
public static final String FINALLY = "finally";

private String tryVersusFinally() {
try {
return TRY;
} catch (Exception e) {
return CATCH;
} finally {
return FINALLY;
}
}

private String catchVersusFinally() {
try {
throw new RuntimeException();
} catch (Exception e) {
return CATCH;
} finally {
return FINALLY;
}
}

@Test
public void testTryFinally() {
assertNotSame(TRY, tryVersusFinally());
assertEquals(FINALLY, tryVersusFinally());
}

@Test
public void testCatchFinally() {
assertNotSame(CATCH, tryVersusFinally());
assertEquals(FINALLY, catchVersusFinally());
}
}
[/java]