I've a yaml fileto be passed as an argument to the java class. But it throws below exception:
Logs
Caused by: Cannot create property=heartbeatThreshold for JavaBean=UdsConfigurationBean{jdbcDriverClassString='org.mariadb.jdbc.Driver', sparkConfigFile='spark/spark-local.conf'}
in 'reader', line 15, column 3:
jdbcDriverClassString: org.maria ...
^
Unable to find property 'heartbeatThreshold' on class: MyClass
in 'reader', line 36, column 23:
heartbeatThreshold: 60000000
^
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:292)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:171)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:219)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:269)
... 12 more
Caused by: org.yaml.snakeyaml.error.YAMLException: Unable to find property 'heartbeatThreshold' on class: MyClass
at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:159)
at org.yaml.snakeyaml.introspector.PropertyUtils.getProperty(PropertyUtils.java:148)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.getProperty(Constructor.java:309)
at org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:230)
... 16 more
My Analysis:
MyClass is packaged as jar and it works for another project,so there should be problem with my yaml file.
Yaml validations has passed and seems all the variables are using camelCase.
As per my findings, PropertyUtils has 2 checks for this exception to be thrown, if property value is null(which it is not as per logs) and isWritable(I didn't get this part)
for jdbcDriverClassString, error indication is at name and for heartbeatThreshold value, its at value.
Can you please help me figure it out. I would be really grateful.
Yaml file:
kafka:
kafkaServers: ${udsKafkaEpfConfigurationBean.kafka.kafkaServers}
kafkaPrincipal: ${udsKafkaEpfConfigurationBean.kafka.kafkaPrincipal}
kafkaKeytab: ${udsKafkaEpfConfigurationBean.kafka.kafkaKeytab}
kafkaEnvironment: ${udsKafkaEpfConfigurationBean.kafka.kafkaEnvironment}
storage:
jdbcDriverClassString: ${memsql.driver}
initializationStoresGeneration: true
heartbeatThreshold: ${MyCLass.kafka.heartbeatThreshold}
For me, add Skip Missing Properties property to the yaml fixes the problem:
Yaml = new Yaml()
change to
Representer represent = new Representer()
represent.getPropertyUtils().setSkipMissingProperties(true)
Yaml yaml = new Yaml(represent)
Related
We are trying to add in automated metrics to our Java Application, with Dropwizard metrics. So far, the config.yml file looks like this:
metrics:
reporters:
- type: log
logger: metrics
frequency: 5 minute
includes: "io.dropwizard.jetty.MutableServletContextHandler.active-requests","io.dropwizard.jetty.MutableServletContextHandler.active-dispatches","io.dropwizard.jetty.MutableServletContextHandler.active-suspended"
When running this project, we get an error stating that the yaml file is malformed:
io.dropwizard.configuration.ConfigurationParsingException: test/config.yml has an error:
* Malformed YAML at line: 24, column: 82; while parsing a block mapping
in 'reader', line 20, column 5:
- type: log
^
expected <block end>, but found FlowEntry
in 'reader', line 23, column 81:
... tContextHandler.active-requests","io.dropwizard.jetty.MutableSer ...
^
What exactly is wrong with the way the yaml is written here? My understanding is that the indentation, the spaces, and not having commas in within quotes were correct for this, and we're not able to find any other issues.
Just change line 6 to
includes: [io.dropwizard.jetty.MutableServletContextHandler.active-requests,io.dropwizard.jetty.MutableServletContextHandler.active-dispatches,io.dropwizard.jetty.MutableServletContextHandler.active-suspended]
I want to put my page addresses in the yml file, but I have a problem with this.
path:
api.v1.0: /api/v1.0
api.v1.0:
register: ${path.api.v1.0}/register
register:
token: ${path.api.v1.0.register}/token/{token}
during the compilation it gets such a mistake
Caused by: org.yaml.snakeyaml.parser.ParserException: while parsing MappingNode
in 'reader', line 5, column 5:
register: ${path.api.v1.0}/register
^
Duplicate key: register
in 'reader', line 39, column 1:
Why does it not work?
PS: Is this a good way to place addresses in yml or properties file? Is it professional?
Whether it is good or not depends on the intended uses so I can't add much value there. But the duplication is because your objects have duplicate keys. You might want to consider an array as a data structure:
paths:
-
name: api.v1.0
path: /api/v1.0
paths:
-
name: register
path: "${path.api.v1.0}/register"
-
name: register-token
path: "${path.api.v1.0.register}/token/{token}"
Schema.xml has all fields mentioned to be indexed. it was working all this time and i am facing this issue all of a sudden. What is wrong. Please advise.
Error :
Line 2458: WARN - 2016-10-10 19:53:56.757; [ iccCore]
org.apache.solr.handler.dataimport.EntityProcessorWrapper; transformer
threw error Line 2459:
org.apache.solr.handler.dataimport.DataImportHandlerException: Error
invoking script for entity icMetadataProcessed Processing Document #
2594 Line 2472: Caused by: javax.script.ScriptException: TypeError:
null has no such function "split" in <eval> at line number 8 Line
2478: Caused by: <eval>:8 TypeError: null has no such function "split"
Looks like a Javascript error in your custom script. Possibly about the script expecting a string (to split) and getting null. I would fix the javascript to ignore that field or add debug to see which record is causing that problem, must likely by missing a value.
I'm trying to add new keys in application.conf file in play framework 2.1. I have added the following keys:
gen.db.host=localhost
gen.db.port=27017
gen.db.name=test
When i start my application, it is throwing the following error:
Configuration error: Configuration error[application.conf: 46: port has type NUMBER rather than OBJECT]
......
......
......
Caused by: com.typesafe.config.ConfigException$WrongType: application.conf: 46: port has type NUMBER rather than OBJECT
I don't understand this issue. How can i resolve it? Also, is it a good practice to define new keys in application.conf file?
Thanks.
Put the port between double quotes:
gen.db.port="27017"
You have to use a colon
gen.dn.port:"26017"
Here's a link to the current documentation
http://www.playframework.com/documentation/2.0.x/Configuration
You are propably using wrong method to extract the data from config. I assume you use it like:
current.configuration.getConfig("gen.db.port")
But this method returns play.api.Configuration and expects an object to be under the path "gen.db.port" (as it is mentioned in the error). Since under the "gen.db.port" path you have a number, you should change the method to:
current.configuration.getNumber("gen.db.port")
I have the following class which is persisted into a mongodb using morphia in a play! application. The class resides in a module which is a dependency of another play! application.
Its configuration is read from a file and persisted into the db on initial load (if its not already in the db) and then subsequent requests use the db version.
#Entity
public class Page extends Model {
#Id
public Long navigationId;
// etc ...
}
The initial load and subsequent query access works ok and i can see the page in mongo:
> db.Page.find({_id:20000})
{ "_id" : NumberLong(20000), "className" : "models.Page" etc }
However if i restart play! or make a code change that results in Morphia being reinitialised
(MorphiaPlugin-1.2.4> initialized appears in the logs) i get the following stack trace:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.google.code.morphia.mapping.MappingException: Error setting value from converter (LongConverter) for models.Page.navigationId to 20000
at com.google.code.morphia.mapping.Mapper.fromDb(Mapper.java:487)
at com.google.code.morphia.mapping.Mapper.fromDBObject(Mapper.java:267)
at com.google.code.morphia.query.MorphiaIterator.convertItem(MorphiaIterator.java:66)
at com.google.code.morphia.query.MorphiaIterator.processItem(MorphiaIterator.java:53)
at com.google.code.morphia.query.MorphiaIterator.next(MorphiaIterator.java:48)
at com.google.code.morphia.query.QueryImpl.asList(QueryImpl.java:255)
at play.modules.morphia.Model$MorphiaQuery.asList(Model.java:1067)
at models.Page.findAll(Page.java)
at plugins.PageConfigLoadPlugin.loadPersistedPages(PageConfigLoadPlugin.java:62)
at plugins.PageConfigLoadPlugin.onApplicationStart(PageConfigLoadPlugin.java:51)
at play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:425)
at play.Play.start(Play.java:495)
... 3 more
Caused by: java.lang.RuntimeException: com.google.code.morphia.mapping.MappingException: Error setting value from converter (LongConverter) for models.Page.navigationId to 20000
at com.google.code.morphia.mapping.ValueMapper.fromDBObject(ValueMapper.java:27)
at com.google.code.morphia.mapping.Mapper.readMappedField(Mapper.java:501)
at com.google.code.morphia.mapping.Mapper.fromDb(Mapper.java:484)
... 14 more
Caused by: com.google.code.morphia.mapping.MappingException: Error setting value from converter (LongConverter) for models.Page.navigationId to 20000
at com.google.code.morphia.converters.DefaultConverters.fromDBObject(DefaultConverters.java:133)
at com.google.code.morphia.mapping.ValueMapper.fromDBObject(ValueMapper.java:25)
... 16 more
If i drop the Collection from mongodb using the command line i can again load and query the Page obejct successfully from my play! web application
> db.Page.drop()
true
As I mentioned, this class is in a module. This problem only happens in one application that the module is a dependency of. The other demo application works fine.
any suggestions?
Does the dependent module have another alternate declaration of the Page or
Model classes?
From the top of the stack trace, ("com.google.code.morphia.mapping.MappingException: Error setting value from converter (LongConverter) for models.Page.navigationId to 20000"), it looks like there's a type mismatch between
the way a numeric value is being stored and retrieved. For example, in Java,
it is not uncommon to store something as a Double and then mistakenly try
to retrieve it as an Integer or a Long. So, can you verify that the
declaration of navigationId in the dependent module is the same as the one
you've shown here? They should share the definition, but its possible there's
an alternate.
Another thing to check is that your code is putting a Long into your
DBObject and not a float. For example, if you're inserting it via the shell,
you'll need to use one of the wrappers, e.g.
db.Page.save({_id:NumberLong(20000)});
Otherwise, this will also cause a mismatch when you retrieve it; by default
numbers in JavaScript are doubles.