How to list all constraints in Oracle database

You can list all constraints and tables to which they are linked via this SQL statement: SELECT constraint_name, Decode(constraint_type, ‘C’, ‘Check constraint on a table’, ‘P’, ‘Primary key’, ‘U’, ‘Unique key’, ‘R’, ‘Referential integrity’, ‘V’, ‘With check option, on a view’, ‘O’, ‘With read only, on a view’, ‘H’, ‘Hash expression’, ‘F’, ‘Constraint that involves […]

Watch out for bad logging: Apache Commons Logging

If you (or your team) use Apache Commons Logging as a logging framework, you may encounter an incorrect way how you log your exceptions (regardless of the logging level – WARN, ERROR, …). It looks like this: try { … some code … } catch (Exception e) { log.error(e); } // or try { … […]

Messages are NOT processed even if workers are available

We’ve application which synchronizes customers data at certain time intervals. For that we’re using JMS (HornetQ) with Java EE MDB’s (workers) as these synchronizations are asynchronous and running in the background. One JMS message contains one customer ID. When JMS message is picked up by MDB instance (worker) from queue then it starts syncing data […]

How to run ClamAV as Windows Service

ClamAV (Clam AntiVirus) is a free, cross-platform and open-source antivirus software toolkit which can detect many types of malicious software. When you’re building Java application which needs antivirus then ClamAV is a really good choice. You can send a byte array via API and check it for viruses. For a long time, we operated ClamAV […]

How-to: Obtain Thread Dump and Heap Dump on JBoss/WildFly

Sometimes you need to analyze unexpected behavior on application server. Out of memory, EJB pool exhaustion or deadlock are one of many problems with which you can often met. And not always the server log will help you. When log is empty, but application shows signs of errors (is slow or maybe even stuck) you […]

How to migrate table, index and LOB column to another tablespace

Recently we had to migrate multiple tables, indexes and lob columns from one tablespace to another. We have prepared scripts to generate necessary ALTER statements. First script is for tables: /* Generate script to alter table from one tablespace to another */ SELECT ‘ALTER TABLE ‘ || OWNER || ‘.’ || SEGMENT_NAME || ‘ MOVE […]

Synchronizing @Schedule method which runs on multiple JBoss servers

Recently we’ve faced a problem of how to synchronize a method with the @Schedule annotation (java.ejb.Schedule) which runs on multiple JBoss servers. Method with this annotation is used as the timeout callback method. It’s simply a method that’s invoked when a timer fires. An analogy is an alarm clock that starts ringing at a certain […]

Injecting EJBs from JAR to WAR using CDI

Recently I faced a problem of how to use @Inject annotation in one of the CDI Beans. Our project has a following structure: Business logic: JAR which packs EJB, JPA Entity Classes, … User interface: WAR which packs CDI Beans, images, XHTMLs, … Technically what I call JAR is actually EJB-JAR, because it packs EJBs, but […]