JBoss AS 7无法实例化类

时间:2013-10-04 17:22:02

标签: java maven jboss

我有2个maven模块的项目 - 服务器和客户端。 我使用JBoss 6.0.0和IDEA 12。

服务器:

import javax.ejb.*;
@Remote
public interface db {
    int hi();
}

+ 

import javax.ejb.*;
@Stateless
public class dbBean implements db {
public int hi()
{
    return 777;
}
}

客户端:

public class Main {
    public static void main (String [] args)
    {
        Frame f = new Frame("Hey");
        f.setSize(300, 300);
        f.setVisible(true);
        Label lb = new Label();
        lb.setAlignment(Label.CENTER);
        try
        {
        Context context;
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
        props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
        props.setProperty("java.naming.provider.url", "jnp://127.0.0.1:1099");
        context = new InitialContext(props);
        Object connectionFacadeRemote = context.lookup("dbBean/remote");
        db exampleService = (db) connectionFacadeRemote;
            lb.setText(Integer.toString(exampleService.hi()));

        }
        catch (NamingException e)
        {
          System.out.println(String.valueOf(e));
        }
        f.add(lb);
    }
}

客户端也有该界面的副本。 它在IDEA ide中工作正常,应用程序返回我的777结果:) 但如果我试图从cmd执行它:

mvn exec:java -Dexec.mainClass="Main" // main class called "Main"

我会收到错误:

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

客户的清单是:

Manifest-Version: 1.0
Main-Class: Main

那为什么它不能在IDE之外工作?

0 个答案:

没有答案