Point not a valid property - MongoDB & Grails 3.3+ - mongodb

Having a really weird issue in Grails and MongoDB where in my production environment I get the following error.
java.lang.IllegalArgumentException: Property [location] is not a valid property of class [domain].Tracking
at org.grails.datastore.mapping.reflect.FieldEntityAccess$FieldEntityReflector.getPropertyReader(FieldEntityAccess.java:268)
at org.grails.datastore.mapping.reflect.FieldEntityAccess$FieldEntityReflector.getProperty(FieldEntityAccess.java:286)
at grails.gorm.validation.PersistentEntityValidator.validatePropertyWithConstraint(PersistentEntityValidator.groovy:319)
at grails.gorm.validation.PersistentEntityValidator.validate(PersistentEntityValidator.groovy:76)
at org.grails.datastore.gorm.GormValidationApi.doValidate(GormValidationApi.groovy:124)
at org.grails.datastore.gorm.GormValidationApi.validate(GormValidationApi.groovy:153)
at org.grails.datastore.gorm.GormValidateable$Trait$Helper.validate(GormValidateable.groovy:71)
at org.grails.datastore.gorm.GormValidateable$Trait$Helper$validate$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at [domain].Tracking.validate(Tracking.groovy)
at org.grails.datastore.gorm.GormInstanceApi.doSave(GormInstanceApi.groovy:332)
at org.grails.datastore.gorm.GormInstanceApi.doSave(GormInstanceApi.groovy)
at sun.reflect.GeneratedMethodAccessor113.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:947)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:930)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:92)
at org.grails.datastore.gorm.GormInstanceApi$_save_closure5.doCall(GormInstanceApi.groovy:179)
at sun.reflect.GeneratedMethodAccessor112.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:54)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:124)
at com.sun.proxy.$Proxy111.doInSession(Unknown Source)
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:319)
at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:40)
at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:178)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:151)
at org.grails.datastore.gorm.GormEntity$Trait$Helper$save.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at [domain].Tracking.save(Tracking.groovy)
at [domain].Tracking.save(Tracking.groovy)
at org.grails.datastore.gorm.GormEntity$save$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at autovision.web.BootStrap$_closure1.doCall(BootStrap.groovy:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1099)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:541)
at grails.util.Environment.executeForEnvironment(Environment.java:534)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:510)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:74)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:261)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at autovision.web.Application.main(Application.groovy:8)
This is happening when I try to insert a new Tracking Object into the DB like so :
Tracking tp = new Tracking()
tp.setUser(user)
nowCal.add(Calendar.MINUTE,i++)
tp.setCreated(nowCal.getTime())
tp.setSpeed(10f)
tp.setLocation(new Point(points[1],points[0]))
tp.save(flush:true)
user.addToTracking(tp);
And my Tracking class is defined as so :
import grails.mongodb.geo.Point
class Tracking {
Point location
Date created
float speed
static belongsTo = [user:User]
static constraints = {
speed nullable:true
}
static mapping = {
location geoIndex:'2dsphere'
}
}
I really can't see what the problem is here, I Think I've defined everything correctly as it shows in the GORM documentation : http://gorm.grails.org/latest/mongodb/manual/#geoSpatial
The other thing is this code works perfectly well when running in non prod mode.
so executing grails run-app works but grails prod run-app doesn't..
Any help would be much appreciated.
Thanks
Lee.

I had the same issue, and after two days of debugging finally found a workaround.
The problem was caused by the following:
There is a Grails utility class called org.grails.datastore.mapping.reflect.FieldEntityAccess, apparently used to access entities fields using reflection. That class has an inner class called FieldEntityReflector. Every time a FieldEntityAccess instance is created, there is an instance of FieldEntityReflector created internally. All those instances are stored in a static map called REFLECTORS, whose keys are the entity names, apparently for performance reasons.
During bean initialization, mongoDatastore bean creates one FieldEntityAccess for each entity, passing a DocumentPersistentEntity as constructor parameter.
In the same way, grailsDomainClassMappingContext bean, unaware of mongoDatastore creates its own FieldEntityAccess for each entity, passing down KeyValuePersistentEntity as parameter. Those FieldEntityAccess instances and their corresponding EntityReflectors are unaware of mongo and therefore don't support mongo specific types like Point.
Given that the REFLECTORS map keys are entity names, EntityReflectors created last for the same entity, override previously created reflectors, and are used by all EntityReflector instances.
When grailsDomainClassMappingContext reflectors are created last, they are used when mongo tries to persist and entity and therefore throw an error.
In short, the error is thrown when grailsDomainClassMappingContext bean is initialized after mongoDatastore bean.
In development mode, UrlMappingsGrailsPlugin plugin creates some beans used to allow url mappings reloading. Those beans trigger instantiation of grailsDomainClassMappingContext bean before mongoDatastore bean. As the mongo beans are created later, the error is not thrown. But, in production mode, those beans are not created, and mongoDatastore is created before grailsDomainClassMappingContext, therefore throwing the error.
Potential solutions
Force grailsDomainClassMappingContext bean instantiation before mongoDatastore: I was unable to do that after several attempts, maybe because of grails bean instantiation logic.
Force UrlMappingsGrailsPlugin instantiation even on production mode: I prefered not to go that way due to possible permformance implications.
Use the static method clearReflectors of FieldEntityAccess class to clear all the reflectors after system initialization:** I decided to do that and the system started to work. I haven't tested it in depth, but was able to persist Point correctly.
In order to call the method, I created a bean depending on both grailsDomainClassMappingContext and mongoDatastore and called FieldEntityAccess.clearReflectors()
package app.utils
import org.grails.datastore.mapping.mongo.MongoDatastore
import org.grails.datastore.mapping.reflect.FieldEntityAccess
import org.grails.datastore.mapping.model.MappingContext
class MongoDatastoreHolder {
MongoDatastore mongo
MappingContext context
MongoDatastoreHolder(MappingContext context, MongoDatastore mongo) {
this.context = context
this.mongo = mongo
FieldEntityAccess.clearReflectors()
}
}
And defined that bean in resources.groovy:
import app.utils.MongoDatastoreHolder
beans = {
mongoDatastoreHolder(MongoDatastoreHolder, ref('grailsDomainClassMappingContext'), ref('mongoDatastore')) { bean ->
bean.lazyInit = false
}
}
Hope it helps, and sorry for my bad english, this is my first StackOverflow answer.

Related

Springboot application.properties for postgres not working - FATAL: database "null" does not exist

