Posts

Showing posts from September, 2009

Database sharding

Shared nothing instances www.codefutures.com highscalability.com

Mocks

Mock Comparison Growing Object-Oriented Software, Guided by Tests jMockit jMock , Mockito EasyMock PowerMock

REST

Restlet Resources Swagger

Java Round Robin Graphing

JRobing-MRTG

JBoss 5

Browse the JNDI tree view In a browser: Connect to http://localhost:8080 or http://localhost:8080/web-console or http://localhost:8080/jmx-console In the Web Console: Open: System : JMX MBeans : jboss : jboss:service=JNDIView In the third/last table click the 'Invoke' button on the list row Or in the JMX Console: Under the jboss section click on the 'service=JNDIView' link In the third/last table click the 'Invoke' button on the list row DO NOT click on jboss.deployment and select 'id="jboss:service=JNDIView",type=Component' It does not have the facilities to list the JNDI tree view. Admin Console http://localhost:8080/admin-console Default username: admin, password: admin Converting to JBoss 5 info: JBoss 5 is strict in validating xml. The persistence.xml needs to be changed from: <?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="titan"> . . . TO

JDBC debugging

log4jdbc * P6Spy most well known, not recently updated * Craftsman Spy not recently updated * JAMon (Java Application Monitor) comprehensive app monitor and API, includes JDBC/SQL * JdbcProxy can emulate another JDBC driver to test the app without a database. * LogDriver

Continuous Integration

Hudson

JAXB

Mapping your favorite class

Eclipse

Project .classpath

XML - Russian Doll vs. Salami Slice vs. Venetian Blind

XML Schemas: Best Practices

Hibernate configuration files

hibernate.properties and hibernate.cfg.xml perform the same configuration functions, if hibernate.cfg.xml exists it takes precedence over hibernate.properties. The configurations can include Datastore, SessionFactory, Connection Pool, Transactions, and Cache Provider. Much if not all of this can also be specified in the persistence.xml and the *-ds.xml. Generally the persistence.xml specifies only the persistence unit name, jndi-name, mode (create, drop, etc.) for an EE application and everything in a standalone application. Generally the *-ds.xml specifies the data source connection parameters, jdbc url, driver class, credentials, connection test parameter, provider type (Oracle, MySQL, etc.). Generally the hibernate.cfg.xml specifies the others. hibernate.cfg.xml is placed in WEB-INF/classes persistence.xml is placed in META-INF in jar with entity beans Hibernate Quickly

Eclipse Remote System Explorer Plugin

Like winscp for Eclipse: Remote System Explorer (RSE) • remote file systems through SSH, FTP or dstore agents (seamless editing of remote files including remote search and compare), • remote shell access (compiling with error navigation), • remote process handling through dstore agents, and remote debugging through CDT / gdb /

GC Tuning

Sun's VM Garbage Collection Tuning documentation Sun tuning presentation GC log format Garbage Collector Visualization

Remote JConsole and VisualGC

To connect visualgc remotely you need to be running jstatd on the server to be monitored. Create a jstatd.all.policy containing: grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission; }; Set and export the JAVA_HOME environment property and start jstatd with: nohup jstatd -J-Djava.security.policy=jstatd.all.policy > jstatd.out 2>jstatd.err & The default port is 1099. Either get the pid from the server or start JConsole to get it. In JConsole int Remote process enter server:port and a username and password if you set authentication to true below. Ah yes, you will have to have started the Java process with the following environment (but should be using JConsole for monitoring and debugging anyway): -Dcom.sun.management.jmxremote.port=11099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false When JConsole starts, click on the VM Summary tab. This shows you many det

EE5 Web Service - Maven + Eclipse + JBoss 5

In Eclipse Create the project: File : New : Other : Maven Project Uncheck create a simple project (skip archetype selection) Click Next Select Catalog: Internal Double-click maven-archetype-webapp Enter Group Id: com.company.xxx Enter Artifact Id: someName Click Finish Set the Java version: Open the pom.xml Add the following: . . . <build> <finalName>someName</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project> Create the artifacts: Right click on the project name in Package Explorer Select New : Source Folder Enter src/main/java Click Finish Right click on the new source folder src/main/java Select New : Package Enter a new package name or

DocBook format

DocBook XML is a library of standard XML tags you can use to write stylesheets for generating other output like HTML, PDF, etc. Build DocBook XML in Eclipse

Diagnosing EE/System problems

Check the following: (order depends on issue) JVM - JConsole (memory, cpu utililzation, threads, deadlocks) - JStack (blocking, locks, what are threads doing) or kill -3 Logs - Load Balancer log - Access Log - Query Log - GC log - been burned by this one twice - Server logs (JBoss, server, error, etc.) - Log4j logging latency - use async appenders Virtualization issues (VMWare) - OS scheduling latency - Network latency - Filesystem latency OS stats - top - ntop - iostats External System Latency - databases - AD - EMail - MOM/JMS - Web Services - network storage - etc.

Import cert into Java keystore

from jdk.X.X.X/jre/lib/security keytool -import -file some.cert -keystore cacerts default password: changeit