javax.naming.NoInitialContextException
fredo Aug 23, 2001 12:44 PMHi,
I've deployed a bean in JBoss named ProductBean with the jndi name : MyProduct.
This bean is a container-managed one.
This bean works against a mysql DB :
DATABASE : ACCOUNT
TABLE : ProductBean
The deployment in JBoss is well done, i mean that the bean is deployed
and the table is well created.
I want to access this bean with a client (simple application)
and the exception which follows is caught when lookup :
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:646)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:283)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at ProductClient.main(ProductClient.java:12)
Here's the code and the properties of JBoss ...
-> Client CODE {
Context initial = new InitialContext();
>>> Object objref = initial.lookup("MyProduct");
}
************* files for deploying bean
--> jboss.xml {
<enterprise-beans>
<ejb-name>ProductBean</ejb-name>
<jndi-name>MyProduct</jndi-name>
</enterprise-beans>
}
--> jaws.xml {
mySQLDS
<type-mapping>MySQL SERVER</type-mapping>
<default-entity>
<remove-table>true</remove-table>
</default-entity>
<type-mappings>
....
}
--> ejb-jar.xml {
<ejb-jar>
no description
<display-name>ProductBean</display-name>
<enterprise-beans>
no description
<display-name>ProductBean</display-name>
<ejb-name>ProductBean</ejb-name>
ProductHome
Product
<ejb-class>ProductEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
False
<cmp-field>
...
}
************** JBoss property files
-> jboss.jcml {
org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImpl
mySQLDS
jdbc:mysql://myMachine:myPort/ACCOUNT
user
password
}
-> 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:org.jnp.interfaces
}
Can I have some suggestions please :))