• 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

Error In EJB

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I havent gone thru ur code fully . But , page 494 of the spec says that "An enterprise Bean must not use the AWT functionality to attempt to output information to a display, or to input information from a keyboard."
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your naming context provider's URL seems wrong. Double check the documentation.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramakrishna Allam:
I havent gone thru ur code fully . But , page 494 of the spec says that "An enterprise Bean must not use the AWT functionality to attempt to output information to a display, or to input information from a keyboard."


Yes, you are right. But this is a just swing EJB client program, which is OK. The specs only forbids the use of IO/UI classes in the enterprise bean classes.
 
dhinakar Meenakshi Sundaram
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic