Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.reflect.InvocationTargetException  RSS feed

 
Mirela Muntean
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello,

I am trying to learn EJB3, and I started to read "EJB in Action".
The first example is very simple, yet it doesn't seem to wprk for me:
It looks like that:

package bean;
import javax.ejb.Remote;


@Remote
public interface HelloFirstUser {
public void sayHello(String name);
}

//--------------------------------------------------------------------------

package bean;
import javax.ejb.Stateless;


@Stateless
public class HelloFirstUserBean implements HelloFirstUser {
public void sayHello(String name) {
System.out.println("Hello " + name + " welcome to EJB 3 In Action!");
}
}

//--------------------------------------------------------------------------

package client;

import bean.HelloFirstUser;
import javax.ejb.EJB;
import javax.naming.*;


public class HelloFirstUserClient {

@EJB
private static HelloFirstUser helloUser;

public static void main(String[] args) throws Exception{

helloUser.sayHello("Hello world to the first user ... ");
System.out.println("Invoked EJB successfully .. see server console for output");
}
}

//-------------------------------------------------------------------------------------------------------------

I used the deploy and run targets in the ant build file, but when running the first example I get the error:

Executing client class using D:\Sun\SDK/bin/appclient.bat
[exec] 08.02.2009 12:15:49 com.sun.enterprise.deployment.annotation.impl.DefaultErrorHandler error
[exec] SEVERE: Class [ Lbean/HelloFirstUser; ] not found. Error while loading [ class client.HelloFirstUserClient ]
[exec] 08.02.2009 12:15:49 com.sun.enterprise.deployment.archivist.Archivist readAnnotations
[exec] WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: Lbean/HelloFirstUser;
[exec] 08.02.2009 12:15:50 com.sun.enterprise.appclient.MainWithModuleSupport <init>
[exec] WARNING: ACC003: Application threw an exception.
[exec] java.lang.NoClassDefFoundError: bean/HelloFirstUser
[exec] at client.HelloFirstUserClient.main(HelloFirstUserClient.java:15)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:585)
[exec] at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:329)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:180)
[exec] Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:340)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:180)
[exec] Caused by: java.lang.reflect.InvocationTargetException
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:585)
[exec] at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:329)
[exec] ... 1 more
[exec] Caused by: java.lang.NoClassDefFoundError: bean/HelloFirstUser
[exec] at client.HelloFirstUserClient.main(HelloFirstUserClient.java:15)
[exec] ... 7 more

What could be the problem ? Please give me a hint, because I cannot run the simplest example.

thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!