[jboss-user] [JNDI/Naming/Network] - Re: javax.naming.NoInitialContextException: Can't find prope

joepareti do-not-reply at jboss.com
Fri May 2 05:17:35 EDT 2008


After a long time I am revisiting this topic and even though I tried to implement your advise the very same error message stays:

javax.naming.NoInitialContextException: Can't find property: java.naming.factory.initial

Below are the details on what I did. TIA for any further help.

SOURCE CODE MODIFICATIONS

package za.co.solms.finance.calculators;
import javax.naming.Context;
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import swingwt.awt.*;
import java.text.*;
import java.util.*;
import swingwtx.swing.*;
import swingwt.awt.event.*;
public class LoanCalculatorClient extends JFrame
{
public LoanCalculatorClient()
{
setTitle("Solms Training Loan Calculator");
java.util.Hashtable properties = new java.util.Hashtable();
properties.put(Context.PROVIDER_URL,"localhost:1099");
properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.rmi.security.manager", "yes");
/*env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming.client:org.jnp.interfaces");*/
/* this is default env.put(jnp.socketFactory,"org.jnp.interfaces.TimedSocketFactory"); */
/* Context initialContext = new InitialContext(env); */
javax.naming.Context context = new javax.naming.InitialContext(properties);
calculatorPanel = new LoanCalculatorPanel();
getContentPane().add(calculatorPanel);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent event)
{
calculatorPanel.destroy();
System.exit(0);
}
});
pack();
}
public static void main(String[] args)

{
new LoanCalculatorClient().show();
}
private LoanCalculatorPanel calculatorPanel;
}

=======

public void connect()
{
try
{
InitialContext jndiContext = new InitialContext();
System.out.println("Now looking up session bean " + jndiName + " ...");
java.util.Hashtable properties = new java.util.Hashtable();
properties.put(Context.PROVIDER_URL,"localhost:1099");
properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.rmi.security.manager", "yes");
javax.naming.Context context = new javax.naming.InitialContext(properties);
Object beanHomeRef
= jndiContext.lookup(jndiName);
System.out.println("got it");
LoanCalculatorHome home =
(LoanCalculatorHome)PortableRemoteObject.narrow
(beanHomeRef, LoanCalculatorHome.class);
loanCalculator = home.create();
}

ERRORS IN THE LOG FILE FROM BUILDING THE CLIENT JAR

/usr/local/samba/tmp/jboss/jboss_demo_solms/src/client/application/LoanCalculatorClient.java:17: error: Undefined variable or class name: `java.naming.factory.initial'.
    [javac]    env.put(java.naming.factory.initial,"org.jnp.interfaces.NamingContextFactory");
    [javac]            ^
    [javac]

This has been fixed by using:

properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

in lieu of:

properties.put(java.naming.factory.initial,"org.jnp.interfaces.NamingContextFactory");

This may be a coincidence, but the client run-time error also refers to "java.naming.factory.initial" ; so I am starting to suspect a more fundamental problem with java.
 


ALTERNATIVE WAYS TO ACCESS THE JNDI SERVICE?

Because I think the following java statement causes the exception:

Object beanHomeRef
= jndiContext.lookup(jndiName);

I am wondering if one could use instead something like:

Object beanHomeRef
= jndiContext.lookup("java:/path");

Or 

Java.lang.Object ejbHome = 
= initialContext.lookup("ava:/path");


WARNINGS IN THE LOG FILE FROM BUILDING THE CLIENT JAR

I don't know how serious the following are:

    [javac] Using gcj compiler
dropping /usr/local/samba/tmp/jboss/jboss_demo_solms/${classpath} from path as it doesn't exist

and 

Property ${classpath} has not been set

-	is classpath case sensitive?
-	I know from a previous experience that classpath was fixed by just listing jar files; in this case it does indeed contain jar files AND regular directories ???



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4148285#4148285

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4148285



More information about the jboss-user mailing list