I have an application with spring 2.6.8, I have migrated it to 2.7.4.
And everything works correctly.
But when I have upgraded from java 11 to java 17 it gives me the following error
#Cacheable(value = "datoAuxiliar", key = "{#nombre, #tipo}", unless = "#result == null")
public DatoAuxiliar findByTipoAndSecurityDomainAndNombre(TipoDatoAuxiliar tipo, SecurityDomain securityDomain,
String nombre);
-- ERROR
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tipoContratoSelectItemController': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Null key returned for cache operation (maybe you are using named params on classes without debug info?) Builder[public abstract java.util.List com.xxx.xxx.repository.DatoAuxiliarRrhhRepository.findByTipoAndSecurityDomainAndDeletedIsNull(com.abalia.elser.domain.enumeration.TipoDatoAuxiliar,com.abalia.elser.domain.SecurityDomain)] caches=[datoAuxiliar] | key='#tipo' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='#result == null' | sync='false'
I've tried several things but they don't work for me.
Can someone help me with this problem?
Thanks.
Related
I have a simple class that I'm writing a test for. Something weird happens when I call validate() on an instance of that class, which relates to my custom validator for my date property. If my custom validator calls a static method, everything seems to work fine. However, if I call a non-static method (which I need to as I need to check some other properties of my instance) I get the following error:
Condition failed with Exception:
testDate.validate(['date']) == valid
| |
| org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'class hegardt.backend.grails.model.person.TestDate' with class 'java.lang.Class' to class 'hegardt.backend.grails.model.person.TestDate'
| at hegardt.backend.grails.model.person.TestDate._clinit__closure1$_closure2(TestDate.groovy:20)
| at groovy.lang.Closure.call(Closure.java:405)
| at org.grails.datastore.gorm.validation.constraints.ValidatorConstraint.processValidate(ValidatorConstraint.java:100)
| at org.grails.datastore.gorm.validation.constraints.AbstractConstraint.validate(AbstractConstraint.java:88)
| at grails.gorm.validation.DefaultConstrainedProperty.validate(DefaultConstrainedProperty.groovy:601)
| at grails.validation.Validateable$Trait$Helper.doValidate(Validateable.groovy:192)
| at grails.validation.Validateable$Trait$Helper.validate(Validateable.groovy:163)
| at grails.validation.Validateable$Trait$Helper.validate(Validateable.groovy:129)
| at hegardt.backend.grails.model.person.TestDateSpec.test(TestDateSpec.groovy:15)
<hegardt.backend.grails.model.person.TestDate#48bb8764 date=null privateVar=false grails_validation_Validateable__beforeValidateHelper=org.grails.datastore.gorm.support.BeforeValidateHelper#1624fd07 grails_validation_Validateable__errors=grails.validation.ValidationErrors: 0 errors>
Here's my class definition:
#GrailsCompileStatic
class TestDate implements Validateable {
LocalDate date
boolean privateVar
static constraints = {
date nullable: true, validator: {LocalDate val -> validateDate(val)}
}
private validateDate(LocalDate val) { // If this method is static, everything works fine
return privateVar
}
}
and here's my test class
class TestDateSpec extends Specification {
#Unroll
void "test"() {
given:
TestDate testDate = new TestDate(date: date)
expect:
testDate.validate(['date']) == valid // This call fails for all 4 test cases...
where:
date | valid
null | true
LocalDate.now().plusDays(1) | false
LocalDate.now() | false
LocalDate.now() | true
}
}
PS
I have also tried without #GrailsCompileStatic but this just generates a different "cast" related error:
Condition failed with Exception:
testDate.validate(['date']) == valid
| |
| java.lang.IllegalArgumentException: object is not an instance of declaring class
| at org.grails.datastore.gorm.validation.constraints.builder.ConstrainedPropertyBuilder.doInvokeMethod(ConstrainedPropertyBuilder.java:65)
| at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
| at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
| at hegardt.backend.grails.model.person.TestDate._clinit__closure1$_closure2(TestDate.groovy:19)
| at groovy.lang.Closure.call(Closure.java:405)
| at org.grails.datastore.gorm.validation.constraints.ValidatorConstraint.processValidate(ValidatorConstraint.java:100)
| at org.grails.datastore.gorm.validation.constraints.AbstractConstraint.validate(AbstractConstraint.java:88)
| at grails.gorm.validation.DefaultConstrainedProperty.validate(DefaultConstrainedProperty.groovy:601)
| at grails.validation.Validateable$Trait$Helper.doValidate(Validateable.groovy:192)
| at grails.validation.Validateable$Trait$Helper.validate(Validateable.groovy:163)
| at grails.validation.Validateable$Trait$Helper.validate(Validateable.groovy:129)
| at hegardt.backend.grails.model.person.TestDateSpec.test(TestDateSpec.groovy:15)
<hegardt.backend.grails.model.person.TestDate#1e742012 date=null privateVar=false grails_validation_Validateable__beforeValidateHelper=org.grails.datastore.gorm.support.BeforeValidateHelper#4f3967c7 grails_validation_Validateable__errors=grails.validation.ValidationErrors: 0 errors>
You are attempting to invoke an instance method (validateDate) from a static context (static constraints block) which is not allowed. You could mark validateDate as static but that moves the problem to privateVar which is an instance variable so you would not be able to reach that from a static method. It isn't clear what role that field plays so it isn't clear how best to deal with that, but the problem described in the question is caused because you are attempting to invoke an instance method from a static context.
Getting the below exception when running the code:
FhirContext ctx = FhirContext.forR4();
// Create a FhirInstanceValidator and register it to a validator
FhirValidator validator = ctx.newValidator();
FhirInstanceValidator instanceValidator = new FhirInstanceValidator();
validator.registerValidatorModule(instanceValidator);
/*
* If you want, you can configure settings on the validator to adjust
* its behaviour during validation
*/
instanceValidator.setAnyExtensionsAllowed(true);
// input is Patient resource in String https://www.hl7.org/fhir/patient-example.json.html
ValidationResult result = validator.validateWithResult(input);
I am using Hapi Library to validate a resource (if i am not wrong this is a Patient resource https://www.hl7.org/fhir/patient-example.json.html ). I have stored this Patient Json in a string
and trying to Validate its :
1: Structure -> i think using Parse Validation it can be achieved and i did the same.
2: Cardinality -> I created two "active:true" Json key-value pair thinking that it will throw cardinality error but neither of SchemxxxValidator / ParseValidator / InstanceValidator working.
...
How to validate a resource against properties listed here https://www.hl7.org/fhir/validation.html (structure ,cardinality , ValueDomains ...) , Do i have to use all three ways
That is Parser , FhirInstanceValidator and SchemaBaseValidator / SchematronBaseValidator .
Please Help as i am new to FHIR and excuse for lame question.
15:58| INFO | VersionUtil.java 72 | HAPI FHIR version 4.1.0 - Rev 03163c2cf5
15:58| INFO | FhirContext.java 174 | Creating new FHIR context for FHIR version [R4]
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/profile/profiles-resources.xml
15:58| INFO | DependencyLogImpl.java 75 | FHIR XML procesing will use StAX implementation 'Woodstox' version '5.1.0'
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/profile/profiles-types.xml
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/profile/profiles-others.xml
15:58| INFO | DefaultProfileValidationSupport.java 227 | Loading structure definitions from classpath: /org/hl7/fhir/r4/model/extension/extension-definitions.xml
15:58| ERROR | FhirInstanceValidator.java 222 | Failure during validation
java.lang.UnsupportedOperationException
at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.generateSnapshot(HapiWorkerContext.java:242)
at org.hl7.fhir.r4.elementmodel.ParserBase.getDefinition(ParserBase.java:122)
at org.hl7.fhir.r4.elementmodel.JsonParser.parse(JsonParser.java:123)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:539)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:531)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:220)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:242)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:20)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:43)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:33)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:243)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:198)
at com.json.schema.validator.InstanceValidatorEx.instanceValidator(InstanceValidatorEx.java:223)
at com.json.schema.validator.InstanceValidatorEx.main(InstanceValidatorEx.java:191)
Exception in thread "main" ca.uhn.fhir.rest.server.exceptions.InternalErrorException: Unexpected failure while validating resource
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:223)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:242)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:20)
at org.hl7.fhir.r4.hapi.validation.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:43)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:33)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:243)
at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:198)
at com.json.schema.validator.InstanceValidatorEx.instanceValidator(InstanceValidatorEx.java:223)
at com.json.schema.validator.InstanceValidatorEx.main(InstanceValidatorEx.java:191)
Caused by: java.lang.UnsupportedOperationException
at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.generateSnapshot(HapiWorkerContext.java:242)
at org.hl7.fhir.r4.elementmodel.ParserBase.getDefinition(ParserBase.java:122)
at org.hl7.fhir.r4.elementmodel.JsonParser.parse(JsonParser.java:123)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:539)
at org.hl7.fhir.r4.validation.InstanceValidator.validate(InstanceValidator.java:531)
at org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator.validate(FhirInstanceValidator.java:220)
Cardinality -> I created two "active:true" Json key-value pair thinking that it will throw cardinality error but neither of SchemxxxValidator / ParseValidator / InstanceValidator working. ...
That's an issue in HAPI - it validates the objects it loads from the JSON, and the JSON parser silently drops the duplicate property key. If you use the validator directly, this won't happen. I believe that this is going to be addressed at some stage
generateSnapshot failed
that's a real issue - I'm not sure why that's not set up, but the validator can't work if snapshots are not being generated
I have a query to sum numeric values from single column:
int numberOfDays = jdbcTemplate.queryForObject
("select sum(number_of_days) from business_trip where name = ? and surname = ? and type = ?",new Object[]{name,surname,"UE"},Integer.class);
It works fine as long as there is a business trip of UE category for selected user. Then it sums trip days correctly. However, if there are no trips of UE category, instead of zero I'm getting NullPointerException. I can place this line inside try/catch but that would be a workaround. I would like to figure out why NPE is thrown in such case.
*2016-11-24 11:13:02.613 ERROR 8316 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException: null
at com.tfb.dao.BusinessTripDAO.getKrajoweTripsDaysForEmployee(BusinessTripDAO.java:59) ~[classes/:na]*
Change your select statement to
"select coalesce(sum(number_of_days), 0) from business_trip where name = ? and surname = ? and type = ?"
This way, if you get null it will be transformed to 0.
I am using Grails 2.3.5 and I have a controller which contains a ajaxDelete method. This method receives the name as a String of the entity i want to delete. I am using a service to delete the entity which I call from within my controller.
The first time the services deleteSvnUser method is called the SVN user is deleted and my div on the page is updated with a alert stating that the user has been deleted. The second time I delete a user i get the following error:
row-was-updated-or-deleted-by-another-transaction-or-unsaved-value-mapping-was...
I have tried a couple of things to get round this:
Adding the #transactional annotation to my service (which I shouldn't have to because it should be transactional by default).
flushing my deletes (flush:true)
Refreshing the entity before i delete it (.refresh)
Locking the entity when I retrieve it (entity.lock(id))
None of the above have worked. I'm not sure what else to do to get around this.
Can anyone help? my code is below:
Controller
class SvnUserController {
def svnUserService
def ajaxDelete() {
if (!params.selectedSvnUser) {
request.error = "The selected Svn User does not exist"
render(template:"svnUserList", model:[svnUserInstanceList: SvnUser.list(params).sort{it.name}, svnUserInstanceTotal: SvnUser.count()])
return
}
String outcome = svnUserService.deleteSvnUser(params.selectedSvnUser)
switch (outcome){
case "":
request.message = "Svn User ${params.selectedSvnUser} deleted"
break
default: request.error = outcome
}
}
def svnUsers = svnUserService.getAllSvnUsers(params)
render(template:"svnUserList", model:[svnUserInstanceList: svnUsers, svnUserInstanceTotal: svnUsers.size()])
return
}
}
Service
class SvnUserService {
public String deleteSvnUser(String userName) {
String outcome = ""
try {
SvnUser svnUserInstance = SvnUser.findByName(userName)
def groups = SvnGroupController.findAllBySvnUserName(userName)
groups.each { SvnGroup group ->
group.removeFromSvnUsers(svnUserInstance)
group.save()
}
def userPermissionsList = UserPermission.findAllBySvnUser(svnUserInstance)
userPermissionsList.each {
def repoDirectory = it.repositoryDirectory
repoDirectory.removeFromUserPermissions(it)
it.delete()
}
svnUserInstance.merge()
svnUserInstance.delete()
}
catch (DataIntegrityViolationException e) {
outcome = "A error occurred while attempting to delete the Svn User from file."
}
return outcome
}
}
The stacktrace is as follows:
Error |
2014-06-10 15:10:07,394 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - StaleObjectStateException occurred when processing request: [POST] /subzero/svnUser/ajaxDelete - parameters:
selectedSvnUser: ruby2
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.uk.nmi.subzero.SvnGroup#2]. Stacktrace follows:
Message: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.uk.nmi.subzero.SvnGroup#2]
Line | Method
->> 72 | deleteSvnUser in com.uk.nmi.subzero.SvnUserService
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 87 | ajaxDelete in com.uk.nmi.subzero.SvnUserController
| 200 | doFilter . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . . . in java.lang.Thread
I can't see any problem with your code. Grails should handle the transaction fine.
If your object mapping is set up correctly, the svnUserInstance.delete() call should delete the child objects too, so I don't think you even need the lines between svnUserInstance = SvnUser.findByName(userName) and the delete.
How are you calling the ajaxDelete? Is there any chance it is being called incorrectly the second time?
I'm having trouble with Mule executing a JDBC query that works externally. It fails once I put parentheses in it if it also has replacement parameters. I'm wondering if MEL has some issues with parentheses that I don't understand.
The following (simplified) example executes correctly in my flow:
<jdbc:query
key="QueryStrategy"
value="SELECT product_strategy FROM licensing.product WHERE product_sku = #[flowVars['productSku']] OR product_sku IS NULL"/>
If I replace the reference to a flow variable with a constant, I can add parentheses and it still works:
<jdbc:query
key="QueryStrategy"
value="SELECT product_strategy FROM licensing.product WHERE (product_sku = 'Trial' OR product_sku IS NULL)"/>
However, the minute I add parentheses while the replacement parameter is present, I get an exception:
<jdbc:query
key="QueryStrategy"
value="SELECT product_strategy FROM licensing.product WHERE (product_sku = #[flowVars['productSku']] OR product_sku IS NULL)"/>
The exception is shown below. Is this a problem with Mule's formatting of what it sends to Microsoft or some bug in the Microsoft JDBC driver?
EDIT
Here's the amended log with DEBUG turned on for org.mule.transport.jdbc.
com.ca.eai.esb.interceptor.EaiLoggingInterceptor FlowBefore | Flow Name: Main | MULE_REMOTE_CLIENT_ADDRESS: /127.0.0.1:59952 | consumerTransId: E0acd42cb-100d-11e3-a264-852205c1b19e | consumerDateTimeSent: null | consumerApp: null | consumerUsername: null | mule.muleId: null | esbTransCode: null | messageSourceName: endpoint.https.localhost.8088.license.requests.r.v1 | currentTimestamp: 2013-08-28 14:09:55.309
org.mule.transport.jdbc.JdbcConnector Borrowing a dispatcher for endpoint: jdbc://QueryStrategy
org.mule.transport.jdbc.JdbcMessageDispatcher Connecting: JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
org.mule.transport.jdbc.JdbcMessageDispatcher Connected: endpoint.outbound.jdbc://QueryStrategy
org.mule.transport.jdbc.JdbcConnector Borrowed a dispatcher for endpoint: jdbc://QueryStrategy = JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
org.mule.transport.jdbc.JdbcConnector Borrowed dispatcher: JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
org.mule.transport.jdbc.sqlstrategy.SelectSqlStatementStrategy Trying to receive a message with a timeout of 10000
org.mule.transport.jdbc.sqlstrategy.SelectSqlStatementStrategy SQL QUERY: SELECT product_strategy, product_id FROM licensing.product WHERE product_name = ? AND (product_sku is null OR product_sku = ? ) ORDER BY product_sku DESC, params = {My Product,My Product}
org.mule.transport.jdbc.JdbcConnector Returning dispatcher for endpoint: jdbc://QueryStrategy = JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
com.ca.eai.esb.interceptor.EaiLoggingInterceptor FlowLast | Flow Name: Main | MULE_REMOTE_CLIENT_ADDRESS: /127.0.0.1:59952 | consumerTransId: E0acd42cb-100d-11e3-a264-852205c1b19e | consumerDateTimeSent: null | consumerApp: null | consumerUsername: null | mule.muleId: null | esbTransCode: null | messageSourceName: endpoint.https.localhost.8088.license.requests.r.v1 | currentTimestamp: 2013-08-28 14:09:55.791 | elapsedTime: 484ms
org.mule.exception.DefaultMessagingExceptionStrategy
********************************************************************************
Message : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://QueryStrategy, connector=JdbcConnector
{
name=Database
lifecycle=start
this=333d612e
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=false
connected=true
supportedProtocols=[jdbc]
serviceOverrides=<none>
}
, name='endpoint.jdbc.QueryStrategy', mep=REQUEST_RESPONSE, properties={queryTimeout=-1}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'FROM'.(SQL Code: 0, SQL State: + null) (com.microsoft.sqlserver.jdbc.SQLServerException)
com.microsoft.sqlserver.jdbc.SQLServerException:190 (null)
2. com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'FROM'. Query: SELECT product_strategy, product_id FROM licensing.product WHERE product_name = ? AND (product_sku is null OR product_sku = ? ) ORDER BY product_sku DESC Parameters: [My Product, My Product](SQL Code: 0, SQL State: + null) (java.sql.SQLException)
org.apache.commons.dbutils.QueryRunner:540 (null)
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://QueryStrategy, connector=JdbcConnector
{
name=Database
lifecycle=start
this=333d612e
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=false
connected=true
supportedProtocols=[jdbc]
serviceOverrides=<none>
}
, name='endpoint.jdbc.QueryStrategy', mep=REQUEST_RESPONSE, properties={queryTimeout=-1}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String (org.mule.api.transport.DispatchException)
org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.microsoft.sqlserver.jdbc.SQLServerException: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'FROM'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.<init>(SQLServerParameterMetaData.java:426)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getParameterMetaData(SQLServerPreparedStatement.java:1532)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************