Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

problem on portable remote object

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have written a bean file for testing.

the remote interface is: -

----------------------------------------------------------------------------------------

import javax.ejb.*;
import java.rmi.*;
public interface login extends EJBObject
{
public int validate(String name, String pass) throws RemoteException;
}

-------------------------------------------------------------------------------------------

the home interface is: -

---------------------------------------------------------------------------------------

import javax.ejb.*;
import java.io.*;
import java.rmi.*;
public interface loginHome extends EJBHome
{
login create() throws RemoteException, CreateException;
}

----------------------------------------------------------------------------------------

the EJB file is: -

----------------------------------------------------------------------------------------

import java.rmi.*;
import javax.ejb.*;
public class loginEJB implements SessionBean
{
public int validate (String name, String pass)
{
int i=0;
if (name.equals("admin") && pass.equals("test"))
{
i=1;
}
return i;
}
public loginEJB() {}
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbRemove() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sc) {}
}

-----------------------------------------------------------------------------------------------------

i have compiled and deployed the three class files in j2ee and the return client jar path to the classpath

my client code is: -

-----------------------------------------------------------------------------------------------------

import javax.naming.*;
import javax.rmi.*;

public class loginClient
{
public static void main(String args[])
{
try
{
Context ic = new InitialContext();
Object obj = ic.lookup("loginjndi");
loginHome h = (loginHome)PortableRemoteObject.narrow(obj, loginHome.class);
login user = home.create();
int a = user.validate("admin","test");
if (a==1)
System.out.println("Successfull");
else
System.out.println("no!");
}
catch(Exception e)
{
System.out.println(e);
}
}
}

--------------------------------------------------------------------------------------------------------------------------

the client code does not compile and gives the following error: -


loginClient.java:12: cannot resolve symbol
symbol : class loginHome
location: class loginClient
loginHome h = (loginHome)PortableRemoteObject.narrow(obj, loginH
ome.class);
^
loginClient.java:12: cannot resolve symbol
symbol : class loginHome
location: class loginClient
loginHome h = (loginHome)PortableRemoteObject.narrow(obj, loginH
ome.class);
^
loginClient.java:12: cannot resolve symbol
symbol : class loginHome
location: class loginClient
loginHome h = (loginHome)PortableRemoteObject.narrow(obj, loginH
ome.class);
^
loginClient.java:13: cannot resolve symbol
symbol : class login
location: class loginClient
login user = home.create();
^
loginClient.java:13: cannot resolve symbol
symbol : variable home
location: class loginClient
login user = home.create();
^
5 errors

--------------------------------------------------------------------------------------------------

any help

Pradyut
http://pradyut.tk

India
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prodyut,
Aparently theer r two problems -

1. loginHome h = (loginHome)PortableRemoteObject.narrow(obj,loginHome.class);
login user = home.create();

Here you defind once home interface with "h" next time you used it by calling "home"

2. Which app server you are using?
Please check ejb-jar.xml field name "jndi", it's case sensative too.
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic