Skip navigation.

LONG AGO YESTERDAY

My Experinece with Ubuntu 8.10

Getting really bored with Windows XP I decided to try Ubuntu Linux 8.10 a couple days ago. As a newbie to Ubuntu I really wondered when I saw all hardwares worked perfect after installation and I didn't even setup network connection!
Well here's what I have done with my Ubuntu 8.10 until now:

Persian Fonts:
Ubuntu supports pension language and you can simply add Persian keyboard layout from System → Administration → Language Support but the default Persian fonts are not sufficient and the Persian websites are not look as they should. So I found this and this for installing Persian fonts on my Ubuntu.

sudo apt-get install ttf-farsiweb
sudo apt-get install xfonts-intl-arabic
sudo apt-get install xfonts-intl-european
sudo apt-get install xfonts-intl-phonetic
sudo apt-get install gsfonts-x11
sudo apt-get install msttcorefonts
wget -c http://voxel.dl.sourceforge.net/sourceforge/fpf/fpf.zip
wget -c http://hezardastan.sourceforge.net/persianfonts/tahoma.tar.gz
wget -c http://hezardastan.sourceforge.net/persianfonts/bfonts.tar.gz
sudo mkdir /usr/share/fonts/truetype/ttf-persian-fonts
sudo unzip fpf.zip -d /usr/share/fonts/truetype/ttf-persian-fonts
sudo tar zxvf tahoma.tar.gz -C /usr/share/fonts/truetype/ttf-persian-fonts
sudo tar zxvf bfonts.tar.gz -C /usr/share/fonts/truetype/ttf-persian-fonts
sudo fc-cache -f -v


Turning on Clear Type Mode:
I like Clear Type mode in windows it makes fonts very smother. Can I have it in Ubuntu Linux? Yes! Here it is.

Spider Card Game and Golha Radio!:
My mother is another user of my desktop computer and she like to play “Spider” card game while listening to Golha Radio and I had to prepare her game in Ubuntu.
Firstly I found PySol and installed it via Synaptic Package Manager but although it has so many card games, I couldn't find a game exactly like Windows Spider! Hence I tried installing kpat (KPatience) and it was exactly the thing that made switching to Ubuntu possible! Anyways after playing with other fantastic Ubuntu games my mother doesn't play Spider anymore!!!

Installing Tor:
Its time to surf Internet freely!! And it was very straightforward: Install 'tor', 'privoxy' and 'torbutton-extention' from repository. Then you should configure privoxy as follow:
sudo gedit /etc/privoxy/config

