import org.eclipse.persistence.logging.AbstractSessionLog; import org.eclipse.persistence.logging.SessionLog; import org.eclipse.persistence.logging.SessionLogEntry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Slf4JEclipseLinkSessionLogger extends AbstractSessionLog implements SessionLog { public static final Logger LOG = LoggerFactory.getLogger(Slf4JEclipseLinkSessionLogger.class); @Override public void log(SessionLogEntry sle) { switch (sle.getLevel()) { case SEVERE: LOG.error(buildLogMessage(sle)); break; case WARNING: LOG.warn(buildLogMessage(sle)); break; case INFO: LOG.info(buildLogMessage(sle)); break; default: LOG.debug(buildLogMessage(sle)); } if (sle.hasException()) { LOG.error("Exception in EclipseLink", sle.getException()); } } private String buildLogMessage(SessionLogEntry sle) { StringBuilder b = new StringBuilder(); b.append("message=").append(sle.getMessage()); if (sle.getSession() != null && sle.getSession().getName() != null) { b.append("\n sessionName=").append(sle.getSession().getName()); } if (sle.getThread() != null && sle.getThread().getName() != null) { b.append("\n threadName=").append(sle.getThread().getName()); } if (sle.hasException()) { b.append("\n Exception=").append(sle.getException().getMessage()); } return b.toString(); } }
In the past this blog should be for Oracle ADF. but since I changed my job and I don't work with ADF any more this blog is about anything for programming with JAVA
Go to archiveFreitag, 30. März 2012
EclipseLinkSessionLogger with SLF4J
Here is the source code for your own Slf4JEclipseLinkSessionLogger. I found this in one mailing list.
Montag, 26. März 2012
Apache Maven Fluido Skin
In the apache announce list they developers from maven announced that the maven skin Fluido has a new version. So I tried this skin out again. It looks some one more fancy then other skins but still version 1.2 has a bug in the breadcrumb section of generated html files.
To enable the new skin open your
After the body section you add these tag’s
For more information what you can do check out the skin page Maven Fluido Skin
Now to come again to my problem: When you do not define a breadcrumb in the
how it should look like:
how it is without breadcrumbs:
To have it nice we decided in our team to use the main items from the menu as bread crumbs.
The javascript which shows the current place [path] of your folder is still missing by default.
To enable the new skin open your
site.xml
file.After the body section you add these tag’s
org.apache.maven.skins maven-fluido-skin 1.2
For more information what you can do check out the skin page Maven Fluido Skin
Now to come again to my problem: When you do not define a breadcrumb in the
site.xml
the layout is destroyed.how it should look like:
how it is without breadcrumbs:
To have it nice we decided in our team to use the main items from the menu as bread crumbs.
The javascript which shows the current place [path] of your folder is still missing by default.
Donnerstag, 22. März 2012
Problem with Pagination and Ordering in JPA
Some days back we implemented ordering for different columns. There we faced the problem that result what is displayed is not the same as data is in the database. So we all thought we do not set the pagination parameters correctly or it is a problem in eclipse link.
I googled a little bit around. The problem is not pagination or eclipse link. The problem is how pagination works at all. Even when you fire the SQL directly to the database the problem occurs.
You have to use a unique id as well for ordering when pagination is used that the database will always sent the data back in the correct order.
see also Bug on using pagination on Oracle?
I googled a little bit around. The problem is not pagination or eclipse link. The problem is how pagination works at all. Even when you fire the SQL directly to the database the problem occurs.
You have to use a unique id as well for ordering when pagination is used that the database will always sent the data back in the correct order.
see also Bug on using pagination on Oracle?
Dienstag, 20. März 2012
Speed up compile time for GWT
Compilation takes long time for GWT projects. The reason for it is the permutation for different browsers.
Permutation means the GWT compiler generates JS and HTML files for different browser by default.
This can be really annoying when you are developing and you only want to see the result in the IE or Firefox
To enable permutation for only one browser do the the following:
Open file
add this line:
Some time measurements from our GWT project
only one browser:
- GWT compilation time: 39.436s
- total time for
all browsers:
- GWT compilation time: 58.435s
- total time for
20 seconds are worth the optimization.
You only have to keep in mind to NOT commit these changes to your source code repository when the real application should run on different browsers.
Permutation means the GWT compiler generates JS and HTML files for different browser by default.
This can be really annoying when you are developing and you only want to see the result in the IE or Firefox
To enable permutation for only one browser do the the following:
Open file
XXXXX.gwt.xml
of your application.add this line:
possible values are:
ie6
= Internet Explorer 6ie8
= Internet Explorer 8ie9
= Internet Explorer 9gecko1_8
= Firefoxsafari
= safari and chromeopera
= opera
This would generate files for IE8 and Firefox.
Some time measurements from our GWT project
only one browser:
- GWT compilation time: 39.436s
- total time for
mvn clean install
in GWT project: 1:35.403sall browsers:
- GWT compilation time: 58.435s
- total time for
mvn clean install
in GWT project: 1:59.730s20 seconds are worth the optimization.
You only have to keep in mind to NOT commit these changes to your source code repository when the real application should run on different browsers.
Freitag, 16. März 2012
pretty format a xml string
do you get most of the time xml not in a human readable format?
this snippet can help:
this snippet can help:
private String formatXml(String xml) { try { Transformer serializer = SAXTransformerFactory.newInstance().newTransformer(); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source xmlSource = new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes()))); StreamResult res = new StreamResult(new ByteArrayOutputStream()); serializer.transform(xmlSource, res); return new String(((ByteArrayOutputStream) res.getOutputStream()).toByteArray()); } catch (Exception e) { return xml; } }
Donnerstag, 15. März 2012
Try to write more - promise
Hi all
I know I stopped writing last year in April.
I try to write now more constantly! Promise! :-)
I know I stopped writing last year in April.
I try to write now more constantly! Promise! :-)
Mittwoch, 14. März 2012
How to configure tomcat to use slf4j and logback
This section explains how to configure Tomcat to use slf4j rather than
First of all it is nothing special because it will use the log4j over slf4 and logback.
java.util.logging
for all Tomcat's internal logging.First of all it is nothing special because it will use the log4j over slf4 and logback.
- Download
tomcat-juli.jar
andtomcat-juli-adapters.jar
that are available as an "extras" component for Tomcat. See Additional Components documentation for details. - Put the following jars into
$CATALINA_HOME/lib
.- log4j-over-slf4j-1.6.4.jar
- logback-classic-1.0.0.jar
- logback-core-1.0.0.jar
- slf4j-api-1.6.4.jar
- tomcat-juli-adapters.jar
- Replace
$CATALINA_HOME/bin/tomcat-juli.jar
withtomcat-juli.jar
from "extras" - Delete
$CATALINA_BASE/conf/logging.properties
to prevent java.util.logging generating zero length log files. - Add
logback.xml
into$CATALINA_HOME/lib
.
Example:<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<!--
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
-->
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>