The problem I am experiecning is that the auto configuration from Springboot version: 1.5.9.RELEASE seems not to be effective.
Note, I probably will be able to overcome my current problem if I define a bean that returns out a DataSource bean.
Probably the DataSource bean could look very similar to the:
Example in the following snippet:
https://www.atomikos.com/Documentation/ConfiguringPostgreSQL
I am switching my application.properties configuration to stop using the default H2 database used by spring boot and switching it to postgres.
The configuration snippet illustrated in the following page:
https://dzone.com/articles/configuring-spring-boot-for-postgresql
Is definitely not working.
Here is what my configuration looks like:
spring.datasource.url=jdbc:postgresql://localhost:5432/dummydb
spring.datasource.username=DUMMYDB
spring.datasource.password=DUMMYDB
spring.jpa.hibernate.ddl-auto=create-drop
This does not work, and why?
Apparently for a very simple reason.
While the user name and password are definitely of use and getting transferred over at the time that the connection factory tries to build a connection for the database.
The URL attribute is of no use when it comes to configuring the data source.
Let me start by giving you the final stack trace:
Caused by: org.postgresql.util.PSQLException: FATAL: database "null" does not exist
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:469) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:112) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.Driver.makeConnection(Driver.java:393) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.Driver.connect(Driver.java:267) ~[postgresql-9.1-901.jdbc4.jar:na]
at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[na:1.8.0_112]
at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[na:1.8.0_112]
at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:91) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.xa.PGXADataSource.getXAConnection(PGXADataSource.java:47) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.xa.PGXADataSource.getXAConnection(PGXADataSource.java:32) ~[postgresql-9.1-901.jdbc4.jar:na]
at com.atomikos.jdbc.AtomikosXAConnectionFactory.createPooledConnection(AtomikosXAConnectionFactory.java:60) ~[transactions-jdbc-3.9.3.jar:na]
... 44 common frames omitted
Why this does not work is because the postgres base data source does not care at all for being configured via URL.
Rather it wants to be configured via setters that pass over:
databaseName, port, etc...
Please have a look at the following class:
org.postgresql.ds.common.BaseDataSource
This class provides multiple setters. For username, for password etcc..
But there is no setter for an URL. The individual elements that compose the URL such as the database name need to go into the dedicated fields.
So instead what the class offers is this getURL() method that is retuning the strange URL where the datbase is null.
Here is a code snippet for the method.
/**
* Generates a DriverManager URL from the other properties supplied.
*/
private String getUrl()
{
StringBuffer sb = new StringBuffer(100);
sb.append("jdbc:postgresql://");
sb.append(serverName);
if (portNumber != 0) {
sb.append(":").append(portNumber);
}
sb.append("/").append(databaseName);
sb.append("?loginTimeout=").append(loginTimeout);
sb.append("&socketTimeout=").append(socketTimeout);
sb.append("&prepareThreshold=").append(prepareThreshold);
sb.append("&unknownLength=").append(unknownLength);
sb.append("&loglevel=").append(logLevel);
if (protocolVersion != 0) {
sb.append("&protocolVersion=").append(protocolVersion);
}
if (ssl) {
sb.append("&ssl=true");
if (sslfactory != null) {
sb.append("&sslfactory=").append(sslfactory);
}
}
sb.append("&tcpkeepalive=").append(tcpKeepAlive);
if (compatible != null) {
sb.append("&compatible="+compatible);
}
if (applicationName != null) {
sb.append("&ApplicationName=");
sb.append(applicationName);
}
return sb.toString();
}
So then the question for me was.
Ok... if the postgres data source does not wished to be configured via url but rather via the various different setters, perhaps I can get away by adding to the application.properties file fields such as:
#spring.datasource.databaseName=dummydb
Nope, it turns out this seems to be of no use at all.
After some debugging, I a managed to find out this spring boot auto configuration class:
org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration
The above class is very interesting, since it is at the route of the configuration of the atomics JTA transaction subsytem.
IT will setup the data source:
org.postgresql.xa.PGXADataSource
But the only problem is that this auto configurator only cares for three attributes in our application.properties file.
See the code snippet bellow:
private void bindXaProperties(XADataSource target, DataSourceProperties properties) {
MutablePropertyValues values = new MutablePropertyValues();
values.add("user", this.properties.determineUsername());
values.add("password", this.properties.determinePassword());
values.add("url", this.properties.determineUrl());
values.addPropertyValues(properties.getXa().getProperties());
new RelaxedDataBinder(target).withAlias("user", "username").bind(values);
}
As you can see, it appears that I am "toasted".
The auto configurator has no notion of any other data source properties that could be relevant.
Which I find surprising to say the least.
I was expecting some sort of class that would not have any thing such as hard-coded subset of properties such as user name and password.
I was expecting some sort of code that would trivially be looping all of the applicaton.properties and hunting for any property whose key would start with:
spring.datasource.whatever
And call the datasource.setWhatever on the data source class.
Seems not to be the case.
So I am certain I must be messing up something.
I cannot believe that springboot would not be able to configure postgres database without forcing a developer to create his own datasource bean.
Postgress is simply too main stream...
So I was wondering if someone could help me figure out how to properly configure the application.properties file to ensure that indeed I can connect to postgres with springboot.
Meanwhile, I will see if I acn work-around this problem by creating programtically a class like:
#AutoConfigureBefore(DataSourceAutoConfiguration.class)
#EnableConfigurationProperties(DataSourceProperties.class)
#ConditionalOnClass({ DataSource.class, TransactionManager.class,
EmbeddedDatabaseType.class })
#ConditionalOnBean(XADataSourceWrapper.class)
#ConditionalOnMissingBean(DataSource.class)
public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
But in my case the class would know how to programatically build the postgres data source with all necessary properties to connect.
Many thanks for the help.

