• 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
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Naming Context problem

 
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to develop a simple session bean and deploy in jbos..but am getting an error while running the client..I was able to deppoy the EJB on the server but the client is giving errors....Can u please tell me Where i have to correct??


The Client
**************************************

package org.jboss.docs.interest;

import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import org.jboss.docs.interest.Interest;
import org.jboss.docs.interest.InterestHome;

/** This simple application tests the 'Interest' Enterprise JavaBean which is
implemented in the package 'org.jboss.docs.interest'. For this to work, the
Bean must be deployed on an EJB server.
*/
class InterestClient
{
/** This method does all the work. It creates an instance of the Interest EJB on
the EJB server, and calls its `calculateCompoundInterest()' method, then prints
the result of the calculation.
*/
public static void main(String[] args)
{
// Enclosing the whole process in a single `try' block is not an ideal way
// to do exception handling, but I don't want to clutter the program up
// with catch blocks
System.out.println("Inside the program");
try
{

System.out.println("before the context");
// Get a naming context
InitialContext jndiContext = new InitialContext();
System.out.println("Got context");

// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("interest/Interest");
System.out.println("Got reference");


// Get a reference from this to the Bean's Home interface
InterestHome home = (InterestHome)
PortableRemoteObject.narrow(ref, InterestHome.class);

// Create an Interest object from the Home interface
Interest interest = home.create();


// call the calculateCompoundInterest() method to do the calculation
System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
}
catch(Exception e)
{
System.out.println(e.toString());
System.out.println(e.getCause());
}

}
}

************************************************
End of Client code
************************************************



The jndi.properties file has the following entries...

JNDI.properties
*****************************************************

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces

********************************************************


The error is ...

Error is
**********************************************************

Inside the program
before the context
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Logger
at org.jnp.interfaces.NamingContext.<clinit>(NamingContext.java:103)
at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory
java:41)
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:175)
at org.jboss.docs.interest.InterestClient.main(InterestClient.java:30)
*****************************************************************

I ahve added the properites file to the classpath and run..the class ..

but still...


Appreciate all ur replies...

Bye,
A Kumar
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add jboss/client/jbossall-client.jar to you client classpath.
 
A Kumar
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks buddy....It worked fine...i got the rezult..

Bye
 
A Kumar
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of using a .properties file i tried to supply them

in the source code and it worked..

i made the change in the above code of the client file..

/**********
//Add a hashtable

Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
//props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming rg.jnp.interfaces");

System.out.println("Inside the program");
try
{

System.out.println("before the context");
// Get a naming context
InitialContext jndiContext =new InitialContext(props);

..........
...
..

****************8/

Thanks

Bye
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic