Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can't call method lookup("path") of Entity Bean  RSS feed

Truc Nguyen
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use MyEclipse 6.5 and Jboss_5 Server.
I create classes about bean: SinhvienFacade,local: SinhvienFacadeLocal, remove: SinhvienFacadeRemove
And then I write code in method main() to run:
package ex;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Properties;
import javax.naming.*;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.genuitec.Sinhvien;
import com.genuitec.SinhvienFacade;

public class Calling1 {

* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");
List<Sinhvien> listSinVien = new ArrayList<Sinhvien>();
try {
System.out.print("vao ham 1");
InitialContext ctx = new InitialContext(properties);
//Object ref = ctx.lookup(" com.genuitec.SinVienFacade");
SinhvienFacade bean = ( SinhvienFacade) ctx.lookup("com.genuitec.SinVienFacade");
System.out.print("vao ham 2");
listSinVien = bean.findAll();
for (int i = 0; i< listSinVien.size();i++) {
System.out.print("MaSV: " + listSinVien.get(i).getMaSv());
System.out.print("Ten: " + listSinVien.get(i).getTenSv());
} catch (NamingException e)
System.out.print("loi: " + e.getMessage());



I receive error:
vao ham 1loi: Cannot instantiate class: org.jnp.interfaces.NamingContextFactoryjavax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at ex.Calling1.main(
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more

Can you help me!!
Thanks you verry much.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!