-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Unable to instantiateorg.hibernate.validator.cfg.defs.NotNul
PostPosted: Fri Feb 18, 2011 12:47 pm 
Newbie

Joined: Fri Feb 18, 2011 12:31 pm
Posts: 2
I have been unit testing using annotations with Hibernate Validator [hibernate-validator-4.1.0.Final.jar] and have everything working well. Now, I want to execute the exact same validations using the "Programmatic" API (see below).

Unfortunately... import org.hibernate.validator.cfg.defs.*;

Caused by: javax.xml.ws.soap.SOAPFaultException: Unable to instantiateorg.hibernate.validator.cfg.defs.NotNullDef
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1153)
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:916)
at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMethodMarshaller.demarshalFaultResponse(DocLitBareMethodMarshaller.java:366)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:451)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:424)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:336)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:148)
at $Proxy56.bookAdventure(Unknown Source)
at sun.reflect.GeneratedMethodAccessor647.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS.executeBusinessProcess(WscBaseGenericConsumerAS.java:447)
at com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS.processConsumer(WscBaseGenericConsumerAS.java:301)
... 41 more

/**
* This instance contains the "declarative" validation rules.
*/
private ConstraintMapping constraintMapping = new ConstraintMapping();

/**
* Construct a BookAdventureProviderController instance
*
* @param webServiceContext The web service context
* @param jaxbRequest The JAXB request
*/
public BookAdventure2ProviderController(
final WebServiceContext webServiceContext, final Object jaxbRequest) {
super(webServiceContext, jaxbRequest);

this.constraintMapping.type(BookingType.class)

.property("startDate", ElementType.FIELD)
.constraint(NotNullDef.class)

.property("endDate", ElementType.FIELD)
.constraint(NotNullDef.class)

.property("customer", ElementType.FIELD)
.constraint(NotNullDef.class)

.property("adventure", ElementType.FIELD)
.constraint(NotNullDef.class)
.valid("adventure", ElementType.FIELD)

.type(AdventureType.class)

.property("departingFlight", ElementType.FIELD)
.constraint(NotNullDef.class)
.valid("departingFlight", ElementType.FIELD)

.property("returningFlight", ElementType.FIELD)
.constraint(NotNullDef.class)
.valid("returningFlight", ElementType.FIELD)

.type(FlightType.class)

.property("flightNumber", ElementType.FIELD)
.constraint(NotBlankDef.class)

.type(AdventureType.class)

.property("name", ElementType.FIELD)
.constraint(NotBlankDef.class)

.type(CustomerType.class)

.property("customerEmailId", ElementType.FIELD)
.constraint(NotBlankDef.class)
.constraint(EmailDef.class)

.property("firstName", ElementType.FIELD)
.constraint(NotBlankDef.class)

.property("lastName", ElementType.FIELD)
.constraint(NotBlankDef.class)

.property("phone", ElementType.FIELD)
.constraint(NotBlankDef.class)
.constraint(DecimalMaxDef.class)
.value("9999999999")
.constraint(DecimalMinDef.class)
.value("1000000000")

.type(AddressType.class)

.property("streetAddress1", ElementType.FIELD)
.constraint(NotBlankDef.class)

.property("city", ElementType.FIELD)
.constraint(NotBlankDef.class)

.property("state", ElementType.FIELD)
.constraint(NotBlankDef.class)

.property("country", ElementType.FIELD)
.constraint(NotBlankDef.class);
}


// #1 of 1: The parent domain instance is validated.

validateDeclarativeFirstErrorOnlyUsingProgrammaticAPI(
bookAdventureRequestType.getBooking(), this.constraintMapping);


/**
* This convenience method is used to invoke declarative validation.
*
* @param <T> Instance to be validated.
* @param instanceToBeValidated Instance to be validated.
* @param constraintMapping The validation rules for the instance being
* validated.
*/
protected <T> void validateDeclarativeFirstErrorOnlyUsingProgrammaticAPI(
final T instanceToBeValidated,
final ConstraintMapping constraintMapping) {

final String METHOD_NAME =
"validateDeclarativeFirstErrorOnlyUsingProgrammaticAPI";
log.entering(CLASS_NAME, METHOD_NAME);

// Declare/Initialize
final HibernateValidatorConfiguration hibernateValidatorConfiguration =
Validation.byProvider(HibernateValidator.class).configure();

hibernateValidatorConfiguration.addMapping(constraintMapping);

final ValidatorFactory validatorFactory =
hibernateValidatorConfiguration.buildValidatorFactory();

final Validator validator = validatorFactory.getValidator();

// Declarative validation NOW!
final Set<ConstraintViolation<T>> constraintViolationSet =
validator.validate(instanceToBeValidated);

final StringBuffer message = new StringBuffer();
if (!constraintViolationSet.isEmpty()) {

for (final ConstraintViolation<T> constraintViolation : constraintViolationSet) {

message.append(constraintViolation.getMessage());
message.append(" [");
message.append(constraintViolation.getLeafBean()
.getClass()
.getSimpleName());
message.append(".");
message.append(constraintViolation.getPropertyPath().toString());

}

throw new WscValidationClientFaultException(
new FordExceptionAttributes.Builder(CLASS_NAME, METHOD_NAME).build(),
message.toString());
}

log.exiting(CLASS_NAME, METHOD_NAME);
return;

}


