Resolving HornetQ issues with two JBoss 6 instances in one network
Posted by itellity in Distributed Computing, Enterprise Java, Uncategorized on July 19, 2011
If you have the following warning in your JBoss 6 logs:
[quote]
WARN [org.hornetq.core.cluster.impl.DiscoveryGroupImpl] There are more than one servers on the network broadcasting the same node id. You will see this message exactly once (per node) if a node is restarted, in which case it can be safely ignored. But if it is logged continuously it means you really do have more than one node on the same network active concurrently with the same node id. This could occur if you have a backup node active at the same time as its live node.
[/quote]
You just have to delete the contents of the /server//data/hornetq/ directory, as you most probably will be using a copy of the exactly the same instance of the JBoss installation that’s causing those warnings. At startup, HornetQ geneartes the node ID and stores it in a file. If you copy that file and the JBoss installation surrounding it, it won’t regenerate the node ID and you will have two servers with the same node ID on the network, hence the pesky warning in your log files.
Migrating to JBoss 7
Posted by itellity in Uncategorized, Enterprise Java on July 15, 2011
For those who have an existing JBoss 4/5/6 installation, migrating to JBoss 7 will take slightly more time, as the new archicture of JBoss has a completely new directory layout and configuration mechanism.
For starters, you should set up your datasources. This is described in the following article:
http://community.jboss.org/wiki/DataSourceConfigurationInAS7
when you’ve done that and setup your MySQL or Oracle datasource bindings and modules, you’ll have to configure your application for usage in a JBoss 7 / JEE 6 Environment.
First of all, you’ll have to check your persistence.xml and your references to see if they comply with the new JEE 6 specs. This is explained in depth in the following section of the JBoss 7 guides:
https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-JNDIPortableJNDISyntax
Next, you will have to check your application for external dependencies, i.e. all libs that were formerly deployed to the /server/<instance>/lib directory need to be installed as modules and declared as dependencies in the
MANIFEST.MF file
Depending on which components your application uses, you may need to add one or more dependencies to this file. There is more information about these dependencies in the following paragraphs.
NOTE: If you modify this file, make sure to include a newline character at the end of the file.
If you need to port your Resteasy application parts, please observe this excellent and short tutorial:
http://blog.xebia.com/2011/07/developing-restful-applications-on-jboss-as-7/
Configuring Postfix as a smarthost for authenticated mail relaying
Posted by itellity in Distributed Computing, Uncategorized on July 14, 2011
This document describes 5 easy steps to setup your Postfix email server as a smarthost to relay on a given mail relay server for all outgoing mail.
1. Create a password maps file (it assigns username/passwords to specified mail servers). You can choose any name, let’s say it is /etc/postfix/relay_passwd. It’s content should be as follows:
relay.mail.com USERNAME:PASSWORD
Note: Replace USERNAME and PASSWORD with your mail relay username and PASSWORD.
2. Set proper permissions for that file:
# chown root:root /etc/postfix/relay_passwd
# chmod 600 /etc/postfix/relay_passwd
3. Create hash from maps file (remember to do it each time you change your maps file):
# postmap /etc/postfix/relay_passwd
4. Configure your /etc/postfix/main.cf:
relayhost = [relay.dnsexit.com]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_passwd
smtp_sasl_security_options =
Note: If your ISP blocks outgoing port 25. You can choose to use alternative SMTP ports by appending the port at the end:
relayhost = [relay.mail.com]:26
5. Reload or restart your postfix:
# /etc/init.d/postfix restart
Getting rid of SocketException: Broken pipe with Quartz and MySQL on JBoss
Posted by itellity in Distributed Computing, Enterprise Java on May 18, 2011
If you’re using Quartz on JBoss and configured the full Quartz package (with database scheduled jobs) instead of the lightweight in memory Quartz bundled with the vanilla installation of JBoss, you’ll certainly encounter the problem of
ava.net.SocketException
MESSAGE: Broken pipe
STACKTRACE:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2635)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554)
in your log files after eight hours of inactivity.
If you start googling, you’ll find hundreds of suggestions, such as appending autoreconnect=true to the datasource URL in your quartz-ds.xml, whihc as such is important, but unfortunately wont solve the problem. The solution is described in this excellent post: http://amitcodes.wordpress.com/2008/07/26/16/. Applied to our configuration, you’ll need to add the following lines to your quart-service.xml:
org.quartz.dataSource.QUARTZ_NO_TX.validateOnCheckout = true
org.quartz.dataSource.QUARTZ_NO_TX.validationQuery = select 1
If you’re looking on guidance to install Quartz with database support on JBoss, check this post: http://zunkthoughts.blogspot.com/2008/12/quick-howto-quartz-with-jboss.html
Extracting class from a type parameter in Java
Posted by itellity in Enterprise Java, Uncategorized on May 18, 2011
it’s simple. Observe the following example:
public class GenericClass<T> {
private Class<T> typeOfT;
@SuppressWarnings("unchecked")
public GenericClass() {
this.typeOfT = (Class<T>)
((ParameterizedType)getClass()
.getGenericSuperclass())
.getActualTypeArguments()[0];
}
Configuring Microsoft Exchange with Mac Clients
Posted by itellity in Digital Worker on May 4, 2011
If you happen to work in or have a company with several Mac clients and an Microsoft Exchange Server, you’ll invariably run into the problem that your Mac clients can’t really connect to your exchange server without using Office Entourage (terrible product) or the new Outlook 2011. On top of it, if you restrict Exchange exposure to the outside world to outlook web access, the latter approach will not work.
If you want to still have access to your calendars without resorting to the many solutions involving Google Calendar Sync, here’s what we found out:
- Mail.app: in order to access your emails, choose Exchange IMAP instead and uncheck the configure iCal option
- iCal.app: install DavMail from http://davmail.sourceforge.net/index.html. This component simulates a CalDav Server and connects to Outlook Web Access, thus acting as a gateway. You can run it on your client, provided you have a Java VM installed or on a JEE compatible Server.
IPhones and Androids work fine without these settings, as they use Microsoft ActiveSync.
Regexp Validation frontends
Posted by itellity in Enterprise Java on March 11, 2011
Here some useful links when workuing with RegExp in Java:
Memory optimization in multithreaded applications
Posted by itellity in Distributed Computing, Enterprise Java, Uncategorized on March 11, 2011
Very interesting Post about Java Reference usage: http://www.kdgregory.com/index.php?page=java.refobj
Usage of WeakHashmaps as object caches: http://www.codeinstructions.com/2008/09/weakhashmap-is-not-cache-understanding.html
Configuring mod_proxy for JIRA
Posted by itellity in Distributed Computing, Enterprise Java on January 28, 2011
If you need to configure a JIRA Standalone to run on Port 80 using an Apache which already is configured to do other tasks, you’ll need to observe the following steps.
- Install mod_proxy and mod_proxy_ajp for apache 2.2.
- Configure Apache’s httpd.conf using the following params:
ProxyRequests Off
Order deny,allow
Allow from all
ProxyPass /browse ajp://localhost:8089/browse
ProxyPassReverse /browse ajp://localhost:8089/browse
ProxyPass /secure ajp://localhost:8089/secure
ProxyPassReverse /secure ajp://localhost:8089/secure
ProxyPass /issues ajp://localhost:8089/issues
ProxyPassReverse /issues ajp://localhost:8089/issues
ProxyPassReverse /s ajp://localhost:8089/s
ProxyPass /rest ajp://localhost:8089/rest
ProxyPassReverse /rest ajp://localhost:8089/rest
ProxyPass /login.jsp ajp://localhost:8089/login.jsp
ProxyPassReverse /login.jsp ajp://localhost:8089/login.jsp
ProxyPass /plugins ajp://localhost:8089/plugins
ProxyPassReverse /plugins ajp://localhost:8089/plugins
ProxyPass /images ajp://localhost:8089/images
ProxyPassReverse /images ajp://localhost:8089/images
ProxyPass /images ajp://localhost:8089/charts
ProxyPassReverse /images ajp://localhost:8089/charts
Oracle Time Zone Conversion
Posted by itellity in Uncategorized on January 24, 2011
I’ll elaborate this later on, but if you ever encounter the problem of having to comvert a UTC/GMT time to a TimeZone with Daylight Saving (or the other way around), this statement will do:
select to_char(FROM_TZ(CAST(c.creation_date AS TIMESTAMP), ‘Europe/Berlin’)
AT TIME ZONE ‘GMT’,'DD.MM.YYYY HH24:MI:SS’) as creation_date From CREDIT_CARD c
Source TZ: Europe/Berlin
Target TZ: GMT
Here’s the reference link:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1007699