Java 如何在netbean6.7中开发和运行ejb?

Java 如何在netbean6.7中开发和运行ejb?,java,netbeans,ejb-3.0,Java,Netbeans,Ejb 3.0,我是学习EJB的初学者。我想在netbean 6.7中测试非常非常小的ejb应用程序。代码如下 package jeenptbeans; import javax.ejb.Remote; @Remote public interface NewSessionRemote { public String getEchoString(String clientString); } package jeenptbeans; import javax.ejb.Stateless; @Sta

我是学习EJB的初学者。我想在netbean 6.7中测试非常非常小的ejb应用程序。代码如下

package jeenptbeans;
import javax.ejb.Remote;
@Remote
public interface NewSessionRemote {
    public String getEchoString(String clientString);

}

package jeenptbeans;
import javax.ejb.Stateless;

@Stateless
public class NewSessionBean implements NewSessionRemote, NewSessionLocal {

 public String getEchoString(String clientString) {
return clientString + " - from session bean";
}
 public String getdisString(String clientString) {
return clientString + " - from session bean";
}
因此,我创建了文件-->新建项目-->EJB模块。右键单击该项目并选择新建-->会话bean并添加上述代码。但我运行该项目时,会显示“build successfully”消息。因此,我想用客户端应用程序测试该bean。所以我制作了“企业应用程序客户端”应用程序并添加了ejb,如下所示

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.naming.NamingException;
import jeenptbeans.NewSessionRemote;
import javax.naming.InitialContext;
import jeenptbeans.NewSessionBean;

public class Main {
    @EJB
    private static NewSessionRemote newSessionBean;
   public static void main(String[] args) {
        try {
              InitialContext ctx = new InitialContext();
             newSessionBean = (NewSessionBean)ctx.lookup(NewSessionBean.class.getName());

            for (int i = 0; i < args.length; i++) {
            String returnedString = newSessionBean.getEchoString(args[i]);
            System.out.println("sent string: " + args[i] +
            ", received string: " + returnedString);
            }
        } catch (NamingException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
import java.util.logging.Level;
导入java.util.logging.Logger;
导入javax.ejb.ejb;
导入javax.naming.NamingException;
导入jeenptbeans.NewSessionRemote;
导入javax.naming.InitialContext;
导入jeenptbeans.NewSessionBean;
公共班机{
@EJB
私有静态NewSessionRemoteNewSessionBean;
公共静态void main(字符串[]args){
试一试{
InitialContext ctx=新的InitialContext();
newSessionBean=(newSessionBean)ctx.lookup(newSessionBean.class.getName());
对于(int i=0;i
但是当我运行这个客户端应用程序时,我得到了以下异常


“SEC5046:审核:拒绝[admin]的身份验证。 Web登录失败:登录失败:javax.security.auth.login.login异常:管理员文件登录失败。 CORE5024:EJB模块[JEENNPT-SessionEJB1]已成功卸载! 使用moduleid=JEENPT-SessionEJB1部署 **RemoteBusinessJndiName:jeenptbeans.NewSessionRemote;remoteBusIntf:jeenptbeans.NewSessionRemote LDR5010:[JEENPT-SessionEJB1]的所有ejb均已成功加载! ADM1006:将文件上载到:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1ASTEMPDomain1Server 1142715591\jeennpt-AppEJBClient1.jar] 找不到类[jeenptbeans/NewSessionRemote]。加载[Class jeenptapejbclient1.Main]时出错 注释处理中出错:java.lang.NoClassDefFoundError:jeenptbeans/NewSessionRemote 使用moduleid=JEENPT-AppEJBClient1部署 注册临时servlet:WebPathPath:context root=“/jeennpt-AppEJBClient1”,path=“” 已为独立应用程序客户端com.sun.enterprise.appclient.jws启动Java Web Start服务。AppclientContentOrigin@1bb5013注册名称=JEENNPT-AppEJBClient1,上下文根=/JEENNPT-AppEJBClient1,模块名称= CORE5024:EJB模块[JEENNPT-SessionEJB1]已成功卸载! 使用moduleid=JEENPT-SessionEJB1部署 **RemoteBusinessJndiName:jeenptbeans.NewSessionRemote;remoteBusIntf:jeenptbeans.NewSessionRemote LDR5010:[JEENPT-SessionEJB1]的所有ejb均已成功加载! classLoader=WebappClassLoader 代表:错 存储库: ---------->父类加载器: WebappClassLoader 代表:是的 存储库: /WEB-INF/课程/ ---------->父类加载器: EJBClassLoader: urlSet=[] doneCalled=false 父->java.net。URLClassLoader@103de90 SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@cf10ae 独立应用程序客户端com.sun.enterprise.appclient.jws的Java Web Start服务已结束。AppclientContentOrigin@1bb5013注册名称=JEENNPT-AppEJBClient1,上下文根=/JEENNPT-AppEJBClient1,模块名称= ADM1064:位于[C:\Documents and Settings\Yamin\Local Settings\Temp\s1ASTEMPDomain1Server 1142715591\jeennpt-AppEJBClient1.jar]的上载文件已存在并将被覆盖。 ADM1006:将文件上载到:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1ASTEMPDomain1Server 1142715591\jeennpt-AppEJBClient1.jar] 找不到类[jeenptbeans/NewSessionRemote]。加载[类jeenptapejbclient1.Main]时出错 注释处理中出错:java.lang.NoClassDefFoundError:jeenptbeans/NewSessionRemote 使用moduleid=JEENPT-AppEJBClient1部署 注册临时servlet:WebPathPath:context root=“/jeennpt-AppEJBClient1”,path=“” 已为独立应用程序客户端com.sun.enterprise.appclient.jws启动Java Web Start服务。AppclientContentOrigin@db05a8注册名称=JEENNPT-AppEJBClient1,上下文根=/JEENNPT-AppEJBClient1,模块名称= CORE5024:EJB模块[JEENNPT-SessionEJB1]已成功卸载! classLoader=WebappClassLoader 代表:错 存储库: ---------->父类加载器: WebappClassLoader 代表:是的 存储库: /WEB-INF/课程/ ---------->父类加载器: EJBClassLoader: urlSet=[] doneCalled=false 父->java.net。URLClassLoader@103de90 SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@cf10ae 独立应用程序客户端com.sun.enterprise.appclient.jws的Java Web Start服务已结束。AppclientContentOrigin@db05a8注册名称=JEENNPT-AppEJBClient1,上下文根=/JEENNPT-AppEJBClient1,模块名称= ADM1064:位于[C:\Documents and Settings\Yamin\Local Settings\Temp\s1ASTEMPDomain1Server 1142715591\jeennpt-AppEJBClient1.jar]的上载文件已存在并将被覆盖。 ADM1006:将文件上载到:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1ASTEMPDomain1Server 1142715591\jeennpt-AppEJBClient1.jar] 找不到类[jeenptbeans/NewSessionRemote]。加载[Class jeenptapejbclient1.Main]时出错 注释处理中出错:java.lang.NoClassDefFoundError:jeenptbeans/NewSessionRemote 使用moduleid=JEENPT-AppEJBClient1部署 注册临时servlet:WebPathPath:context root=“/jeennpt-AppEJBClient1”,path=“” 已为独立应用程序客户端com.sun.enterprise.appclient.jws启动Java Web Start服务。AppclientContentOrigin@8500bc注册名称=JEENNPT-AppEJBClient1,上下文根=/JEENNPT-AppEJBClient1,模块名称=
请帮帮我。让“企业应用程序客户端”应用程序测试简单会话bean是对还是错?我也不知道在哪里为主函数添加参数。到 "SEC5046: Audit: Authentication refused for [admin]. Web login failed: Login failed: javax.security.auth.login.LoginException: Failed file login for admin. CORE5024: EJB module [JEENPT-SessionEJB1] unloaded successfully! deployed with moduleid = JEENPT-SessionEJB1 **RemoteBusinessJndiName: jeenptbeans.NewSessionRemote; remoteBusIntf: jeenptbeans.NewSessionRemote LDR5010: All ejb(s) of [JEENPT-SessionEJB1] loaded successfully! ADM1006:Uploading the file to:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] Class [ jeenptbeans/NewSessionRemote ] not found. Error while loading [ class jeenptappejbclient1.Main ] Error in annotation processing: java.lang.NoClassDefFoundError: jeenptbeans/NewSessionRemote deployed with moduleid = JEENPT-AppEJBClient1 Registering ad hoc servlet: WebPathPath: context root = "/JEENPT-AppEJBClient1", path = "' Java Web Start services started for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@1bb5013 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name= CORE5024: EJB module [JEENPT-SessionEJB1] unloaded successfully! deployed with moduleid = JEENPT-SessionEJB1 **RemoteBusinessJndiName: jeenptbeans.NewSessionRemote; remoteBusIntf: jeenptbeans.NewSessionRemote LDR5010: All ejb(s) of [JEENPT-SessionEJB1] loaded successfully! classLoader = WebappClassLoader delegate: false repositories: ----------> Parent Classloader: WebappClassLoader delegate: true repositories: /WEB-INF/classes/ ----------> Parent Classloader: EJBClassLoader : urlSet = [] doneCalled = false Parent -> java.net.URLClassLoader@103de90 SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@cf10ae Java Web Start services ended for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@1bb5013 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name= ADM1064:The upload file at [C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] exists and will be overwritten. ADM1006:Uploading the file to:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] Class [ jeenptbeans/NewSessionRemote ] not found. Error while loading [ class jeenptappejbclient1.Main ] Error in annotation processing: java.lang.NoClassDefFoundError: jeenptbeans/NewSessionRemote deployed with moduleid = JEENPT-AppEJBClient1 Registering ad hoc servlet: WebPathPath: context root = "/JEENPT-AppEJBClient1", path = "' Java Web Start services started for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@db05a8 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name= CORE5024: EJB module [JEENPT-SessionEJB1] unloaded successfully! classLoader = WebappClassLoader delegate: false repositories: ----------> Parent Classloader: WebappClassLoader delegate: true repositories: /WEB-INF/classes/ ----------> Parent Classloader: EJBClassLoader : urlSet = [] doneCalled = false Parent -> java.net.URLClassLoader@103de90 SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@cf10ae Java Web Start services ended for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@db05a8 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name= ADM1064:The upload file at [C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] exists and will be overwritten. ADM1006:Uploading the file to:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] Class [ jeenptbeans/NewSessionRemote ] not found. Error while loading [ class jeenptappejbclient1.Main ] Error in annotation processing: java.lang.NoClassDefFoundError: jeenptbeans/NewSessionRemote deployed with moduleid = JEENPT-AppEJBClient1 Registering ad hoc servlet: WebPathPath: context root = "/JEENPT-AppEJBClient1", path = "' Java Web Start services started for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@8500bc registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name=