Tag: Bignners

How to download JBoss Server ?

Hi,

JBoss is worlds one of the most popular and reliable application server which provides you a lots of features including full customization.  It comes in two flavours

1). JBoss Community Release

2). JBoss RedHat Enterprise Release

Community Versus Enterprise JBoss Which one is Best?

The JBoss Community releases are the base of JBoss Enterprise Releases. But the JBoss Enterprise Release has many additional advantages in terms of standard life cycles and support and Many additional advantages and features which are required, mandatory and essential in running a Production environment using JBoss. For more informations of JBoss Community Release Vs JBoss Enterprise Release please refer to the following article:

JBoss Application ServerCommunity Release can be downloaded from the following link:
http://www.jboss.org/jbossas/downloads/

JBoss Enterprise Releases can be downloaded from the following link:
http://www.jboss.com/downloads/

The JBoss Enterprise release can be downloaded with “Subscription” as well as “Evaluation Version for 30 Days” In the above page you will get these options so based on your requirement you can choose.

If you already have a RedHat Subscription then you can download the software’s through the following link:
https://access.redhat.com/jbossnetwork/restricted/listSoftware.html

There are many JBoss  Community Releases and projects are going on in parallel which can be found in the following link:
http://www.jboss.org/projects/matrix

.
.
Thanks
MiddlewareMagic


Binding Custom Strings in JBoss AS6 JNDI tree

Hi,

Many times we want to create some customer JNDI names which will hold some string objects to perform some application specific functionality. In general terms we can say “We want to bind some strings to the JBoss AS6 server’s JNDI tree.” so in order to do that we have the following two options

Option-1).

According to J2EE Specifications we can write the following kind of tag inside our application’s “WEB-INF/web.xml” file:

<?xml version='1.0' encoding='UTF-8'?>
<web-app>
  <env-entry>
    <env-entry-name>TestJNDIKey</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>Some_Application_Specific_JNDIData</env-entry-value>
  </env-entry>
</web-app>

Once your web.xml file has the above kind of entry then you can use the following kind of Code snippet inside your application code (like servlet or jsp) to get the JNDI entry’s bind value.

   InitialContext ctx = new InitialContext();
   Context envCtx = (Context) ctx.lookup("java:comp/env");
   String jndiData = (String) envCtx.lookup("TestJNDIKey");

Option-2).

Open the “jboss-services.xml” file from the following location “$JBOSS_HOME/server/$PROFILE/conf” directory and then add the following kind of <mbean> declaration using “org.jboss.naming.JNDIBindingServiceMgr”

<mbean code="org.jboss.naming.JNDIBindingServiceMgr" name="jboss.testing:name=test">
       <attribute name="BindingsConfig" serialDataType="jbxb">
         <jndi:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
                        xs:schemaLocation="urn:jboss:jndi-binding-service resource:jndi-binding-service_1_0.xsd">
             <jndi:binding name="TestJNDIKey">
                 <jndi:value trim="true">Hello, SomeValue!</jndi:value>
             </jndi:binding>
         </jndi:bindings>
        </attribute>
</mbean>

Option-3).

If you don;t want to edit the “jboss-services.xml” file provided by JBoss AS6 then in that case you can create your own Service file with some name like “test-service.xml” inside your “/WEB-INF” directory.
NOTE: the file name must end with “*-service.xml”

OR

Create a file with some name like “test-service.xml” and then place it inside your “$PROFILE/deploy” directory, so that as soon as you will start your JBoss AS6 instance the Service will be activated and the JNDI name will be binded in the JNDI tree of your JBoss.

So you can add the following MBean declaration somewhere in the file Either inside “/server/
/conf/jboss-service.xml” Or add the following declaration inside “/WEB-INF/test-service.xml” file:

<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.naming.JNDIBindingServiceMgr" name="jboss.tests:name=example1">
       <attribute name="BindingsConfig" serialDataType="jbxb">
         <jndi:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
                        xs:schemaLocation="urn:jboss:jndi-binding-service resource:jndi-binding-service_1_0.xsd">
             <jndi:binding name="TestJNDIKey">
                 <jndi:value trim="true">Hello, SomeValue!</jndi:value>
             </jndi:binding>
         </jndi:bindings>
        </attribute>
</mbean>
</server>

Step2). Now restart your JBoss AS6 profile like

./run.sh -c default_Test -b 10.10.10.10

Above means you are starting the JBoss profile “default_Test” on Listen address 10.10.10.10.

Step3). You can use the the following client to access the JNDI name remotely/locally.

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class ExClient
   {
       public static void main(String args[]) throws Exception
        {
          Properties env = new Properties();
          env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.NamingContextFactory");
          env.setProperty(Context.PROVIDER_URL,"10.10.10.10:1099");
          Context ctx = new InitialContext(env);
          System.out.println("nntCreated InitialContext, env=" + env);
          Object data = ctx.lookup("TestJNDIKey");
          System.out.println("nntlookup(MyJNDIName): " + (String)data);
         }
   }

.
.
Thanks
Middleware Magic Team


Copyright © 2010-2012 Middleware Magic. All rights reserved. |