########################################################################## # Jonas (Java Open Application Server) Notes # # Anuradha Weeraman, 03 April 2004 # # $Id: jonas-notes.txt,v 1.1 2004/06/02 21:17:53 anuradha Exp $ # ########################################################################## -- Running the first session bean $JONAS_ROOT/examples/src$ ant install $JONAS_ROOT/examples/src$ jonas start $JONAS_ROOT/examples/src$ jonas admin -a sb.jar $JONAS_ROOT/examples/src$ jclient sb.ClientOp You should get >> Create a bean Start a first transaction First request on the new bean Second request on the bean Commit the transaction Start a second transaction Rollback the transaction Request outside any transaction ClientOp OK. Exiting. ---------- -- Configuring a MySQL DataSource 1) Install MySQL 2) Set MySQL root password and create a database (example db_jonas) 3) Edit $JONAS_ROOT/conf/MySQL.properties 4) Edit $JONAS_ROOT/conf/jonas.properties and add the following property jonas.service.dbm.datasources MySQL 5) Modify $JONAS_ROOT/bin/unix/config_env and set the location of the MySQL JDBC driver classes. 6) Start jonas. The datasource should be bound to jdbc_1 by default. To check, jonas admin jndinames ---------- -- Turn off the web container service If you want to run Jonas without tomcat or jetty, edit $JONAS_ROOT/conf/jonas.properties and remove 'web' from the property jonas.services ---------- -- Autoloading ejbs This can be done by either placing the jar files in the autoload directory of 'ejbjars' or specifying them in a comma separated list for the jonas.service.ejb.descriptors in $JONAS_ROOT/conf/jonas.properties file. ---------- -- Jonas BASE The configuration and deployments can be maintained separately from the Jonas application itself. For this, create a new directory and point the environment variable JONAS_BASE to it. If the variable JONAS_BASE doesn't exist, it will default to JONAS_ROOT. From $JONAS_ROOT, ant create_jonasbase This will create the proper directory structure. Perform configuration changes on JONAS_BASE and start Jonas. Deployments should be made to JONAS_BASE instead of JONAS_ROOT. ---------- -- Multiple Jonii To start multiple Jonas servers : jonas -n server1 start jonas -n server2 start jonas -n server1 admin jonas -n server2 admin jonas -n server1 stop jonas -n server2 stop By default the name of the server is 'jonas'. There might be issues when sharing the JNDI and one server is downed, some resources such as datasources that might be used by the other server might get closed. Don't know how to overcome this yet. ---------- -- Check configuration To check if the jonas configuration is correct : jonas check ---------- -- Add to Jonas Server Classpath To append to the Jonas server classpath, edit $JONAS_ROOT/unix/bin/config_env and add : CLASSPATH=$SPS$CLASSPATH At the very end. ---------- -- JNDI To make changes to jndi, edit $JONAS_BASE/conf/carol.properties. As of 3.3.2, the available protocols are : JRMP, RMI/IIOP, JEREMIE and CMI The default is JRMP. If you wish to use RMI/IIOP, then it has to be reflected in carol.properties and you need to run 'ant installiiop' from $JONAS_ROOT directory. This will result in a choice between rmi/jrmp, rmi/iiop or cmi. Also, remember this? # If true, local call with jrmp are optimized. If you get "ClassCastException # with 2 beans in different jars, you should set it at "false". carol.jvm.rmi.local.call=true ---------- -- Admin To get a list of beans registered in Jonas directly from the commandline : jonas admin -l To see the registered jndi names : jonas admin -j ---------- -- GenIC When using GenIC, the Jonas deployment tool, the protocols for which the remote invocation stubs should be created can be specified, either in the command line itself such as : GenIC -protocols jrmp,jeremie,iiop Or in the JOnAS ejbjar ANT task : ---------- -- Logging Jonas logging system is based on Monolog and can be configured 1) By modifying $JONAS_BASE/conf/trace.properties 2) Dynamically using jonas admin or JonasAdmin Monolog is based on Log4J and has two handlers configured by default : tty - outputs to console, with no headers logf - output to a file If the output file name is "automatic" monolog will log to : $JONAS_BASE/logs/-.log To send the logs to both the console and a file : handler.logf.output /tmp/jonas.log or handler.logf.output automatic logger.org.objectweb.jonas.handler.0 tty logger.org.objectweb.jonas.handler.1 logf ---------- -- Class loader hierarchy If a library is required, add it to $JONAS_BASE/lib/ext or $JONAS_ROOT/lib/ext. The former will be loaded first. This will be part of the bootstrap class loading phase. Each EAR will have its own class loader, inherited from the bootstrap class loader and will contain a class loader for all the EJBs. The WAR classloader will in turn be inherited from the EJB classloader and will therefore not require to have the EJB jars in WEB-INF\lib. Sometimes the WAR will have classes which it will want to override the rest with. In such a scenario, the java2-delegation-model should be set to false in jonas-web.xml and the WAR will search for classes in its own repository before resorting to the parent classloader. ---------- -- Services Currently (as of 3.3.2) available services : registry : JNDI, automatically launched before all the other services. ejb : the EJB container web : the WEB container (Servlets and JSP, provided by either Tomcat or Jetty) ear : The EAR service ws : support for WebServices. jmx : needed to administer Jonas servers, current implementations are : - the Sun Reference implementation - MX4J security : used for enforcing runtime security resource : needed by resource adapters conforming to JCA jtm : the transaction manager. Currently the only mandatory service. dbm : the database service for access to RDBMS. jms : for application components that use the JMS Api. Required for MDBs. mail : required for application components that need to send e-mails. Currently its not possible to launch a service after start-up. The services will be loaded in order, so the following constraints will have to be kept in mind. * jmx must precede all other services in the list (except registry) in order to allow the management of these services. * jtm must precede the following services: dbm, resource, and jms. * security must be after dbm, as it uses datasources. * the services used by the application components must be listed before the container service used to deploy these components. For example, if the application contains EJBs that need database access, dbm must precede ejb in the list of required services. ---------- -- Registry There are several registry launching modes, configurable via jonas.service.registry.mode in jonas.properties: collocated : save JVM as Jonas remote : must be launched before Jonas in different JVM automatic : default, same JVM as Jonas The port number can be configured in carol.properties. ---------- -- Web Container if $JETTY_HOME or $CATALINA_HOME is not set, the web container will not be started and a warning will be displayed. WAR files will reside in $JONAS_BASE/webapps/. Web applications can be made to load at start time by specifying them in a comma separated list for the jonas.service.web.descriptors property in jonas.properties. The webapp can be exploded in the webapps\autoload directory for ease of development. This can be turned off during production. ---------- -- WebServices Currently (3.3.2) only the Axis implementation exists and can be configured either by selecting a web services engine or declaring one or more WSDL handlers in jonas.properties. 1) Selecting a web services engine jonas.service.ws.class org.objectweb.jonas.ws.AxisWSServiceImpl 2) Choose one or more WSDL handlers Example: # a list of comma separated WSDL Handlers jonas.service.ws.wsdlhandlers file1 # Configuration of the file WSDL Handler jonas.service.ws.file1.class org.objectweb.jonas.ws.handler.FileWSDLHandler # Specify String params for WSDLHandler creation # jonas.service.ws.file1.params location # Make sure that user that run JOnAS have rad/write access # in this directory jonas.service.ws.file1.location /path/to/directory/where/store/wsdls ---------- -- EAR To deploy EARs on Jonas start-up : jonas.service.ear.descriptors Bank.ear EARs go into $JONAS_BASE/apps/. ---------- -- Transaction Service A mandatory service, it can be launched locally, or remotely in a different JVM. When there are are several Jonas servers, one transaction manager is considered the master and the rest as slaves. The slaves must be configured as if they are working with a remote transaction service. Example : jonas.name TM jonas.services jtm jonas.service.jtm.remote false and jonas.name EJB jonas.services jmx,security,jtm,dbm,ejb jonas.service.jtm.remote true jonas.service.ejb.descriptors foo.jar ---------- -- Security Jonas relies on Tomcat and Jetty for the identification of web clients. Jonas provides three types of realms : 1) Memory realm : users, groups and roles are defined in jonas-realm.xml under . 2) Datasource realm : the configuration for accessing a database and a set of tables for authentication is defined under . 3) LDAP realm : allows authentication information to be gotten from an LDAP database. Defaults to ldap://localhost:389. To allow security context propagation, set : jonas.security.propagation true in jonas.properties. ---------- -- JavaMAIL Jonas provides two types of mail factories : 1) javax.mail.Session 2) javax.mail.internet.MimePartDataSource The latter allows mails to be sent with the subject and recipient already set. To configure these, modify MailSession1.properties and MailMimePartDS1.properties respectively and reflect them in jonas.properties : jonas.service.mail.factories MailSession1,MailMimePartDS1 ---------- -- Session Bean Pools Example: SessSLR EJB/SessHome 20 10 ---------- -- MOM The Joram MOM can be launched separately using the command 'JmsServer'. If the MOM is to be launched in the same JVM as Jonas the jonas.service.jms.collocated needs to be set to true, which it is by default. When using JMS, it is very important to stop JOnAS using the jonas stop command; it should not be stopped directly by killing it. When connecting to a MOM on a different host, the jonas.service.jms.url property needs to be set. jonas.service.jms.url joram://host2:16010 If the default host or connection port needs to be changed, it can be configured in a3servers.xml file. An MDB will never execute within an existing transaction. ---------- -- Transactions Transactions could be either local or remote to the JVM that Jonas runs on. This can be configured by the jonas.service.jtm.remote property. If remote, the Transaction Manager needs to be started separately using the TMServer command. ---------- -- Deployment Once a JAR has been bundled according to the specifications, it needs to be passed into the GenIC program in order to generate the necessary stubs for deployment in Jonas. Simply : GenIC helloworld.jar And follow the normal deployment process. ---------- -- Client container To view help on the use of the client container : java -jar $JONAS_ROOT/lib/client.jar -? Use the -jarClient argument if the EAR has more than one client. ----------