• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB3 Client Not Running

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Members ,

I am new to EJB 3.0.I am using Eclipse 3.2,Jboss 4.2.2.GA .Everything is fine but when i run client it gives me the following error

******************************************************************

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy0.add(Unknown Source)
at com.npi.client.CalculatorClient.main(CalculatorClient.java:24)
Caused by: java.lang.Exception: Can not make remoting client invocation due to not being connected to server.
at org.jboss.remoting.Client.invoke(Client.java:1639)
at org.jboss.remoting.Client.invoke(Client.java:548)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
... 2 more
*************************************************************

Please help me It is very urgent .I go through lots of tutorials and books but still waiting for running the first EJB3.0 Client.

Waiting for reply !!

Thanks in advance !!
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source code would be nice.

The exception message is pretty clear though: "Can not make remoting client invocation due to not being connected to server."

Have you tried connecting to the server first?
 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I am using JBoss Plugin with Eclipse 3.2.

This is Client
****************************************
package com.npi.client;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import com.npi.ejb.StatelessCalculator;
import com.npi.ejb.StatelessCalculatorBean;

public class CalculatorClient {

/**
* @param args
*/
public static void main(String[] args) {

try {
Context context = new InitialContext();
Object ref = context.lookup("StatelessCalculatorBean/remote");
StatelessCalculator calc = (StatelessCalculator) PortableRemoteObject
.narrow(ref, StatelessCalculator.class);

System.out.println("On Addition " + calc.add(12.0, 13.2));
System.out.println("On Addition " + calc.subtract(13.0, 12.0));
System.out.println("On Addition " + calc.add(12.0, 12.0));
System.out.println("On Addition " + calc.add(12.0, 4.0));
} catch (NamingException e) {
Throwable t = new Throwable();

System.err.println(t.getCause());
e.printStackTrace();
}
}

}

******************************************************************

This is Remote Class

package com.npi.ejb;

import javax.ejb.Remote;

@Remote
public interface StatelessCalculator {

public double add(double x,double y);
public double subtract(double x,double y);
public double multiply(double x,double y);
public double divide(double x,double y);

}


****************************************

This is my Bean Class
***********************************************************
package com.npi.ejb;

import javax.ejb.Stateless;
import com.npi.ejb.StatelessCalculator;

public @Stateless class StatelessCalculatorBean implements StatelessCalculator {

public double add(double x, double y) {

return (x+y);
}

public double divide(double x, double y) {

return (x-y);
}

public double multiply(double x, double y) {

return (x*y);
}

public double subtract(double x, double y) {
if(y ==0.0)
{
throw new javax.ejb.EJBException("Number Divided By Zero");
}

return (x/y);
}

}
********************************************

I am really in big trouble since last 20 days
If by tommorrow i could not run it i will leave EJB 3.0

Thanks for your early response
 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I followed a nice example from
http://java.boot.by/scbcd5-guide/apcs05.html

but whenever i run client it shows me the error that i posted in my first post
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reading from context, you need to packaged your EJB Client and yung EJB jar into an EAR and deploy it so that the references to the JNDI names of the EJB will be visible to the EJB Client.

First and foremost, you cannot reference a resource using JNDI when the client is outside the container unless of course you have a facilitry of recreating the environment or connecting to the same JNDI resource in the app server.

I am not sure if initializing the Context object in the EJB client and manually loading the JNDI names will reference the same instance present in the container.

I hope this helps.
 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for Reply !!

But tell me that how would i come to knoe that client is outside of container ??
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any standard J2SE program is outside the container.

When you packaged the J2SE program with the EJB JAR in an EAR and deploy it to the application server, then the program is inside the container.

Regards.
 
Fidel Edwards
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jerwin,

Means you want to say that say container uses jdk1.5 and i run my client in jdk 1.6.0 .Then will the client be local ??


Isn't it ??
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic