Dear Sir can anyone plz help me with EJB2.0 Project
nakul.r Feb 25, 2015 3:49 AMimport javax.ejb.EJBObject;
public interface CardValidator extends EJBObject
{
public boolean validateCard(long cardNo, float ammount) throws RemoteException;
}
------------>this is my remote interface
-------------------------------------------------------------------------------------------------
public interface CardValidatorHome extends EJBHome
{
public CardValidator create() throws RemoteException;
}
------------>this is my Home interface
-------------------------------------------------------------------------------------------------
public class CardValidatorImplementor implements SessionBean
{
/**
*
*/
private static final long serialVersionUID = 1L;
public boolean validateCard(long cardNo,float ammount) throws RemoteException
{
if(cardNo==12345 && ammount<50000)
return true;
else
return false;
}
public void EJBcreate()
{
}
------------>this is Implementor class
-------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>EJb_2.0</display-name>
<enterprise-beans>
<session>
<ejb-name>Cards</ejb-name>
<home>amoeba.EJB.CardValidatorHome</home>
<remote>amoeba.EJB.CardValidator</remote>
<ejb-class>amoeba.EJB.CardValidatorImplementor</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
------------>this is ejb-jar.xml
-------------------------------------------------------------------------------------------------
I have deployed it through Jboss wildfly 8.2.0 Final
Now i wnat to acces this EJB or cardValidator()
public static void main(String[] args)
{
try {
boolean status;
Properties props=new Properties();
System.out.println("properties are initialising");
props.setProperty("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
System.out.println("property 1 initilised");
props.setProperty("java.naming.provider.url","remote://localhost:4447");
System.out.println("property 2 initilised");
//props.put(Context.SECURITY_PRINCIPAL, "jerry");
//System.out.println("property 3 initilised");
//props.put(Context.SECURITY_CREDENTIALS, "jerry@tom1");
//System.out.println("property 4 initilised");
InitialContext context=new InitialContext(props);
System.out.println("context initilised");
Object object=context.lookup("Cards");
System.out.println("cards founds");
CardValidatorHome home=(CardValidatorHome)PortableRemoteObject.narrow(object, CardValidatorHome.class);
System.out.println("CardValidatorHome");
CardValidator remote=home.create();
System.out.println("CardValidatorRemote");
status = remote.validateCard(12345,1500);
if(status)
System.out.println("Card Accepted");
else
System.out.println("Card Declined");
}
catch (ClassCastException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (RemoteException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (NamingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
------------>through this i m accessing it when i try to run it it gives exception as follows
-------------------------------------------------------------------------------------------------
properties are initialising
property 1 initilised
property 2 initilised
Feb 25, 2015 1:43:27 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.0.Final
Feb 25, 2015 1:43:31 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.0.Final
Feb 25, 2015 1:43:33 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.6.Final
context initilised
javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129)
at javax.naming.InitialContext.lookup(Unknown Source)
at amoeba.EJBClient.Entry.main(Entry.java:37)
-------------------------------------------------------------------------------------------------
I have tried changing the port but fails