关于JBoss入门
刚刚做了个JBoss入门:报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这样的错,
求解决方案,在此谢过
java代码:
-------------------------------------------------------
package com.sls.ejb3;
public interface HelloEJB3 {
public String sayHello(String name);
}
-------------------------------------------------------
package com.sls.ejb3.impl;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import com.sls.ejb3.HelloEJB3;
@Stateless
@Remote(HelloEJB3.class)
// @Stateless 这个注解可以指定类是个无状态的会话bean
public class HelloEjb3Bean implements HelloEJB3 {
@Override
public String sayHello(String name) {
return name + "说:你好,世界....";
}
}
-------------------------------------------------------
客户端代码:
public static void main(String[] args) {
// Properties props = new Properties();
// props.setProperty("java.namint.jactory.initial",
// "org.jnp.interfaces.NamingContextFactory");
// props.setProperty("java.naming.provider.url", "localhost:1099");
InitialContext ctx;
try {
ctx = new InitialContext();
System.out.println("110" + ctx);
HelloEJB3 helloEJB3 = (HelloEJB3) ctx
.lookup("java:helloEjb3/HelloEjb3Bean/remote");
System.out.println(helloEJB3.getClass().getName());
// System.out.println(helloEJB3.sayHello("尚立帅"));
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
-------------------------------------------------------
jndi.properties代码:
java.namint.jactory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
--------------------------------------------------------------
HelloEJB3 helloEJB3 = (HelloEJB3) ctx.lookup("java:helloEjb3/HelloEjb3Bean/remote")
改为
HelloEJB3 helloEJB3 = (HelloEJB3) ctx.lookup("HelloEjb3Bean/remote")
也不行啊!
helloEJB3没值啊!
我觉得还是ctx.lookup("HelloEjb3Bean/remote")这儿有问题啊!
求高手赐教!谢谢了
[解决办法]
http://patmusing.blog.163.com/blog/static/1358349602010015105351448/
给个图文例子博客的网址你,你自己看看,都很详细了
[解决办法]
你是用什么版本的jboss啊
[解决办法]
http://learning.iteye.com/blog/1274103
里面有ejb例子跟源码
[解决办法]
初学的话我建议用jboss5.0+ejb3.0,网上例子多数是这版本的,其他版本的例子少,出错也难找