Discussion:
[jboss-user] [JNDI and Naming] - javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
jashan07
2013-07-24 13:10:05 UTC
Permalink
jashan07 [https://community.jboss.org/people/jashan07] created the discussion

"javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]"

To view the discussion, visit: https://community.jboss.org/message/829512#829512

--------------------------------------------------------------
Hi,

I am trying to run my application on 6.0.1 EAP and m getting the following error:


javax.naming.NoInitialContextException

Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException


I found from some forums that i have to add jbossall-client.jar file but jboss 6.0.1 doesnt contain any jar like this.
Can any one help me to get out of this problem?
my BookClient code:

*public* *class* BookClient {
*public static void* *main(String z[]) {*


*try* *{*
*int* *choice = 1;**Properties p =*
*new* *Properties();**p.put(Context.*
++*INITIAL_CONTEXT_FACTORY*++*,*
*"org.jnp.interfaces.NamingContextFactory"**);**p.put(Context.*
++*URL_PKG_PREFIXES*++*,*
*"org.jboss.naming:org.jnp.interfaces"**);**p.put(Context.*
++*PROVIDER_URL*++*, "localhost:4447"**);**InitialContext ctx =*
*new* *InitialContext(p);*
*BookHome home = (BookHome) ctx.lookup(*
*"BK"**);*
*Book bean = home.create();*
*Scanner sc =*
*new Scanner(System.+*+in+*+**);*
*while* *(choice != 2) {**String bname;*
*System.*
++*out*++*.println("Enter choice 1. Add 2. Over"**);**choice = sc.nextInt();*

*if* *(choice == 1) {**System.*
++*out*++*.println("Enter book name"**);**bname = sc.next();*
*bean.addBook(bname);*
*}*
*else if* *(choice == 2) {*
*break**;**}*
*}*

*Vector v = bean.getBooks();*

*System.*
++*out*++*.println("Size of vector \t"* *+ v.size());*
*for (int* *i = 0; i < v.size(); ++i) {**System.*
++*out*++*.println((String) v.elementAt(i));**}*

*}*
*catch* *(Exception e) {**System.*
++*out*++*.println(e);**}*
*}*



*where is the error or which jar file i need to add or modification i need to do?*

*Thanks,*
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/829512#829512]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Loading...