How to correctly setup RUTA config parameters in the script?

Help is needed with a code example for proper understanding of setting parameters in own RUTA script.
In my case I need to setup the configuration parameter "emptyIsInvisible" to false. The root cause is described in Are some extra settings in RUTA script needed to detect annotations with the same begin and end attributes?
I made two attempts
1) use the name of standard Ruta Engine:
ENGINE BasicEngine;
Document{->CONFIGURE(BasicEngine, "emptyIsInvisible" = false)};`
That part of the script does not change the default settings.
2) use the name of own engine:
ENGINE xxx.yyy.zzz.TagEngine;
Document{->CONFIGURE(TagEngine, "emptyIsInvisible" = false)};
In that case the script raises the following exception:
Exception in thread "main" java.lang.StackOverflowError
at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242)
at java.io.File.exists(File.java:819)
at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1081)
at sun.misc.URLClassPath$FileLoader.findResource(URLClassPath.java:1048)
at sun.misc.URLClassPath$1.next(URLClassPath.java:226)
at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:236)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:589)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:587)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader$3.next(URLClassLoader.java:586)
at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:611)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:354)
at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:393)
at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:474)
at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:293)
at java.security.AccessController.doPrivileged(Native Method)
at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267)
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:127)
at org.apache.uima.internal.util.XMLUtils.createSAXParserFactory(XMLUtils.java:543)
at org.apache.uima.util.impl.XMLParser_impl.parse(XMLParser_impl.java:159)
at org.apache.uima.util.impl.XMLParser_impl.parseResourceSpecifier(XMLParser_impl.java:399)
at org.apache.uima.util.impl.XMLParser_impl.parseResourceSpecifier(XMLParser_impl.java:381)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:278)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:279)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:279)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:279)
at org.apache.uima.ruta.engine.Ruta.wrapAnalysisEngine(Ruta.java:270)
at org.apache.uima.ruta.engine.RutaEngine.initializeEngines(RutaEngine.java:896)
at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:820)
at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:527)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:172)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
....
This parameter will not solve the problems in the linked question. The parameter controls the basic matching if there are no annotations at all at some positions. This means that is will only affect the matching if a different seeding is applied, e.g., there is no seeding.
Concerning this question:
You cannot configure the RutaEngine analysis engine within the script the analysis engine tries to execute. You need to set the configuration parameter on framework level. This depends on how you create and run the UIMA analysis engines in your code.
In a simple Ruta project, you need to modify the template analysis engine description (BasicEngine.xml) so that the generated descriptions will contain the parameter value.
Using uimaFIT or other factory methods, you need to pass the parameter and its value when creating the description or analysis engine.
DISCLAIMER: I am a developer of UIMA Ruta

I am getting error "java.lang.NullPointerException"

I am using selenium Webdriver for the testing web application. I am using marioette driver for the same as I am havin firefox 48.0 since yusing the same the web page gets open however I am not able to put the values in the text box it gives the error " java.lang.NullPointerException"
I have written code
#BeforeTest
public void setUp() throws Exception {
System.setProperty("webdriver.gecko.driver", "D:\\ashwini\\geckodriver.exe");
driver= new MarionetteDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
#Test
public void testAddAccount() throws Exception {
driver.get("http://qa.luna.wexeurope.com/CPCardWeb/login.htm?programme=CPYCGB");
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("cp_admin");
}
#AfterTest
public void teardown()
{
driver.quit();
}
Output is:
1472448949884 Marionette INFO sendAsync 3744f8a9-772e-42fe-8c85-6f9964888fb1
FAILED: testAddAccount
java.lang.NullPointerException
at Add_Account.testAddAccount(Add_Account.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
I have checked the same it gives null values in sendkeys.
However instead of by.id I have used other options like name, xpath, css selector for the same
it gives the error only.
Value is still not inserted in the text box
Line no 36 is
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("cp_admin");
I have debug that as you said, Yes it passes the null value to the element that's why it throws null pointer exception. so please let me know to solve this. as I have tried to pass values using the id, name, xpath, css selecter. same error is displayed. so could u please help me?
NullPointerException means your driver is not initialized properly and hence it has null value when it tries to find a element. This is not related to xpath/id etc.
Please check line number 36 of Add_Account class you will get to know where exactly there is an error. It will be good if you put whole code of your class for anyone to look into.
issue is resolved by removing unwanted jar from the referenced library

Is hot code replace supposed to work for Groovy in Eclipse?

I was wondering if anyone was able to get Groovy hot replace working in Eclipse reliably. I can't find any useful info about this, so I am not sure if it's b/c it's just working for everyone else? Or is nobody using Eclipse to do Groovy development?
I have tried using the latest Eclipse (4.5 Mars) with latest Groovy-Eclipse plugin (Groovy Eclipse 2.9.2 from http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/), and I still can't get reliable hot replace.
Some simple hot replace scenarios work fine. However, just a little bit of complexity leads to strange Groovy exceptions. I get different errors in different situations, but I was able to reproduce one in a simple junit, so I'll demonstrate that one with some simplified domain objects.
HotSwapTests.groovy:
class HotSwapTests {
#Test
public void testHotReplace() {
DefaultTxView transactionGroup = new DefaultTxView();
List<Default> defaults = [];
Default d1 = new Default(ProducerAccountTransactionType.REPAID_AMOUNT, ParticipantAccountType.DEFAULT);
Default d2 = new Default(ProducerAccountTransactionType.REPAID_AMOUNT, ParticipantAccountType.DEFAULT);
d1.setCancelledDefault(d2);
defaults << d1;
transactionGroup.setDefaultTransactions(defaults);
while (true) {
Default result = transactionGroup.getRepaymentTransaction();
println result
}
}
}
DefaultTxView.groovy:
public class DefaultTxView {
def List<Default> defaultTransactions;
public Default getRepaymentTransaction() { return getTransactionOfType(REPAID_AMOUNT); }
public Default getTransactionOfType(ProducerAccountTransactionType type) {
return defaultTransactions.find { it.getType() == type };
}
Default.java:
The contents of this domain object are not really important - it's a simple POJO.
Now, to test hotswap I place a breakpoint at the marked line:
while (true) {
Default result = transactionGroup.getRepaymentTransaction(); <<< break
println result
}
And then I go to DefaultTxView.groovy and modify the code inside the closure passed in to the find method:
public Default getTransactionOfType(ProducerAccountTransactionType type) {
return defaultTransactions.find { it.getType() == type && it.getCancelledDefault() == null};
}
I don't get any warning or error messages when I save the file, but if I attempt to step over the modified line now, I get the following exception:
java.lang.ArrayIndexOutOfBoundsException: 2
at ca.gc.agr.app.web.jsf.producer.DefaultTxView$_getTransactionOfType_closure1.doCall(DefaultTxView.groovy:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker.invoke(BooleanReturningMethodInvoker.java:48)
at org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper.call(BooleanClosureWrapper.java:50)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.find(DefaultGroovyMethods.java:3060)
at org.codehaus.groovy.runtime.dgm$175.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView.getTransactionOfType(DefaultTxView.groovy:15)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView$getTransactionOfType$1.callCurrent(Unknown Source)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView.getRepaymentTransaction(DefaultTxView.groovy:11)
at ca.gc.agr.app.web.jsf.producer.DefaultTxView$getRepaymentTransaction$0.call(Unknown Source)
at ca.gc.agr.app.web.jsf.temp.HotSwapTests.testHotReplace(HotSwapTests.groovy:29)
I get very similar results when running my webapp in TomCat, with the same exception after modifying that line. Restarting the junit, or TomCat makes the new line work fine, so it's definitely a hot replace issue.
So what am I doing wrong? Any advice would be appreciated.
I've used hot deploy in a web dev environment with groovy successfully in the past using the eclipse plugin.
IIRC, I used groovyReset.jar, DCEVM and jdk1.7.
groovyReset.jar should be in the classpath and set as java agent. I've used the one found inside the groovy-eclipse plugin folder (like eclipse/plugins/org.codehaus.groovy_2.3.7.xx-201411061335-e44-RELEASE/extras/groovyReset.jar)
-javaagent:/groovyReset.jar
New closures and methods were instantly visible without redeploy. Of course including a simple LOC in a method worked too. Sometimes i needed to restart the VM, but still a breath of fresh air.
In your case, i think at least groovyReset.jar must be present. It is responsible for resetting the metaclass. If you decompile a groovy class you can check method calls being called by reflection using an array of java.lang.Method. Upon hot code swap this array gets out of order, needing a reset.

GWT History issue

Is it possible to add/create new history token from every class? I have the problem, that i get NullPointerException if i try to create new token (History.newItem("infoTab")) outside the main class (the main class contains the onModuleLoad() method). Here the error message:
09:45:11.890 [ERROR] [com.mycompany.client.AdminInterface] Unable to load module entry
point class com.mycompany.client.entries.MainEntry (see associated exception for details)
edit: the iframe part was not added in the index.html. After adding it, i get following:
11:16:48.885 [ERROR] [com.mycompany.client.AdminInterface] Error while executing the JavaScript provider for property 'user.agent'
com.google.gwt.core.client.JavaScriptException: (null): null
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at com.google.gwt.dev.shell.ModuleSpacePropertyOracle.computePropertyValue(ModuleSpacePropertyOracle.java:189)
at com.google.gwt.dev.shell.ModuleSpacePropertyOracle.getSelectionProperty(ModuleSpacePropertyOracle.java:127)
at com.google.gwt.dev.cfg.ConditionWhenPropertyIs.doEval(ConditionWhenPropertyIs.java:58)
at com.google.gwt.dev.cfg.Condition.isTrue(Condition.java:49)
at com.google.gwt.dev.cfg.ConditionAny.doEval(ConditionAny.java:37)
at com.google.gwt.dev.cfg.Condition.isTrue(Condition.java:49)
at com.google.gwt.dev.cfg.ConditionAll.doEval(ConditionAll.java:38)
at com.google.gwt.dev.cfg.Condition.isTrue(Condition.java:49)
at com.google.gwt.dev.cfg.Rule.isApplicable(Rule.java:36)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind(StandardRebindOracle.java:98)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:54)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:154)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:119)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:531)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:414)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:39)
at com.google.gwt.core.client.GWT.create(GWT.java:98)
at com.google.gwt.user.client.ui.Hyperlink.<clinit>(Hyperlink.java:65)
at com.mycompany.client.entries.MainEntry.onModuleLoad(MainEntry.java:110)
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.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:662)
Line 110 from MainEntry is:
searchButton = new Hyperlink("Search", SEARCH_ID);
so i can't really understand, what is wrong...whithout the iframe i get five history tokens added successfully as follow http://localhost:8080/client/index.html#token1.
It works with and without the iframe tag in my index.html. My mistake was, that i use the url query parameters wrong...after the # :)