How to solve “javax.naming.Reference cannot be cast to javax.naming.Reference cannot be cast to ..”

This error means that the interface javax.naming.Reference cannot be resolved. It can happen when you are trying to lookup a component like an EJB or a Datasource from the JNDI. It is commonly caused by two reasons: You are missing some classes in client classpath (Verify that you have jbossall-client.jar in the classpath). You are … Read more

How to restart JBoss AS ?

This article has been written for JBoss AS 5 and is now obsolete. Please check this tutorial to learn how to start/stop/restart WildFly or JBoss EAP: How to Start, Stop and Restart WildFly One not well known option of the shutdown command is the -e option.If you issue the shutdown with the -e option: … Read more

How to solve Classloader issues in JBoss 4 and 5

By default JBoss 4 and JBoss 5 uses a flat class loading model that avoids the need to redundantly include classes in different layers.  WAR files would only have the web contents and servlets, EJBs their interfaces, implementations and types, etc. From 4.0.2 JBoss has changed to the Servlet spec classloading model, i.e. it uses … Read more

How to create multiple instances of an Mbean?

  Supposing you need two instances of an MBean, let’s say one for the client and one for the server. The main problem is that the objectName must be unique but you can hack it by adding an id for each MBean. Here’s an example: <?xml version=”1.0″ encoding=”UTF-8″?> <server>   <mbean code=”sample.HelloWorldService” name=”sample:service=HelloWorld,id=1″>     <attribute … Read more