构建过程中的EJB + Webservice错误

时间:2014-03-21 04:04:44

标签: web-services java-ee jpa

我是一名java初学者。我使用netbean创建项目Java EE>企业应用程序并从数据库创建实体类并创建JPA持久性(我不确定这样称呼)。所以当我创建ejb时已经完成了。我将通过Web服务使用call ejb。当我使用带有ejb类的web服务或调用ejb时,这是我的问题。它可以构建和部署应用程序,但是当我使用ejb时。我从bulid应用程序得到错误。任何人都可以解释我解决这个问题。

此错误构建过程

Deploying D:\Project\Source\Dev\PYS\PYSServices\PYSServices-war\dist\PYSServices-war.war
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"PYSServices-war.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"PYSServices-war.war\".POST_MODULE: Failed to process phase POST_MODULE of deployment \"PYSServices-war.war\""}}}}
D:\Project\Source\Dev\PYS\PYSServices\PYSServices-war\nbproject\build-impl.xml:1052: The module has not been deployed.

此服务器日志

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC00001: Failed to start service jboss.deployment.subunit."PYSServices.ear"."PYSServices-ejb.jar".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."PYSServices.ear"."PYSServices-ejb.jar".PARSE: Failed to process phase PARSE of subdeployment "PYSServices-ejb.jar" of deployment "PYSServices.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: org.jboss.msc.service.ServiceNotFoundException: Service service jboss.ejb.default-resource-adapter-name-service not found
    at org.jboss.msc.service.ServiceContainerImpl.getRequiredService(ServiceContainerImpl.java:447) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.getDefaultResourceAdapterName(MessageDrivenComponentDescriptionFactory.java:273)
    at org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.processMessageBeans(MessageDrivenComponentDescriptionFactory.java:153)
    at org.jboss.as.ejb3.deployment.processors.MessageDrivenComponentDescriptionFactory.processAnnotations(MessageDrivenComponentDescriptionFactory.java:81)
    at org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:58)
    at org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:81)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    ... 5 more

这是我的网络服务源代码。当我输入注释@EJB时,我的问题就会发生。它无法编译和构建到war文件。如果我不使用EJB,它可以构建和部署到jboss服务器成功。

公共类PysWebServices {

@Resource
WebServiceContext wsContext;

@EJB
private PysUserFacade pysUserFacade;

@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
    return "Hello " + txt + " !";
}

private boolean userValidate(String userid,String password, String email, String mobileno){
    boolean rev = true;

    if (userid != null && password != null && email != null && mobileno != null) { 

        if (userid.length() <5){ rev = false;}
        if (password.length() < 6) { rev= false;}
        if (!email.contains("@")) { rev = false;}
        if (mobileno.length() != 10) {rev = false; }

    } else {
        rev = false;
    }

    return rev;
}

@WebMethod(operationName="Create User")
public String crateUser(@WebParam(name="userId") String userid,@WebParam(name="userPassword") String password, @WebParam(name="eMail") String email, @WebParam(name="mobileNo") String mobileNo){
    String rev="";

    MessageContext mc = wsContext.getMessageContext();
    HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
    String clientIP = req.getRemoteAddr();

    if (userValidate(userid, password, email, mobileNo)){
        PysUser eUser = new PysUser();
        eUser.setUserId(userid);
        eUser.setUserPassword(password);
        eUser.setMobileNo(mobileNo);
        eUser.setCreateIp(clientIP);
        eUser.setCreateDtm(new Date());
        pysUserFacade.create(eUser);
        rev = "Create User Success";
    } else {
        rev = "Err001:Verify Create User Faile";
    }

    return rev;
}

}

1 个答案:

答案 0 :(得分:0)

没有得到你的问题,但我想看错误信息:

您可能需要在项目中激活/启用EJB规范。 确保在ejbs中包含所有必需的注释

希望这有帮助