aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Error in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Error in EJB" Watch "Error in EJB" New topic
Author

Error in EJB

dhinakar Meenakshi Sundaram
Greenhorn

Joined: Mar 22, 2004
Posts: 3
Hi All I am new to this EJB concept,
I have successfully deployed the EJB, but when i execute the Client I am getting the below error please give a solution for this.
-->
package EJB;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.naming.Context;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import java.lang.*;

public class myClient extends JFrame
{
public static int w=500;
public static int h=95;
public static String str = "Polaris Welcomes You";
public static String value1, value2;
Container cnr;

JLabel lblNumber1, lblNumber2, lblResult;
JTextField txtNumber1, txtNumber2;
JButton butAdd;
public myClient()
{
super(str);
cnr = getContentPane();
cnr.setLayout(new GridLayout(3, 3, 2, 2));
lblNumber1 = new JLabel("Number 1:");
lblNumber2 = new JLabel("Number 2:");
lblResult = new JLabel("Result");
txtNumber1 = new JTextField(10);
txtNumber2 = new JTextField(10);
butAdd = new JButton("Add");
cnr.add(lblNumber1);
cnr.add(txtNumber1);
cnr.add(lblNumber2);
cnr.add(txtNumber2);
cnr.add(lblResult);
cnr.add(butAdd);
butAdd.addActionListener(new addEvent());
setSize(w, h);
show();
}

public static void main(String args[])
{
new myClient();
}

public class addEvent implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
int num1 = Integer.parseInt(txtNumber1.getText());
int num2 = Integer.parseInt(txtNumber2.getText());
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
env.put(Context.PROVIDER_URL,
"http://localhost:8080");
Context initialContext = new InitialContext(env);
Context iContext = new InitialContext();
Object obj = iContext.lookup("java:comp/env/ejb/myEJBClass");
myHome home = (myHome)PortableRemoteObject.narrow(obj, EJB.myHome.class);
myRemote remote = home.create();
int res = remote.myMethod(num1, num2);
lblResult.setText("Result Is: " + Integer.toString(res));
}
catch(NamingException e)
{
System.out.println(e);
e.printStackTrace();
}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
}
}
}
<--

Exception in thread "main" java.lang.NoClassDefFoundError: myClient (wrong name:
EJB/myClient)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
C:\Dhinakar\Programs\Java\EJB>java EJB.myClient > err.txt
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterp
rise.naming.SerialInitContextFactory. Root exception is java.lang.ClassNotFound
Exception: com.sun.enterprise.naming.SerialInitContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
49)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at EJB.myClient$addEvent.actionPerformed(myClient.java:65)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)


  • dhinakar
    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17260
        
        6

    Dhinikar,
    I am going to move this thread to the, more appropriate, EJB forum. This forum is for Servlets questions.
    You will get a much better response form that forum.
    Mark


    Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
    How to Ask Questions the Smart Way FAQ
    Marcos Maia
    Ranch Hand

    Joined: Jan 06, 2001
    Posts: 977
    Hi,
    the class, com.sun.enterprise.naming.SerialInitContextFactory is missing for the client classpath. You'll have to check your classpath and put the classes the client need under it's classpath, usually you do this setting a environment variable or running some script before running the client.
    regards.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Error in EJB