Top
 Profile  
 
 Post subject: Re: Unable to instantiateorg.hibernate.validator.cfg.defs.NotNul
PostPosted: Mon Feb 21, 2011 5:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

when is this exception occurring? This looks like a runtime exception and it seems you are using some (un-)marshalling here. I am not sure where at what tries to instantiate the NotNullDef class. Is this really the whole stack trace?

As a side note, in validateDeclarativeFirstErrorOnlyUsingProgrammaticAPI you create a ValidatorFactory for each invocation of the method. This is not the intention of Bean Validation. The validator factories are quite expensive to built and should be cached.

--Hardy


Top
 Profile  
 
 Post subject: Re: Unable to instantiateorg.hibernate.validator.cfg.defs.NotNul
PostPosted: Mon Feb 21, 2011 11:09 am 
Newbie

Joined: Fri Feb 18, 2011 12:31 pm
Posts: 2
This is 'Proof of Concept' code... just trying to get it working... in the interest of verbosity here is the complete unit test:

[2/21/11 10:06:42:041 EST] 0000002c IncontainerTe I

*** Setup BookAdventureProviderTest.testBookAdventure_update_success()

[2/21/11 10:06:42:050 EST] 0000002c WscUtilLoggin I
<< ##pvcsLabel##; Consumer Message Sent; RequestContext(UserId=[unknown] RequestId=[null] SessionId=[null] ContextId=[3]) >>
[2/21/11 10:06:42:056 EST] 0000002c WSChannelFram A CHFW0019I: The Transport Channel Service has started chain HttpOutboundChain:localhost:11000.
[2/21/11 10:06:42:066 EST] 0000002f WscUtilLoggin I
<< ##pvcsLabel##; Provider Request Received; RequestContext(UserId=[unknown] RequestId=[null] SessionId=[null] ContextId=[6]) >>
WSDL_DESCRIPTION=null
[2/21/11 10:06:42:073 EST] 0000002f WscUtilLoggin I
<< ##pvcsLabel##; Provider Failed; RequestContext(UserId=[wasadm01] RequestId=[1759282146] SessionId=[null] ContextId=[6]) >>
WSDL_OPERATION=BookAdventure
WSDL_PORT={urn:abco/interface/Booking/v1}Booking
*** PROVIDER INBOUND SOAP PART ***
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<idty:EntityIdentity xmlns:idty="urn:ford/security/identity/v1.0" entityType="Unspecified" soapenv:mustUnderstand="0">jabagent@ford.com</idty:EntityIdentity>
</soapenv:Header>
<soapenv:Body>
<ns2:BookAdventure xmlns:ns2="urn:abco/interface/Booking/v1" xmlns:ns3="urn:abco/Customer/v1.0" xmlns:ns4="urn:abco/Booking/v1.0">
<ns4:Booking>
<StartDate>2022-09-12</StartDate>
<EndDate>2023-10-01</EndDate>
<TotalPrice>0.0</TotalPrice>
<ns3:Customer>
<CustomerEmailId>wasadm01@ford.com</CustomerEmailId>
<FirstName>Unit</FirstName>
<LastName>Test</LastName>
<ns3:Address>
<StreetAddress1>Unit Test Way</StreetAddress1>
<StreetAddress2>406455651</StreetAddress2>
<City>Detroit</City>
<State>Michigan</State>
<Country>United States</Country>
</ns3:Address>
<Phone>3139999999</Phone>
</ns3:Customer>
<ns4:Adventure>
<Name>Dude Ranch</Name>
</ns4:Adventure>
<ns4:DepartingFlight>
<FlightNumber>NW11</FlightNumber>
</ns4:DepartingFlight>
<ns4:ReturningFlight>
<FlightNumber>NW11</FlightNumber>
</ns4:ReturningFlight>
</ns4:Booking>
</ns2:BookAdventure>
</soapenv:Body>
</soapenv:Envelope>

[2/21/11 10:06:42:076 EST] 0000002f WscUtilLoggin I
<< ##pvcsLabel##; Provider Failed; RequestContext(UserId=[wasadm01] RequestId=[1759282146] SessionId=[null] ContextId=[6]) >>
*** PROVIDER OUTBOUND SOAP PART ***
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>Unable to instantiateorg.hibernate.validator.cfg.defs.NotNullDef</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

