Approve Request WS - Final Approval Error

2010-07-22
2013-05-15
  • Yee Wen Biau

    Yee Wen Biau - 2010-07-22

    Hi,

    I am writing a approval request web service for ejbca 3_10_3

    below is my code in EjbcaWS.java:

    #############################################################

    public int approveRequest(int approvalId, boolean approve, String comment)
    throws AdminAlreadyApprovedRequestException, AuthorizationDeniedException, EjbcaException, ApprovalException {
            final IPatternLogger logger = TransactionLogger.getPatternLogger();
            try{
    EjbcaWSHelper ejbhelper = new EjbcaWSHelper();
    Admin admin = ejbhelper.getAdmin(wsContext);
    logAdminName(admin,logger);

    //search approvalId
    ApprovalDataVO appData = ejbhelper.getApprovalSession().findNonExpiredApprovalRequest(admin,approvalId); //findNonExpiredApprovalRequest(approvalId);
    if(appData.getApprovalId()!=approvalId){//approvalrequest not found
    return -90; //request not exist
    }else{
    if (appData.getStatus()!= ApprovalDataWS.STATUS_WAITINGFORAPPROVAL){
    return -90; //request not exist
    }
    }

    //check if the administrator is authorized using the follwing rules:
    int endEntityID = appData.getEndEntityProfileiId();
    int caID = appData.getCAId();

    if (endEntityID==1){
    ejbhelper.getAuthorizationSession().isAuthorizedNoLog(admin,AccessRulesConstants.REGULAR_APPROVECAACTION);
    }else {
    ejbhelper.getAuthorizationSession().isAuthorizedNoLog(admin, AccessRulesConstants.REGULAR_APPROVEENDENTITY);
    ejbhelper.getAuthorizationSession().isAuthorizedNoLog(admin, AccessRulesConstants.ENDENTITYPROFILEPREFIX + endEntityID + AccessRulesConstants.APPROVAL_RIGHTS );
    }

    ejbhelper.getAuthorizationSession().isAuthorizedNoLog(admin,AccessRulesConstants.CAPREFIX + caID);

    java.util.Collection previousApprovedList = appData.getApprovals();
    Iterator iter =  previousApprovedList.iterator();
        for(int i=0; i< previousApprovedList.size();i++){
        org.ejbca.core.model.approval.Approval tempApproval = (org.ejbca.core.model.approval.Approval) iter.next();
    if ( tempApproval.getAdmin().getUsername().equalsIgnoreCase(admin.getUsername())){
    return -91; //already approve or reject before
    }
        }

    org.ejbca.core.model.approval.Approval approval = new org.ejbca.core.model.approval.Approval(comment);
    approval.setApprovalAdmin(approve,admin);

    if (approve){ //approve
    ejbhelper.getApprovalSession().approve(admin, approvalId, approval,ejbhelper.getRAAdminSession().loadGlobalConfiguration(admin));
    }else {//reject
    ejbhelper.getApprovalSession().reject(admin, approvalId, approval,ejbhelper.getRAAdminSession().loadGlobalConfiguration(admin));
    }
    return 1; //success
    } catch (AuthorizationDeniedException authorizeEx){
    logger.paramPut(TransactionTags.ERROR_MESSAGE.toString(), authorizeEx.toString());
    throw authorizeEx;
    } catch ( Exception ex ) {
                logger.paramPut(TransactionTags.ERROR_MESSAGE.toString(), ex.toString());
                //throw ex;
    } finally {
        logger.writeln();
                logger.flush();
            }
    return -1;//unknow error
    }

    #############################################################

    my setting is, Add / Edit end entity required 2 approvals
    first approval always no problem, even reject also work fine.

    But second approval (which mean it will execute after that), I get the error below:

    #############################################################
    16:26:23,362 ERROR  TransactionRolledbackLocalException in method: public abstract void org.ejbca.core.ejb.approval.ApprovalDataLocal.approve(org.ejbca.core.model.approval.Approval) throws org.ejbca.core.model.approval.ApprovalRequestExpiredException,org.ejbca.core.model.approval.ApprovalRequestExecutionException,org.ejbca.core.EjbcaException, causedBy:
    org.ejbca.core.ejb.ServiceLocatorException: javax.naming.NameNotFoundException: UserAdminSessionLocal not bound
            at org.ejbca.core.ejb.ServiceLocator.getObject(ServiceLocator.java:160)
            at org.ejbca.core.ejb.ServiceLocator.getLocalHome(ServiceLocator.java:70)
            at org.ejbca.core.model.approval.approvalrequests.EditEndEntityApprovalRequest.execute(EditEndEntityApprovalRequest.java:83)
            at org.ejbca.core.ejb.approval.ApprovalDataBean.approve(ApprovalDataBean.java:485)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
            at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1187)
            at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:87)
            at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:284)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
            at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:126)
            at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:278)
            at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:104)
            at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:76)
            at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
            at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
            at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:527)
            at org.jboss.ejb.Container.invoke(Container.java:960)
            at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:430)
            at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:65)
            at $Proxy182.approve(Unknown Source)
            at org.ejbca.core.ejb.approval.LocalApprovalSessionBean.approve(LocalApprovalSessionBean.java:342)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
            at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
            at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
            at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
            at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
            at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
            at org.jboss.ejb.Container.invoke(Container.java:960)
            at sun.reflect.GeneratedMethodAccessor139.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
            at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
            at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
            at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
            at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
            at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
            at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
            at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
            at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
            at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
            at $Proxy214.approve(Unknown Source)
            at org.ejbca.core.protocol.ws.EjbcaWS.approveRequest(EjbcaWS.java:329)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at com.sun.xml.ws.server.PeptTie._invoke(PeptTie.java:58)
            at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.invokeEndpoint(SOAPMessageDispatcher.java:278)
            at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.invoke(SOAPMessageDispatcher.java:586)
            at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:141)
            at com.sun.xml.ws.server.Tie.handle(Tie.java:88)
            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.handle(WSServletDelegate.java:333)
            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:288)
            at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:77)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: javax.naming.NameNotFoundException: UserAdminSessionLocal not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
            at javax.naming.InitialContext.lookup(InitialContext.java:392)
            at org.ejbca.core.ejb.ServiceLocator.getObject(ServiceLocator.java:158)
            … 96 more

    #################################################################

    Any 1 know what happen??

    Thank you

     
  • J Eklund

    J Eklund - 2010-07-23

    Hi biau83,

    Since it looks like in the stacktrace that this traversed thrugh org.ejbca.core.ejb.approval.ApprovalDataBean, I would assume that ApprovalDataBean's ENC is not populated with a local reference to UserAdminSessionLocal.

    Try adding a another XDoclet tag to this bean where the local EJB reference is declared. Run "ant clean" + "ant deploy" and try again.

    Best Regards,

    Johan

     
  • Yee Wen Biau

    Yee Wen Biau - 2010-07-23

    Hi jeklund, Thank for your reply.

    this is the first time i come across XDoclet…. i would be appreciate if you can explain to me a bit more details :)

    what XDoclet tag that I need to add?  is it add into C:\ejbca_3_10_3\src\java\org\ejbca\core\ejb\approval\ApprovalDataBean.java ?

    thank you

     
  • Yee Wen Biau

    Yee Wen Biau - 2010-07-23

    Hi jeklund…. :D

    My problem solved. This is because everytime i compile the webservice, I only type: "ant ejbca-ws-generate",  then "ant deploy"

    I never "ant clean"
    Just now I "ant clean" and "ant deploy", It works now~~~~~~~~~~~~~~~ :D

    Thank you very much!!~~~

     
  • J Eklund

    J Eklund - 2010-07-23

    Great! =)

     
  • Lautaro Carmona

    Lautaro Carmona - 2013-05-14

    Hi! I'm trying to do something similar to what Yee Wen Biau did, an approval request web service, but for EJBCA 4.0.14.

    I've tried Yee Wen Biau's code with no success... :(

    Do you have any code that does this in EJBCA 4.0.14? Or could you give me some advice on how to approve requests ("Add End Entity" for example) programatically, not using the EJBCA Admin GUI?

     
  • Tomas Gustavsson

    For code examples you can look in the EJBCA source code. See how it works when you approve something in the admin GUI, then code the same thing in your service.

    Cheers,
    Tomas


    PrimeKey Solutions offers commercial EJBCA and SignServer support subscriptions and training courses. Please see www.primekey.se or contact info@primekey.se for more information.
    http://www.primekey.se/Services/Support/
    http://www.primekey.se/Services/Training/

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks