[jboss-user] [Beginners Corner] - Please help: Failed to run simple EJB 3.0 Application

mathias.altmeyer do-not-reply at jboss.com
Mon Aug 14 03:11:03 EDT 2006


Hello.

I'm trying to deploy a simple EJB 3.0 application within JBoss Application Server (build CVSTag=JBoss_4_0_4_GA date=200605151000). Here is my sample code:

Remote Interface:


import java.math.BigDecimal;
import javax.ejb.Remote;

@Remote
public interface Converter {
    public BigDecimal dollarToYen(BigDecimal dollars);

    public BigDecimal yenToEuro(BigDecimal yen);
}



Bean class:


import javax.ejb.Stateless;
import java.math.BigDecimal;

@Stateless
public class ConverterBean implements Converter 
{
    private BigDecimal euroRate = new BigDecimal("0.0070");
    private BigDecimal yenRate = new BigDecimal("112.58");

    public BigDecimal dollarToYen(BigDecimal dollars) {
        BigDecimal result = dollars.multiply(yenRate);

        return result.setScale(2, BigDecimal.ROUND_UP);
    }

    public BigDecimal yenToEuro(BigDecimal yen) {
        BigDecimal result = yen.multiply(euroRate);

        return result.setScale(2, BigDecimal.ROUND_UP);
    }
}


Test client:


import java.math.BigDecimal;
import javax.ejb.EJB;
import javax.naming.*;

public class ConverterClient 
{

    public ConverterClient() 
    {
    }

    public static void main(String[] args) 
    {
        ConverterClient client = new ConverterClient();
        client.doConversion();
    }

    public void doConversion() 
    {
        try {
            InitialContext ctx = new InitialContext();
            Converter converter = (Converter) 
                 ctx.lookup("converter/ConverterBean/remote");

            BigDecimal param = new BigDecimal("100.00");
            BigDecimal yenAmount = converter.dollarToYen(param);

            System.out.println("$" + param + " is " + yenAmount + " Yen.");

            BigDecimal euroAmount = converter.yenToEuro(yenAmount);
            System.out.println(yenAmount + " Yen is " + euroAmount + " Euro.");

            System.exit(0);
        } catch (Exception ex) {
            System.err.println("Caught an unexpected exception!");
            ex.printStackTrace();
        }
    }
}


My JNDI properties file:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces


My ear archive (named converter.ear) has the following content:
META-INF/application.xml
beans.jar

My beans.jar has the following content:
Converter.class
ConverterBean.class

After deploying the archive JBoss don't has created the context path "converter/ConverterBean/remote"! After compiling and running the test client I get an NameNotFoundException:

javax.naming.NameNotFoundException: converter not bound

I thought that I don't need a deployment descriptor anymore. Is my ear archive incorrect? What is my fault? Please help me!

Thank you! Mathiasanonymous wrote : 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964894#3964894

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964894



More information about the jboss-user mailing list