Posts

Showing posts from February, 2009

How to write a simple EJB

A simple EJB contains remote/local interface, and a class which implements that interface along with an optional configuration file (XML). For the following example, JBoss Application Server 4.2.3.GA has been used where the EJB would be deployed and tested. You have to add the following external JARs also from the JBoss Application Server client and server libraries to be able to import the javax.ejb.* libraries and the @Remote Annotation: - From ...\jboss-4.2.3.GA\client\: Add jbossall-client.jar and jnp-client.jar . - From ...\\jboss-4.2.3.GA\server\default\lib\: Add ejb3-persistence.jar and jboss-ejb3x.jar Now, let's start writing the EJB: Remote/Local Interface: Consider the following interface: import javax.ejb.*; @Remote public interface MyRemoteInterface{ public String SayHello(String name); } A Bean implementation class: Now, write the implementation of the interface as follows: import javax.ejb.*; @Stateless public class ...

How to Deploy JBoss Application Server on NetBeans

First of all, you need to download the JBoss Application Server from JBoss Downloads Website: http://www.jboss.org/jbossas/downloads/ . Unzip the .zip file into a location on your hard drive. For instance, c:\jboss-4.0.4.GA\ . Now do the following: Open NetBeans and go to Services on the left Pane of the IDE. Right click on drivers, and select 'New Driver'. A window titled 'New JDBC Driver' will appear, Click on 'Add' Button. Browse to ...\jboss-4.0.4.GA\server\default\lib and select 'hsqldb.jar'. The Driver class should be "org.hsqldb.jdbcDriver" and choose a name for the Driver. Before making a connection to the Database, you have to make some configurations: Environment Variables: Create a variable named "JBOSS_HOME" and set the value pointing to the JBoss Installation Directory, i.e. ..\jboss-4.0.4.GA Add or append "...\jboss-4.0.4.GA\server\default\lib\hsqldb.jar" to the CLASSPATH variable. These environment variabl...