[2/21/11 10:06:42:078 EST] 0000002f WscUtilLoggin I
<< ##pvcsLabel##; Provider Close; RequestContext(UserId=[wasadm01] RequestId=[1759282146] SessionId=[null] ContextId=[6]) >>
Total time taken for the web service call [1] include inbound unmarshalling [0] and outbound marshalling [0].
[2/21/11 10:06:42:208 EST] 0000002f FFDCJanitor I com.ibm.ws.ffdc.FFDCJanitor doCleanupIfNeeded FFDC0004I: FFDC log file management removed 6 of 6 files that have reached their configured maximum age
[2/21/11 10:06:42:285 EST] 0000002c WscUtilLoggin I
<< ##pvcsLabel##; Consumer Close; RequestContext(UserId=[unknown] RequestId=[null] SessionId=[null] ContextId=[3]) >>
Total WebService call time elapsed in milliseconds [232].
[2/21/11 10:06:42:288 EST] 0000002c WscUtilLoggin I
<< ##pvcsLabel##; Consumer Failed; RequestContext(UserId=[unknown] RequestId=[null] SessionId=[null] ContextId=[3]) >>
*** CONSUMER OUTBOUND SOAP PART ***
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<idty:EntityIdentity xmlns:idty="urn:ford/security/identity/v1.0" entityType="Unspecified" soapenv:mustUnderstand="0">jabagent@ford.com</idty:EntityIdentity>
</soapenv:Header>
<soapenv:Body>
<ns2:BookAdventure xmlns:ns2="urn:abco/interface/Booking/v1" xmlns:ns3="urn:abco/Customer/v1.0" xmlns:ns4="urn:abco/Booking/v1.0">
<ns4:Booking>
<StartDate>2022-09-12</StartDate>
<EndDate>2023-10-01</EndDate>
<TotalPrice>0.0</TotalPrice>
<ns3:Customer>
<CustomerEmailId>wasadm01@ford.com</CustomerEmailId>
<FirstName>Unit</FirstName>
<LastName>Test</LastName>
<ns3:Address>
<StreetAddress1>Unit Test Way</StreetAddress1>
<StreetAddress2>406455651</StreetAddress2>
<City>Detroit</City>
<State>Michigan</State>
<Country>United States</Country>
</ns3:Address>
<Phone>3139999999</Phone>
</ns3:Customer>
<ns4:Adventure>
<Name>Dude Ranch</Name>
</ns4:Adventure>
<ns4:DepartingFlight>
<FlightNumber>NW11</FlightNumber>
</ns4:DepartingFlight>
<ns4:ReturningFlight>
<FlightNumber>NW11</FlightNumber>
</ns4:ReturningFlight>
</ns4:Booking>
</ns2:BookAdventure>
</soapenv:Body>
</soapenv:Envelope>

[2/21/11 10:06:42:291 EST] 0000002c WscUtilLoggin I
<< ##pvcsLabel##; Consumer Failed; RequestContext(UserId=[unknown] RequestId=[null] SessionId=[null] ContextId=[3]) >>
*** CONSUMER INBOUND SOAP PART ***
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>Unable to instantiateorg.hibernate.validator.cfg.defs.NotNullDef</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

[2/21/11 10:06:42:295 EST] 0000002c WscBaseGeneri E com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS manageException

com.ford.it.wscore.exception.WscConsumerSoapException for user [UnKnown] self logged on Feb 21, 2011 10:06:42 AM.
Exception instance reference code [13270C97-9E91-095E-48C2-14F648C214F6].

com.ford.it.wscore.exception.WscConsumerSoapException: A SOAP Fault [soapenv:Server] was thrown by the service provider with Fault String [Unable to instantiateorg.hibernate.validator.cfg.defs.NotNullDef].
at com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS.manageException(WscBaseGenericConsumerAS.java:353)
at com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS.processConsumer(WscBaseGenericConsumerAS.java:315)
at com.ford.jcoe.jab.as.BookAdventureProviderTest.bookAdventure(BookAdventureProviderTest.java:805)
at com.ford.jcoe.jab.as.BookAdventureProviderTest.testBookAdventure_update_success(BookAdventureProviderTest.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:124)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:124)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:124)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:592)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:764)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:133)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
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:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
Caused by: javax.xml.ws.soap.SOAPFaultException: Unable to instantiateorg.hibernate.validator.cfg.defs.NotNullDef
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1153)
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:916)
at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMethodMarshaller.demarshalFaultResponse(DocLitBareMethodMarshaller.java:366)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:451)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:424)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:336)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:148)
at $Proxy23.bookAdventure(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS.executeBusinessProcess(WscBaseGenericConsumerAS.java:447)
at com.ford.it.wscore.consumer.as.WscBaseGenericConsumerAS.processConsumer(WscBaseGenericConsumerAS.java:301)
... 41 more

[2/21/11 10:06:42:299 EST] 0000002c IncontainerTe I

*** Teardown BookAdventureProviderTest.testBookAdventure_update_success(); milliseconds = 255


Top
 Profile  
 
 Post subject: Re: Unable to instantiateorg.hibernate.validator.cfg.defs.NotNul
PostPosted: Wed Feb 23, 2011 6:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Is this problem solved? I still don't understand the error message. It seems that something somewhere swallows some of the stack trace. If it all it should be the Validator framework itself instantiating the NotNullDef. There is no public or default constructor to do that for a Validator client (and no need for it).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.