Win a copy of Machine Learning with TensorFlow this week in the Artificial Intelligence and Machine Learning forum!

dhinakar Meenakshi Sundaram

Greenhorn
+ Follow
since Mar 22, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dhinakar Meenakshi Sundaram

F1 me... Radhakrishna / EDU / Kumar,
Thanks for the reply...
I have taken all the AWT related stuffs...
The errors are minimized but still i am getting the error.
Code-->
import javax.swing.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
public class CalculatorClient extends JFrame
{
public CalculatorClient()
{
double dbl = 10.20;
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "http://localhost:8080");
Context ic = new InitialContext(env);
System.out.println("Executing...Context ic = new InitialContext()");
Object obj = ic.lookup("CalculatorJNDI");
System.out.println("Executing...Object obj = ic.lookup(CalculatorJNDI)");
CalculatorHome home = (CalculatorHome)PortableRemoteObject.narrow(obj, CalculatorHome.class);
System.out.println("Executing...CalculatorHome home = (CalculatorHome)PortableRemoteObject.narrow(obj, CalculatorHome.class)");
Calculator calc = home.create();
System.out.println("Executing...Calculator calc = home.create()");
double amt = calc.dollarToRs(dbl);
System.out.println("Executing...amt = calc.dollarToRs(dbl)");
System.out.println("Result(Rs.): " + String.valueOf(amt));
System.out.println("Executing...result.setText(Result(Rs.): + String.valueOf(amt))");
}
catch(Exception ex)
{
System.err.println("Executing...Caught an un UnExpected Exception !");
ex.printStackTrace();
}
}
public static void main(String args[])
{

new CalculatorClient();
}
}
Code<---
Error--->
Executing...Caught an un UnExpected Exception !
javax.naming.ConfigurationException: http://localhost:8080 does not contain an IOR
at com.sun.jndi.cosnaming.CNCtx.getStringifiedIor(CNCtx.java:421)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContextCNCtx.java:198)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContextCNCtxFactory.java:32)
at javax.naming.spi.NamingManager.getInitialContextNamingManager.java:6
62)
at javax.naming.InitialContext.getDefaultInitCtxInitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at CalculatorClient.<init>(CalculatorClient.java:19)
at CalculatorClient.main(CalculatorClient.java:43)
Error<---
Help me
[ April 05, 2004: Message edited by: dhinakar Meenakshi Sundaram ]
[ April 05, 2004: Message edited by: dhinakar Meenakshi Sundaram ]
Hi,
I am getting an Error while running an EJB client.
I am using an Container bean(StateLess)
This is the code i am using
--->
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.naming.Context;
import javax.naming.*;
import javax.ejb.*;
import java.rmi.*;
import javax.rmi.*;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
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();
System.out.println("Hashtable env = new Hashtable()");
//env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
System.out.println("env.put(Context.INITIAL_CONTEXT_FACTORY, com.sun.jndi.cosnaming.CNCtxFactory)");
env.put(Context.PROVIDER_URL, "http://localhost:8080");
System.out.println("env.put(Context.PROVIDER_URL, http://localhost:8080)");
Context iContext = new InitialContext(env);
//Context iContext = new InitialContext();
System.out.println("Setting Initial Context(env)");
//Object obj = iContext.lookup("java:comp/env/ejb/myEJBClass");
//System.out.println("lookup(myEJBClass)");
Context myEnv = (Context)iContext.lookup("java:comp/env");
System.out.println("(Context)iContext.lookup(java:comp/env)");
Object obj = myEnv.lookup("ejb/myEJBClass");
System.out.println("myEnv.lookup(ejb/myEJBClass)");
myHome home = (myHome)PortableRemoteObject.narrow(obj, myHome.class);
System.out.println("(myHome)PortableRemoteObject.narrow(obj, myHome.class)");
myRemote remote = home.create();
System.out.println("home.create()");
int res = remote.myMethod(num1, num2);
System.out.println("remote.myMethod(num1, num2)");
lblResult.setText("Result Is: " + Integer.toString(res));
System.out.println("lblResult.setText(Result Is: + Integer.toString(res))");
}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
}
}
}
<--
Error Contents:
-->
javax.naming.ConfigurationException: http://localhost:8080 does not contain an IOR
javax.naming.ConfigurationException: http://localhost:8080 does not contain an IOR
at com.sun.jndi.cosnaming.CNCtx.getStringifiedIor(CNCtx.java:421)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:198)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:32)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
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 myClient$addEvent.actionPerformed(myClient.java:69)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.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(BasicButtonListener.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(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.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)
<--
Please help me to solve the problem...
Regards,
Dhinakar. M
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)