Archive for the ‘General’ Category
(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]
(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]
MultiException[java.lang.RuntimeException: Error scanning file]
Case
I run a project with JSF 2 / PrimeFaces 5 (BTW: it rocks!) / Spring 4 / Jetty 9 / Java 8:
[java]MultiException java.lang.RuntimeException: Error scanning file SummerBean.class, java.lang.RuntimeException: Error scanning entry …/SummerService.class from jar file:/…/spring-tier-1.0-SNAPSHOT.jar, java.lang.RuntimeException: Error scanning entry …/SummerServiceImpl.class from jar file:/…/spring-tier-1.0-SNAPSHOT.jar
at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:530)[/java]
Explanation
The error occurs because of a conflict on the JARs of ASM.
Fix
You have to override Jetty’s dependencies to ASM.
In Maven’s POM, amend Jetty plugin to force ASM versions:
[xml]<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>5.0.2</version>
</dependency>
</dependencies>
<!– … –>
</plugin>
[/xml]
Then it should work 😉
SizeLimitExceededException: the request was rejected because its size (…) exceeds the configured maximum
Stacktrace
On deploying a WAR in Tomcat:
[java]org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (128938160) exceeds the configured maximum (52428800)[/java]
Quick fix
Edit the file $CATALINA_HOME/webapps/manager/WEB-INF/web.xml
Replace the block
[xml] <multipart-config>
<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config> [/xml]
with:
[xml] <multipart-config>
<!– 200 MB max –>
<max-file-size>209715200</max-file-size>
<max-request-size>209715200</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
[/xml]
Mount a shared drive with VirtualBox
Case
You have to share some content between the host (eg: Linux Mint) and the resident (eg: Windows 7) systems, with Virtual Box.
Solution
- In the resident system, go to Virtual Box, then:
Machine
>Settings
> SharedFolders
> on the right:Add
> checkautomount
andpermanent
, browse to the folder, let’s sayD:\sharedFolder
- Launch the VM.
- Execute a terminal in host system:
- Grant rights of group
vboxsf
to usermint
:
sudo gpasswd -a mint vboxsf
- Create a “local” folder:
mkdir ~/sharedFolder
- Mount the folder
sharedFolder
on/home/
:
sudo mount -t vboxsf -o uid=1000,gid=1000 sharedFolder ~/sharedFolder
Conférence Devoxx: « 42 IntelliJ IDEA tips in 45 minutes »
JetBrains, le studio russe éditeur de notre IDE préféré IntelliJ IDEA, était présent en force cette année à Devoxx. Outre un stand où il était possible de discuter avec deux développeurs de l’IDE, JetBrains a animé deux conférences.
A vrai dire, j’étais un peu réticent à l’idée d’assister à la conférence de Hadi Hariri (@hhariri, blog): une conférence au titre similaire l’année dernière m’avait laissé sur ma faim, m’apprenant peu de chose. Le compère de Hadi m’a convaincu de faire l’effort. Eh bien je n’ai pas été déçu.
Hadi a présenté plusieurs dizaines de tips et raccourcis clavier. En voici quelques uns que j’ai appris durant la conférence:
- tout le monde connait le classique
Ctrl
–N
ouvrant une classe. L’astuce consiste, avecCtrl
–N
(et de manière similaire avecCtrl
–Shift
–N
) à rajouter “:<numéro de ligne>” en suffixe à la classe à ouvrir : celle-ci s’ouvrira au numéro de ligne indiqué, par exemple:Ctrl
–N
>CHM:12
ouvrira ConcurrentHashMap en ligne 12. - Désactiver la navigation bar (View > Navigation Bar). Cela permet, via un
Ctrl-Home
, d’afficher à tout instant la barre de navigation en restant dans la fenêtre d’édition. Ctrl-Shift-E
permet de restreindre l’application deCtrl-E
aux fichier récemment édités.Ctrl-Shift-F7
permet, dans le cas général, de mettre en surbrillance les occurrences d’un champ, d’une variable ou d’une méthode. En appliquantCtrl-Shift-F7
sur unreturn
ou unthrow
, respectivement tous les points de sortie de la méthode ou de levée d’exception seront surlignés.Shift-F4
permet d’externaliser une fenêtre, c’est-à-dire de la rendre flottante et indépendante du reste de l’IDE- Symétriquement à
Ctrl-W
qui étend la sélection,Ctrl-Shift-W
la réduit Ctrl-Alt-Shift-J
passe l’éditeur en mode multi-caret: ce mode permet d’effectuer des opérations sur plusieurs lignes en même temps, mais pas forcément sur la même colonne. Le mode colonne (Alt-Shift-Insert
) apparait ainsi comme une application restreinte du mode multi-caret.- Dans un fichier HTML, en tapant par exemple
table>tr>td
, IDEA complétera le code en<table><tr><td></td></tr></table>
(toutefois il semblerait que cette fonctionnalité soit liée au plugin Zen-coding). Shift, Shift
: c’est le “raccourci ultime” vers la recherche sur tout ce qui existe dans IDEA
En conclusion, IntelliJ IDEA confirme son statut de Rolls des outils de développement Java, dont la maitrise complète s’acquière par des années de pratique et d’exploration.
Conférence Devoxx: Introduction aux Google Glass
J’ai eu la chance d’assister à l’édition 2014 de Devoxx FR.
La première conférence que j’ai suivie était “Introduction aux Google Glass”, par Alain Régnier (@AltoLabs, +AlainRegnier), dont voici un résumé:
Alain fait partie d’un programme, les Google Glass Explorers, c’est-à-dire les heureux élus qui ont pu se procurer des paires de lunettes Google Glass. Théoriquement, seuls les résidents nord-américains peuvent souscrire au programme ; néanmoins, l’estimation du nombre de Google Glass circulant en France oscille entre 30 et 50 paires.
A mi-chemin entre des lunettes Star Trek et des scouters de Dragon Ball, les Google Glass ressemblent à des lunettes classiques dont l’une des branche est plus épaisse et dont un verre est surmonté d’un prisme et d’une mini-webcam. Le petit bijou de technologie embarque, sous le capot, de nombreux capteurs et connecteurs: visuel, sonore, bluetooth, wifi, et même infrarouge.
Les Google Glass affichent par défaut des informations de quatre types: texte, image, vidéo et une version limitée d’HTML. Elles sont contrôlables de plusieurs façons: à la voix (en lançant le mot magique “OK Glass!”), via un trackpad, une application “web” MyGlassWeb ou enfin une appli Android MyGlassMobile.
En tant qu’outil de développement, un Android Screen Monitor (un simple client ADB) permet d’afficher sur l’écran du PC ce qui est visible par la personne portant les Google Glass: en d’autres termes, le flux de la webcam sur lequel est superposé l’affichage du prisme.
Concernant le développement proprement dit, trois méthodes sont disponibles:
- Mirror API: les Glass communiquent avec un serveur hébergé par Google, qui redirige vers un serveur concret
- GDK: il s’agit d’un kit de développement similaire à celui d’Android
- WearScript: c’est une librairie, non-officielle, permettant de programmer les Glass en JavaScript
Alain a réalisé une démonstration d’utilisation des Glass. Avouons-le: c’est bluffant… En tant que développeur, les perspectives ouvertes par un tel objet connecté sont très enthousiasmantes! Le plus dur va encore être d’attendre que les Glass soient officiellement disponibles dans nos contrées européennes…
(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
.
(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.
“Apache Maven Dependency Management” by Jonathan Lalou, was published by Packt
Abstract
I am glad and proud to announce the publication of “Apache Maven Dependency Management”, by Packt.
Direct link: https://www.packtpub.com/apache-maven-dependency-management/book
Alternate locations: Amazon.com, Amazon.co.uk, Barnes & Noble.
On this occasion, I’d like to thank all Packt team for allowing me achieving this project.
What you will learn from this book
- Learn how to use profiles, POM, parent POM, and modules
- Increase build-speed and decrease archive size
- Set, rationalize, and exclude transitive dependencies
- Optimize your POM and its dependencies
- Migrate projects to Maven including projects with exotic dependencies
In Detail
Managing dependencies in a multi-module project is difficult. In a multi-module project, libraries need to share transitive relations with each other. Maven eliminates this need by reading the project files of dependencies to figure out their inter-relations and other related information. Gaining an understanding of project dependencies will allow you to fully utilize Maven and use it to your advantage.
Aiming to give you a clear understanding of Maven’s functionality, this book focuses on specific case studies that shed light on highly useful Maven features which are often disregarded. The content of this book will help you to replace homebrew processes with more automated solutions.
This practical guide focuses on the variety of problems and issues which occur during the conception and development phase, with the aim of making dependency management as effortless and painless as possible. Throughout the course of this book, you will learn how to migrate from non-Maven projects to Maven, learn Maven best practices, and how to simplify the management of multiple projects. The book emphasizes the importance of projects as well as identifying and fixing potential conflicts before they become issues. The later sections of the book introduce you to the methods that you can use to increase your team’s productivity. This book is the perfect guide to help make you into a proud software craftsman.
Approach
An easy-to-follow, tutorial-based guide with chapters progressing from basic to advanced dependency management.
Who this book is for
If you are working with Java or Java EE projects and you want to take advantage of Maven dependency management, then this book is ideal for you. This book is also particularly useful if you are a developer or an architect. You should be well versed with Maven and its basic functionalities if you wish to get the most out of this book.
Table of content
- Preface
- Chapter 1: Basic Dependency Management
- Chapter 2: Dependency Mechanism and Scopes
- Chapter 3: Dependency Designation (advanced)
- Chapter 4: Migration of Dependencies to Apache Maven
- Chapter 5: Tools within Your IDE
- Chapter 6: Release and Distribute
- Appendix: Useful Public Repositories
- Index