0

これはコントローラーのコードで、ここでオブジェクトを保存します

public static void newNdsf(Integer cprNumber,String fstCode,Date startDate,
            Double amount, Date endDate, String isActive, String userCreated, String msg){

    Beneficiary beneficiary = new Beneficiary();
    beneficiary.beneficiaryPK = (new BeneficiaryPK(cprNumber, fstCode, startDate));
    beneficiary.dateCreated = (new Date());
    beneficiary.userCreated = userCreated;
    beneficiary.amount = new BigDecimal(amount);
    beneficiary.dateLastUpdate = (new Date());
    beneficiary.userLastUpdate = userCreated; 
    beneficiary.endDate = endDate;

    if(isActive.charAt(0) == Constants.IN_ACTIVE || isActive.charAt(0) == Constants.ACTIVE)
        beneficiary.isActive = isActive.charAt(0);
    else
        System.out.println("in valid is Active value entered in service");  
    beneficiary.save();
    int count = new CRSServices().savePersonDetails(cprNumber);
    System.out.println("Person Data saved from Service : " + count);
    msg = msg.concat("Entered Successfully");
    renderText(msg);
}

モデルでは、いくつかの例外をキャッチするためにsaveメソッドをオーバーライドしています

@Override

 public <T extends JPABase> T save() 
{
        long startTs = System.currentTimeMillis();
        if (endDate != null && beneficiaryPK != null && beneficiaryPK.startDate != null &&    endDate.before(beneficiaryPK.startDate)){
            throw new RuntimeException("startdate_after_end_date");
        }
        Object result  = super.save();
        logger.debug("Save Took: {} " , System.currentTimeMillis() - startTs);
        return (T) result;
    }

このコードは WAS6 で動作しています

しかし、WAS8で使用すると

それは私にこの例外を与えます

@6d2l11n03
Internal Server Error (500)

Execution exception (In /app/models/Beneficiary.java around line 221)
ValidationException occured : error during validation of 

play.exceptions.JavaExecutionException: error during validation of <unknown>
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:290)
    at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:476)
    at play.Invoker$Invocation.run(Invoker.java:187)
    at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:467)
    at play.Invoker.invokeInThread(Invoker.java:61)
    at play.server.ServletWrapper.service(ServletWrapper.java:117)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1027)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:895)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
Caused by: javax.validation.ValidationException: error during validation of <unknown>
    at org.apache.bval.jsr303.ClassValidator.unrecoverableValidationError(ClassValidator.java:633)
    at org.apache.bval.jsr303.ClassValidator.validate(ClassValidator.java:161)
    at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:113)
    at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:71)
    at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:177)
    at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:72)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:345)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:791)
    at play.db.jpa.JPABase._save(JPABase.java:47)
    at play.db.jpa.GenericModel.save(GenericModel.java:187)
    at models.Beneficiary.save(Beneficiary.java:221)
    at controllers.NdsfService.newNdsf(NdsfService.java:189)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:413)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:408)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:182)
    ... 27 more
Caused by: play.exceptions.UnexpectedException: Unexpected Error
    at play.db.jpa.JPAPlugin$JPAModelLoader.keyValue(JPAPlugin.java:491)
    at play.db.jpa.JPABase._key(JPABase.java:96)
    at play.db.jpa.JPABase.hashCode(JPABase.java:226)
    at org.apache.bval.jsr303.GraphBeanIdentity.hashCode(GraphBeanIdentity.java:123)
    at java.util.HashMap.getEntry(HashMap.java:510)
    at java.util.HashMap.get(HashMap.java:498)
    at org.apache.bval.jsr303.GroupValidationContextImpl.collectValidated(GroupValidationContextImpl.java:133)
    at org.apache.bval.jsr303.ClassValidator.validateBeanNet(ClassValidator.java:421)
    at org.apache.bval.jsr303.ClassValidator.validate(ClassValidator.java:141)
    ... 45 more
Caused by: play.exceptions.UnexpectedException: Cannot get the object @Id for an object of type class models.Beneficiary
    at play.db.jpa.JPAPlugin$JPAModelLoader.keyField(JPAPlugin.java:511)
    at play.db.jpa.JPAPlugin$JPAModelLoader.keyValue(JPAPlugin.java:489)
    ... 53 more

誰かが助けることができれば!!!

4

1 に答える 1

0

これを考え出した

私が持っている前に私のオブジェクトで

@EmbeddedId
    public BeneficiaryPK beneficiaryPK;

これはWAS 6では機能しますが、WAS 8では機能しません

だから今私は@Idを追加し、両方の注釈がWAS 8で機能しています

 @EmbeddedId
    @Id  
    public BeneficiaryPK beneficiaryPK;

これが役立つことを願っています

于 2013-01-16T09:20:32.263 に答える