Add the following line at top of the file (don't miss the dot at the end of line):
forward-socks4a / 127.0.0.1:9050 .   

Search for 'logfile logfile' and comment out the line.
Search for 'jarfile jarfile' and comment out the line.
After saving file restart the Privoxy service:
sudo /etc/init.d/privoxy restart

Now restart Firefox and you will see a red text in bottom right corner of Firefox saying:
Tor Disable. Enable tor by clicking text, it should turn to green and say Tor Enabled. Now you can surf the web freely :smile:

Problem with HP laserJet 1020:
The other day I noticed that my printer which is HP LaserJet 1020 doesn't work! I am sure it was working after installing Ubuntu but maybe after updating Ubuntu something made it ot of order! The problem was that it accepted print jobs and cleared them but nothing would happened! So I tried whatever came to my mind like testing it by another computer with windows XP (worked), reinstalling CUP, changing USB port etc. Nothing worked but google again proved me the first thing for solving a problem should be always googling!
http://foo2zjs.rkkda.com/ emphatically says not to use the foo2zjs driver from the Ubuntu repository. Instead, they want you to download from their site and compile from source. So I did it and my printers started printing again :smile:

Share Printer on Network:
I wanted to share my Ubuntu printer so that my notebook with XP windows could print to it. And there was no problem at all: https://help.ubuntu.com/community/NetworkPrintingFromWinXP

Set Static IP Address:
Well lets set a static IP address for Ubuntu because it has shared the printer. Oops NetworkManager that provide so simplified Internet connection for me has a known problem with static IP address! Settings made in NetworkManager will not be applicable at the next restart. Ultimately if you assign a fixed IP address in NetworkManager, this setting will be forgotten the next reboot. There is a solution for it but it was not that much important for me so I just forget about it! Hopefully it will be fixed soon...

Merging Partitions in Ubuntu 8.10:
Getting addicted to Ubunto, I wanted to delete windows partition and add it to Ubuntu partition so I used GParted with live CD as GParted doesn’t resize mounted partitions so I had to first swapoff swap partition by “sudo swapoff –a” it is also possible by right clicking on swap partion in Gparted and choosing swapoff. Then deleting swap partion, Coping Ubuntu portion to have:
Ubunto Partition | unallocated space | Swap Partition
Then I could expand the Ubunto Partition.

Restarting Grub
Unfortunately after merging partitions the Grub returned error at start up so I tried restoring Grub from live CD by helping from here.

And now life is beautiful! I really like Ubuntu and I really like when I feel everything is under control!




JNIEasy Hello World Sample

JNI (Java Native Interface) is one of really difficult technologies in Java. Firstly you should know C/C++ very good and then you should handle many things such as errors, memory, configurations etc. Wishing to find an alternative I stumbled upon JNIEasy. With JNIEasy your way to integrate Java and C/C++ is more straightforward.
Bellow follows my Hello World sample of mapping a Java class with its C++ equivalent.
Well I want to have an array of bytes shared between C++ and Java. First of all I have to create a wrapper:
public class MyCPPClassOnDLL {
     protected int virtualTable; // the C++ class has a virtual method     
     public MyCPPClassOnDLL() // mandatory (is not native)
     {
     }
     public static native void destroy(MyCPPClassOnDLL obj);  
     public native byte[] getValue(int index);
     public native void setValue(byte[] test,int index) ; 
} 

As you see we have only method declaration here and the implementation is in C++ side as follow:
dll.h:
#include "JNIEasy.h"
class DLLEXPORT MyCPPClassOnDLL
{
protected:
    char** m_value;    
public:

    virtual ~MyCPPClassOnDLL();
    static MyCPPClassOnDLL* __stdcall create();
    static void __stdcall destroy(MyCPPClassOnDLL* obj);

    void __stdcall setValue(char* test,int index);

    char* __stdcall getValue(int index);

};

dllmain.cpp:

#include "dll.h"
#include <stdio.h>
#include <stdarg.h>
#include <iostream>
#include <cstdio>

using namespace std;

char debugMsg[256];
char *buffer;
char input[256] = "";
unsigned long inSize;
unsigned long msgSize;
bool running = true;


#define PAUSE system("PAUSE")

MyCPPClassOnDLL::~MyCPPClassOnDLL()
{
   m_value = new char*[2];
}

MyCPPClassOnDLL* __stdcall MyCPPClassOnDLL::create()
{
    return new MyCPPClassOnDLL(); // may be an inherited class
}

void __stdcall MyCPPClassOnDLL::destroy(MyCPPClassOnDLL* obj)
{
    delete obj;
}

void __stdcall MyCPPClassOnDLL::setValue(char* value,int index){     
     m_value[index] = value;
}     


char* __stdcall MyCPPClassOnDLL::getValue(int index){
       return m_value[index];
}

You should make a DLL from them.
The sad part is creating XML hell to explain how to bind methods of Java class to DLL libraries:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Archive MyCPPClassOnDLL.jnieasy.enh.xml -->
<jniEasyEnhancer version="1.1"
    xmlns="http://www.innowhere.com/jnieasy/enhancer"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.innowhere.com/jnieasy/enhancer
        ../../../schemas/JNIEasy.enh.xsd">

    <package name="ir.org.kia.common.jniObjects">
        <imports/>
        <class name="MyCPPClassOnDLL" type="class"
                libraryPath="DevShareValue" >

            <constructor onLibrary="true"
                    nativeName="gcc:_ZN15MyCPPClassOnDLL6createEv">
            </constructor>

            <method name="destroy" onLibrary="true"
                    nativeName="gcc:_ZN15MyCPPClassOnDLL7destroyEPS_"
                    params="MyCPPClassOnDLL">
            </method>

            <method name="setValue" onLibrary="true"
                    nativeName="gcc:_ZN15MyCPPClassOnDLL8setValueEPci">
                <return class="void"/>
                <params>
                    <param class="byte[]" />
                    <param class="int" />
                </params>
            </method>
            <method name="getValue" onLibrary="true"
                    nativeName="gcc:_ZN15MyCPPClassOnDLL8getValueEi">
                <return class="byte[]"/>
                <params>
                    <param class="int"/>
                </params>
            </method>
        </class>
    </package>
</jniEasyEnhancer>

Well you have to find nativeName in DLL file in order to map it to Java method. And
‘PEDUMP’ will do it for you. You have to execute a command like
‘pedump DevShareValue.dll >pedump_DevShareValue.txt’ and then under ‘exports table’ part of generated txt file, you will find native names.
There are also some other xml files for pointing to the locations.
Now it’s time to load stuff:
public class JNILoader {
    private static JNILoader ourInstance = new JNILoader();

    public static JNILoader getInstance() {
        return ourInstance;
    }

    private JNILoader() {
        final ResourceBundle theResourceBundle = ResourceBundle.getBundle("jni");
        JNIEasy jniEasy = JNIEasy.get();
        jniEasy.setFeature("jnieasy.license.dir",theResourceBundle.getString("jnieasy.license.dir"));
        jniEasy.setFeature("java.library.path",theResourceBundle.getString("java.library.path"));
        jniEasy.load();
        try {
            jniEasy.getEnhancer().enhance(
                    new URL("file:"+theResourceBundle.getString("enhancer.path")),
                    theResourceBundle.getString("out.path"));
        } catch (MalformedURLException e) {
            e.printStackTrace();  
        }

    }
    public void initMacros()
    {
        NativeTypeManager typeMgr = JNIEasy.get().getTypeManager();
        DynamicLibrary dll = JNIEasy.get().getDLLManager().get("DevShareValue");
        long address = dll.getAddress("?create@MyCPPClassOnDLL@@SGPAV1@HH@Z");
        if (address != 0)
            typeMgr.defineMacro("MSC");
        else
            typeMgr.defineMacro("gcc"); // MinGW or cygwin gcc
    }

}

An at last you have access to C++ class via Java:
public class Main {
    public static void main(String[] args) {
        JNILoader.getInstance().initMacros();
        // Calls create() C++ method. New object is already native
        MyCPPClassOnDLL obj = new MyCPPClassOnDLL(); 
        obj.setValue("Hello ".getBytes(),0);
        obj.setValue("World!".getBytes(),1);
        System.out.println("Hello World from C++: " + 
                new String (obj.getValue(0))+
                new String (obj.getValue(1)));
    }
}


What is best Seam pattern?

As far as I know we have five options for implementing Seam components:
  • Backing Beans
  • Stateful Session Beans
  • Entity Beans
  • Message-Driven Beans
  • Stateless Session Beans

The three last items fundamentally are not very good choices because of stateless nature of SLSBs and MDBs and of course Entity Beans are not good place for writing business logic!
So the question is what are pros and cons of using SLSB VS Backing Beans plus session façades?

Pros:
  • Simpler classes design because you can bridge the JSF component model with EJB component model.
  • Transactions are handled.
  • You have instance pooling.

Cons:
  • SFSBs are heavy components I know they are very optimized in EJB3 but they are still heaver than POJOs.
  • Using SFSB as component makes the classes design simple but useful for hello world applications! In a real application if you put all business logic in one SFSB it will end up with a huge class!! For preventing it you may decide to separate business into many SFSBs but is it wise to have many costly SFSBs for each user? You may use some Stateless Session Beans for servicing your SFSB so why you didn’t use POJO and many SLSB services?
  • I can’t imagine what is the use of having transactions handled in a component while we can decuple business components like any other rich client application?

    Update:
    Well now I can see the usage of Stateful Session Beans in Seam. Suppose you have a method like this:
    public void doSomething(){
    1.do some db related CRUD;
    2.do some UI related staff;
    3.do some db related CRUD;
    }
    And suppose that the order of above tasks is important and on the other hand you want to have all of them in one transaction. Although it is possible to put transaction in a SLSB but it is definitely simpler to have a SFSB as a component especially in transactional or workflow based situations.

13949712720901ForOSX

,

EJB-to-Client Notification

, , ,

A few days ago I asked a friend of mine -who is Java addicted- about EJB-to-Client Notification. I was wondering why EJB doesn’t support events for notifying swing based clients of the changes i.e. updates, deletes etc.
His answer was that I have to use JMS but this is not acceptable because I am talking about an easy to use event driven approach that handles the problem of locating clients and so on. I want to fire an event in the server and the EJB Container notifies all clients.
Anyways even using JMS there is no clear approach for implementing this feature. It seems that this is the problem addressed by the ’Observer Design Pattern’. According to this pattern one approach is for every client to query the server periodically but this can be computationally wasteful. Another solution is for the server to be designed knowing its clients. But giving the server knowledge about its clients breaks the classic client-server model and this approach also doesn’t recommend.

So I think the best solution is adding a Broker i.e. a “reference repository” to the EJB Container which grabs the location of clients as they connect to it (Note that I’m talking about desktop applications).

Distributed computing with Terracotaa

, , ,


One year without any post!!! So how can I blame Behrang for calling me lazy ass?  :frown:
Anyways I want to share my experience using Terracotta for clustering POJO applications. First of all I should say that the idea behind Terracotta is really nice which is adding a VM like layer under JVM for sharing objects or replicating change between them. Actually I wanted to prepare a cluster for implementing distributed computing, something like this. After googling for finding easy to implement general solutions, I found Master/Worker pattern and it’s implementation. So I tried to write a sample that has workers with various tasks, which is PI calculator with two Workers that can be run parallel. Unfortunately my sample performance is not good at all in compare of RMI (PI implementation with RMI also is attached). But there are some problems in my code, firstly I have always performing two parallel operations and secondly Terracotta has some startup overhead that is not present in other solutions like RMI and thirdly my program has not a timer for measuring the actual start and stop and lastly my sample is entirely CPU bound and maybe it doesn’t show significant difference between Terracotta and RMI for this particular use.
Unfortunately I hadn’t time to accomplish a better distributed parallel sample with better and newer Master/Worker implementation
For now I can only say go ahead Terracotta and GOOD LUCK!!
PI with Terracotta
PI with RMI

problem in charWidth method of FontMetrics

, ,

There is a problem in charWidth method of FontMetrics class when using it for finding the width of a Unicode character in JDK1.5. Although it works correctly but in JDK1.5 it’s more than 10 times slower than JDK1.4. I used both charWidth(int codePoint) and charWidth(char ch) methods and the result is same.
I have used many features of JDK1.5 in my project and it’s very hard to switch back to JDK1.4 and now it works very slowly.:frown:

General DataObject

, , ,

For communicating between server and client I have written a data object.
This data object uses Java reflection for getting hibernate objects property fields and I can send fields of one or more persist data object to the client without detaching persist data.
For simplicity I have written ‘addAll()’ method that puts all fields of persist object to the data object.

Item item = (Item)session.get( Item.class, pk );
String [] exclude = new String[]{“categories”};
dataObject.addAll(item, exclude);

For storing properties of various objects I have used a HashTable that its keys are the class name of the object plus name of getter method of the property field. But there is a problem when I want to put an object like below in my data object:

Item item = category.getItem();
String [] exclude = new String[]{“categories”};
dataObject.addAll(item,exclude);


The problem is that item (which is returned from category) is an inherited object and its class name isn’t CatAegory.class ! So I can’t get the values of category by calling get method:
For example DataObject.get(Category.class,”name”) returns null :frown:
Anyway in these cases I have to use set method for each field…



import java.util.Hashtable;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.io.Serializable;

import ir.sam.stock.util.Logger;


public class DataObject implements Serializable {
    Hashtable<String,Object> map = new Hashtable<String, Object>();

    /**
     * adding property value of object to hashtable
     * @param object
     * @param property
     */
    public void add(Object object, String property) {
        if(object == null)
            return;
        Method method;
        Class<? extends Object> c = object.getClass();
        Object value;
        try {
            method = c.getDeclaredMethod("get" + property.substring(0, 1).toUpperCase() + property.substring(1));
        } catch (NoSuchMethodException nsme) {
            throw new RuntimeException(nsme);
        }
        try {
            value = method.invoke(object);
            if(value != null)
                map.put(c.getName() + "." +method.getName(),value);
        } catch (IllegalAccessException iae) {
            throw new RuntimeException(iae);
        } catch (InvocationTargetException ite) {
            throw new RuntimeException(ite);
        }
    }

    /**
     *
     * @param object
     * @param properties: an array of this object's properties
     */
    public void add(Object object, String[] properties) {
        for (String prop:properties){
            add(object,prop);
        }
    }

    /**
     * adding all properties of object to hashtable
     * @param object
     */
    public void addAll(Object object) {
        addAll(object,null);
    }

    /**
     * add all properties exclude these properties
     * @param object
     * @param exclude
     */
    public void addAll(Object object,String[] exclude) {
        if(object == null)
            return;
        Method[] methods;
        Class<? extends Object> c = object.getClass();
        methods = c.getDeclaredMethods();
        try {
            for (Method method : methods) {
                method.getReturnType().isPrimitive();

                if(method.getName().startsWith("get")){
                    if(exclude!=null)
                        for(String excluded:exclude){
                            if(method.getName().equals("get" + excluded.substring(0, 1).toUpperCase() + excluded.substring(1))){
                                method = null;
                                break;
                            }
                        }
                    if(method == null)
                        continue;
                    Object value = method.invoke(object);
                    if(value != null)
                        map.put(c.getName() + "." + method.getName(), value);
                }
            }
        } catch (IllegalAccessException iae) {
            throw new RuntimeException(iae);
        } catch (InvocationTargetException ite) {
            throw new RuntimeException(ite);
        }
    }

    /**
     * setting property of class c with this value
     * @param c         class Type
     * @param property
     * @param value
     */
    public void set(Class c,String property,Object value){
        if(value == null && get(c,property)!=null){
            map.remove(generateKey(c,property));
        }else if(value == null){
            return;
        }
        try {
            c.getDeclaredMethod("get" + property.substring(0, 1).toUpperCase() + property.substring(1));
            map.put(generateKey(c,property),value);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * setting an individual object with arbitary name in hashtable
     * @param name
     * @param value
     */
    public void set(String name,Object value){
        if(value == null)
            return;
        map.put(name,value);
    }

    /**
     * @param name
     * @return an individual object with arbitary name in hashtable
     */
    public Object get(String name){
        return map.get(name);
    }
    /**
     * @param c
     * @param property
     * @return value of the property of class c
     */
    public Object get(Class c,String property){
        return map.get(generateKey(c,property));
    }

    private String generateKey(Class c,String property){
        return c.getName()+".get" + property.substring(0, 1).toUpperCase() + property.substring(1);
    }

     /**
     * fills object with all values for it's properties that are in hashtable
     * @param object
     * @return filled object
     */
    public Object fillObject(Object object){
        Class c = object.getClass();
        Method[] methods;
        methods = c.getDeclaredMethods();
        for(Method method : methods){
            if(method.getName().startsWith("get")&&map.containsKey(c.getName() + "." + method.getName())){
                String methodName = method.getName();
                methodName = methodName.replaceFirst("get","set");
                Method setter =null;
                Object value = null;
                try {
                    value = map.get(c.getName() + "." + method.getName());
                    Class[] argtype = {value.getClass()};
                    setter = c.getDeclaredMethod(methodName,argtype);
                } catch (NoSuchMethodException nsme) {
                    // trying to find same method with primitive type arguments
                        try {
                            Class[] argtype = new Class[1];
                            if(value instanceof Boolean)
                                argtype[0] = boolean.class;
                            if(value instanceof Byte)
                                argtype[0] = byte.class;
                            if(value instanceof Character)
                                argtype[0] = char.class;
                            if(value instanceof Short)
                                argtype[0] = short.class;
                            if(value instanceof Integer)
                                argtype[0] = int.class;
                            if(value instanceof Long)
                                argtype[0] = long.class;
                            if(value instanceof Float)
                                argtype[0] = float.class;
                            if(value instanceof Double)
                                argtype[0] = double.class;
                            setter = c.getDeclaredMethod(methodName,argtype);
                        } catch (NoSuchMethodException e) {
                            throw new RuntimeException(e);
                        }
                }
                try{
                    if(setter != null){
                        Object[] args = {value};
                        setter.invoke(object,args);
                    }
                }catch (IllegalAccessException e) {
                    Logger.logError("error whike invoking "+setter.getName());
                    throw new RuntimeException(e);
                } catch (InvocationTargetException e) {
                    Logger.logError("error whike invoking "+setter.getName());
                    throw new RuntimeException(e);
                }

            }
        }
        return object;
    }
}

Using Hibernate as persistence layer inside JBoss

, ,

I have created an example and it works, but I didn’t find any clear sample code to be ensured of what I did!]
I have created a stateless SessionBean, and in it’s ejbCreate() method, Hibernate SessionFactory is looked up:
public class DataServiceBean implements SessionBean {
    protected SessionContext sessionContext;
    private SessionFactory factory;

    public void ejbCreate() {
        try {
            InitialContext ctx = new InitialContext();
            String jndiName = "SessionFactory";
            factory = (SessionFactory) ctx.lookup(jndiName);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    public void setSessionContext(SessionContext sessionContext) throws EJBException {
        this.sessionContext = sessionContext;
    }

    public void ejbRemove() throws EJBException {
    }

    public void ejbActivate() throws EJBException {
    }

    public void ejbPassivate() throws EJBException {
    }

    public Player getPlayer() {
        Session s = factory.getCurrentSession();
        Player p = (Player) s.get(Player.class, 1);
        return p;
    }
}

The interfaces are:
public interface DataService extends EJBObject {
    public Player getPlayer() throws RemoteException;
}
public interface DataServiceHome extends EJBHome {
    public DataService create() throws CreateException, RemoteException;
}
ejb-jar.xml:
<ejb-jar>
<description>TEST</description>
<display-name>TEST</display-name>
    <enterprise-beans>
        <session>
            <ejb-name>DataServiceBean</ejb-name>
            <home>interfaces.DataServiceHome</home>
            <remote>interfaces.DataService</remote>
            <ejb-class>ejb.DataServiceBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
        </session>
    </enterprise-beans>
</ejb-jar>
jboss.xml:
<jboss>
<secure>true</secure>
<container-configurations />
<resource-managers />
        <enterprise-beans>
<session>
<ejb-name>DataServiceBean</ejb-name>
<jndi-name>TEST/DataService</jndi-name>
<configuration-name>Standard Stateless SessionBean</configuration-name>
</session>
        </enterprise-beans>
</jboss>
hibernate-service.xml:
<server>
    <mbean code="org.jboss.hibernate.jmx.Hibernate"
           name="jboss.har:service=Hibernate">
        <attribute name="DatasourceName">java:/MSSQLDS</attribute>
        <attribute name="Dialect">org.hibernate.dialect.SQLServerDialect</attribute>
        <attribute name="SessionFactoryName">SessionFactory</attribute>
    </mbean>
</server> 
Player DataObject:
public class Player implements Serializable {

    private Integer id;
    private String name;
    private String position;
    private float salary;

    public Player() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public float getSalary() {
        return salary;
    }

    public void setSalary(float salary) {
        this.salary = salary;
    }
}
Player.hbm.xml:
<hibernate-mapping>
    <class name="dataobject.Player" table="PlayerBean">
       <id name="id" type="int" column="playerID">
           <generator class="assigned" />
       </id>
       <property name="position" type="string" column="POS"    />
       <property name="name"     type="string" column="name"   />
       <property name="salary"   type="float"  column="salary" />
    </class>
</hibernate-mapping>
And the client code:
public class Main {
    public static void main(String[] args) {
        try {
            InitialContext ctx = new InitialContext();
            String jndiName = "TEST/DataService";
            DataServiceHome dataServiceHome = (DataServiceHome) ctx.lookup(jndiName);
            DataService dataService = dataServiceHome.create();
            Player p = dataService.getPlayer();
            System.out.println("Name = " + p.getName());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
In order to deploy both EJB and Hibernate I created a jar file and also a har file and put both of them in JBoss. So Jboss Builds SessionFactory and bounds it into JNDI by har file and also deploys EJB by jar file.
I’ll appreciate any comment and opinion.

Thanks Behrang for his useful Java2BBCode convertor :wink:

Hibernate Service JNDI lookup returns null

, , , ...

I want to share Hibernate session factory by using JBoss for desktop application.
Finally I could configure it and now my har file deploys and service appears to bind correctly, also I could connect to Jboss with a jsp file and work with database properly. But JNDI lookup in a java class returns null!!
I found this problem could cause by existing class files in my war file but there is no class file in my war file though deleting war file from JBOSS didn’t solve the problem…
January 2010
S M T W T F S
December 2009February 2010
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30