Getting error on update when using a different version mongodb java client.
I ran the dependency-report and found that only 1 jar for mongdb java driver is existing.
Please guide why this error is coming, I am trying to update domain object through GORM.
dependencies {
runtime "org.mongodb:mongo-java-driver:2.9.0"
}
plugins {
compile (":mongodb:1.3.0"){
excludes "mongo-java-driver";
}
}
Message: ACKNOWLEDGED
Line | Method
->> 646 | doInDB in
org.grails.datastore.mapping.mongo.engine.MongoEntityPersister$5
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 616 | updateEntry in
org.grails.datastore.mapping.mongo.engine.MongoEntityPersister
| 78 | updateEntry . . . . . . in ''
| 846 | run in
org.grails.datastore.mapping.engine.NativeEntryEntityPersister$2
| 33 | executePendingOperation in
org.grails.datastore.mapping.core.impl.PendingOperationExecution
| 364 | flushPendingOperations in org.grails.datastore.mapping.core.AbstractSession
| 343 | flushPendingUpdates . . in ''
| 263 | flush in ''
| 126 | flush . . . . . . . . . in org.grails.datastore.mapping.mongo.MongoSession
WriteConcern.ACKNOWLEDGED is only available in the MongoDB Java Driver version 2.10 and above. You either need to update your Mongo version:
dependencies {
runtime "org.mongodb:mongo-java-driver:2.10.0"
}
or you need to remove your exclusion of the mongo driver here:
compile (":mongodb:1.3.0"){
excludes "mongo-java-driver";
}
and replace it with:
compile ":mongodb:1.3.0"
If you take this second option, this will use the 2.11 version of the Mongo Java Driver, which is what this plugin code is expecting. Using a version of the driver that is older than 2.11 is likely to cause these sorts of issues.
Related
I have following very simple module definition in build.src
import mill._
import mill.bsp.BSP.millSourcePath
import mill.scalalib.{JavaModule, ScalaModule}
object scalaMod0 extends ScalaModule {
override def scalaVersion = "2.13.6"
}
Mill version is 0.9.9
Then I try to run
mill show scalaMod0.resolvedAmmoniteReplIvyDeps
1/1] show interp.watchValue millSourcePath: /home/jk/workspace.exp/hands-on-scala/mill01
[1/1] show > [9/9] scalaMod0.resolvedAmmoniteReplIvyDeps | Downloading [2/2] artifacts (~0/0 bytes)
1 targets failed
show 1 targets failed
scalaMod0.resolvedAmmoniteReplIvyDeps
Resolution failed for 1 modules:
--------------------------------------------
com.lihaoyi:ammonite_2.13.6:2.3.8-65-0f0d597f
not found: /home/jk/.ivy2/local/com.lihaoyi/ammonite_2.13.6/2.3.8-65-0f0d597f/ivys/ivy.xml
not found: https://repo1.maven.org/maven2/com/lihaoyi/ammonite_2.13.6/2.3.8-65-0f0d597f/ammonite_2.13.6-2.3.8-65-0f0d597f.pom
The contents of https://repo1.maven.org/maven2/com/lihaoyi/ammonite_2.13.6 are following:
com/lihaoyi/ammonite_2.13.6
../
2.3.8-122-9be39deb/ 2021-05-17 21:19 -
2.3.8-123-0b9a8c9b/ 2021-05-18 14:20 -
2.3.8-124-2da846d2/ 2021-05-19 04:57 -
2.3.8-125-f6bb1cf9/ 2021-06-08 13:15 -
2.3.8-67-4b6c67db/ 2021-05-17 19:50 -
2.4.0/ 2021-06-08 13:25 -
2.4.0-10-40f87721/ 2021-07-27 12:49 -
2.4.0-11-5b9ff5e7/ 2021-07-27 12:57 -
2.4.0-12-69f45b4b/ 2021-07-27 13:05 -
2.4.0-13-6ffcb9ff/ 2021-07-30 16:49 -
2.4.0-14-4824b429/ 2021-08-02 15:59 -
2.4.0-17-6dbd7856/ 2021-08-30 14:06 -
2.4.0-18-12c9e33e/ 2021-09-01 15:35 -
2.4.0-19-f4790b61/ 2021-09-01 16:24 -
2.4.0-20-f3d8171f/ 2021-09-09 16:33 -
2.4.0-22-a70409dc/ 2021-09-09 23:09 -
2.4.0-23-76673f7f/ 2021-09-16 16:30 -
2.4.0-5-534c9436/ 2021-07-15 18:25 -
2.4.0-6-426d8ae5/ 2021-07-27 10:13 -
2.4.0-9-0017ff97/ 2021-07-27 11:59 -
maven-metadata.xml 2021-09-16 16:32 1175
maven-metadata.xml.md5 2021-09-16 16:32 32
maven-metadata.xml.sha1 2021-09-16 16:32 40
maven-metadata.xml.sha256 2021-09-16 16:32 64
maven-metadata.xml.sha512 2021-09-16 16:32 128
So the requested dir 2.3.8-65-0f0d597f does not exist.
How can I fix this?
Where is this 2.3.8-65-0f0d597f configured or selected? Why does mill want exactly this non-existing ammonite version?
When I start my local installed ammonite, it shows following version information:
amm
Loading...
Welcome to the Ammonite Repl 2.2.0 (Scala 2.13.3 Java 11.0.11)
Thank you for your help!
This is already discussed in the mill discussions forum (https://github.com/com-lihaoyi/mill/discussions/1396).
I'm mostly quoting an adapted version here:
Mill will by default pick the same ammonite version which it uses internally. But as ammonite releases need to match the full Scala version, and the pre-selected ammonite version (2.3.8-65-0f0d597f) wasn't released for Scala 2.13.6, you need to specify another ammonite version by overriding def ammoniteVersion.
For example:
import mill._
import mill.scalalib.ScalaModule
object scalaMod0 extends ScalaModule {
override def scalaVersion = "2.13.6"
override def ammoniteVersion = "2.4.0"
// ...
}
I have a publisher that emits an object which contains a few params. In the object, one of the params (called optionId) distinctly identifies an option. I'd like to debounce instances of that emission. However, if a new optionId shows up, I'd like to start a new clock, and start a new debounce.
Consider a stream like this:
Time in seconds: optionID emitted at source | what debounce(3 seconds) gets me | what I need //- means no event emitted.
00: 1 | - | -
01: 1 | - | -
02: - | - | -
03: - | - | -
04: - | 1 | 1
05: - | - | -
06: 3 | - | -
07: 1 | - | -
08: 3 | - | -
09: 1 | - | -
10: - | - | -
11: - | - | 3
12: - | 1 | 1
13: - | - | -
Your drawing has nothing whatever in common with what the Rx groupBy does. Thus your title is misleading.
Perhaps you are also misusing the word "debounce"? Debouncing has to do with timing, and nothing in your diagram shows anything about that either. Debouncing has nothing to do with what values arrive; it simply insists upon a big gap of empty time before it will pass any value downstream at all (namely the most recent value).
It seems to me more likely that you simply want the removeDuplicates() operator. That would result in 1,3,1,3,1,3,1 which is exactly the output you give.
Okay, now that you've reworded the question, it occurs to me that you might be looking for something like this (this is just a demo, but it will give you the idea):
let pub = [1,1,1,3,3,3,1,3,1,3,1].publisher
.flatMap(maxPublishers:.max(1)) { num in
Just(num).delay(for:.seconds(1), scheduler: DispatchQueue.main)
}
.share()
let p1 = pub
.filter { $0 == 1 }
.debounce(for: .seconds(1.5), scheduler: DispatchQueue.main)
let p2 = pub
.filter { $0 == 3 }
.debounce(for: .seconds(1.5), scheduler: DispatchQueue.main)
p1.merge(with: p2)
.sink { print($0, Date().timeIntervalSince1970) }
.store (in: &storage)
What I'm doing here is exactly what you said: I'm splitting the stream into two streams, based on whether this is a 1 or a 3, and I'm debouncing each of those streams before joining them back together.
The result is:
1 1614228919.57355
3 1614228922.823595
1 1614228923.923283
3 1614228925.0221992
1 1614228926.12345
If you think about those numbers, you'll see that we are indeed debouncing each value (1 or 3) separately.
Edited my code, tried a different approach to get the desired output.
Let me know if it's correct
import re
pattern1 = re.compile(r'\b(ERROR)')
pattern2 = re.compile(r'^\d+-\d+-\d+')
count =0
with open('sample.txt',encoding='utf-8')as f:
for i in f:
a= re.search(pattern1,i)
if a:
count = count + 1
b = re.search(pattern2,i)
if b:
print(b.group(),':',a.group())
print('Total ERROR in the logfile:',count)
***output:***
2019-11-22 : ERROR
2019-11-22 : ERROR
2019-11-20 : ERROR
Total ERROR in the logfile: 3
log.txt
2019-11-22 16:46:46,985 - main - INFO - Starting to Wait for Files
2019-11-22 16:46:56,645 - main - INFO - Starting: Attempt 1 Checking for New Files
2019-11-22 16:47:46,488 - main - INFO - Success: Downloading the Files from Cloud Storage: Return
2019-11-22 16:48:48,180 - main - ERROR - Failed: Waiting for files the Files
2019-11-22 16:49:17,918 - main - INFO - Starting to Wait for Files
2019-11-22 16:49:32,160 - main - INFO - Starting: Attempt 1 Checking for New Files
2019-11-22 16:49:39,329 - main - WARNING - Success: Downloading the Files from Cloud Storage:
2019-11-22 16:53:30,706 - main - WARNING - Starting to Wait for Files
2019-11-22 16:53:48,180 - main - ERROR - Failed: Waiting for files the Files
2019-11-20 10:00:00,121 - main - ERROR - Failed: Waiting for files the Files
The pattern you should be using to match error lines is:
^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\bERROR\b.*$
Your updated script:
pattern1 = re.compile(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\bERROR\b.*$')
count = 0
with open('log.txt',encoding='utf-8')as f:
for i in f:
a = re.search(pattern1, i)
if a:
count = count + 1
So i have simple shell commands to ping websites to retrieve data about said websites.
For example one of my pinging.sh looks like this:
ping -R -c 120 blar.org.cn >> pingdata.txt
ping -R -c 120 another.net >> pingdata.txt
But then my crontabs look like this:
7 * * * ./pinging.sh >> pingdata.log
The pingdata.log doesn't output. Is it best to do it through the crontab or through the script? I assumed the crontab would be better because it would cover the entire script rather than having to write it out multiple times.
You need to indicate the full path of your script in the cronjob, together with the binary running it.
For example:
7 * * * * /bin/sh /home/you/pinging.sh >> /home/you/pingdata.log
Note also you are just adding 4 parameters to the cronjob, whereas you need at least 5:
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed
You can test your cron syntax with Crontab guru (---> http://crontab.guru/).
First, the executable must be provided as full path in cron.
Example:
7 * * * * /bin/bash /path/to/pinging.sh
Second, create a wrapper script for pinging.sh >> pingdata.log and add that to crontab.
Third, your crontab entry is wrong. There must be 5 fields whereas your's have 4 (maybe that's a typo ?)
I am experiencing some troubles with the Vaadin integration into a Grails project in Eclipse.
I am using the Eclipse (version 4.4 Luna) provided by Spring Tool Suite (version 3.6.3) and Grails (version 2.4.4).
I create a Grails project:
File -> New -> Grails Project
I am reading the Vaadin Cookbook book, the author says that in order to use Vaadin in a Grails project, the Vaadin plugin for Grails must be installed. The author says that one should:
Open the grails console and type:
grails> install-plugin vaadin
However, this is deprecated as of Grails 2.4.3, and the plugin must be added to the BuildConfig.groovy file like this (basing on this tutorial of one of the co-authors of the book -> https://vaadin.com/wiki/-/wiki/Main/Vaadin%20on%20Grails%20-%20Create%20project%20in%20IntelliJ%20IDEA (IntelliJIDEA is used in the linked URL instead of Eclipse)):
// BuildConfig.groovy
// ...
grails.project.dependency.resolution = {
//...
plugins {
//...
compile ":vaadin:7.3.9"
//...
}
}
But then, what should I do? In the book they say that the grails-app/vaadin folder must be marked as the source folder (Build Path -> Use as source folder), but there's no such folder in my Grails project.
Also, from the tutorial with InlliJIDEA linked above, the author says:
Now I have tried to edit the UrlMappings.groovy file in order to remove all the mappings:
class UrlMappings {
static mappings = {
}
}
And then when I run the run-app command I get the following exception:
|Running Grails application
objc[42370]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
| Error 2015-01-30 11:33:56,213 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
Line | Method
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by IntegrationException: Error activating Bean Validation integration
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by NoClassDefFoundError: javax/validation/ParameterNameProvider
->> 760 | defineClass in java.lang.ClassLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 142 | defineClass in java.security.SecureClassLoader
| 455 | defineClass in java.net.URLClassLoader
| 73 | access$100 in ''
| 367 | run . . . in java.net.URLClassLoader$1
| 361 | run in ''
| 360 | findClass in java.net.URLClassLoader
| 424 | loadClass in java.lang.ClassLoader
| 269 | configure in javax.validation.Validation$GenericBootstrapImpl
| 111 | buildDefaultValidatorFactory in javax.validation.Validation
| 266 | run . . . in java.util.concurrent.FutureTask
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by ClassNotFoundException: javax.validation.ParameterNameProvider
->> 372 | run in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 361 | run in ''
| 360 | findClass in java.net.URLClassLoader
| 424 | loadClass in java.lang.ClassLoader
| 760 | defineClass in ''
| 142 | defineClass in java.security.SecureClassLoader
| 455 | defineClass in java.net.URLClassLoader
| 73 | access$100 in ''
| 367 | run . . . in java.net.URLClassLoader$1
| 361 | run in ''
| 360 | findClass in java.net.URLClassLoader
| 424 | loadClass in java.lang.ClassLoader
| 269 | configure in javax.validation.Validation$GenericBootstrapImpl
| 111 | buildDefaultValidatorFactory in javax.validation.Validation
| 266 | run . . . in java.util.concurrent.FutureTask
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Error |
Forked Grails VM exited with error
|Server running. Browse to http://localhost:8080/vaadin-in-grails
It says "Server running" at the end but it is not true, and no grails-app/vaadin folder is created as needed.
I didn't find any other tutorials which cover the topic (specifically I was searching for an Eclipse version of the IntelliJIDEA tutorial I linked, but didn't find it).
So, as I know that the book I am reading covers an older version of Grails where plugins are installed via the install-plugin deprecated command and I can't use it and as I have tried to use the compile ":vaadin:7.3.9" directive without success, I am asking someone of SO here.
How can I resolve this issue and start programming with Grails/Vaadin?
Don't use the install-plugin method.
Place this in the plugins section in BuildConfig.groovy:
compile ":vaadin:7.4.1"
From what I understand from the plugin author, the newer versions of the Vaadin/Grails plugin no longer create the grails-app/vaadin directory. Instead, you're now expected to place your vaadin code in the typical src/groovy or src/java folders.
Buddy, I had the same problem but after reading a lot the book Vaadin on Grails and experimenting a lot I came across with the solution, it's important to mention that my grails project is using this configurations, no major changes in version so I believe it should work:
Grails 2.4.5
Vaadin 7.4.8, which is a bit newer,
Oracle Express for Database (this is agnostic)
From your log trace, I see this line:
Caused by ClassNotFoundException: javax.validation.ParameterNameProvider
OK, first things first, go to your BuildConfig.groovy and set this values:
//BuildConfig.groovy
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
compile 'javax.validation:validation-api:1.1.0.Final'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55.2" // or ":tomcat:8.0.20"
// plugins for the compile step
//compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:2.1.5"
compile ":vaadin:7.4.8"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.6.1"
runtime ":database-migration:1.4.0"
//runtime ":jquery:1.11.1"
}
What you have to notice from above code are two things:
Plugins section is using hibernate4:4.3.6.1
In Dependencies section I added following line, from my many reads some people mentioned that due the change from Hibernate3 to Hibernate4 there were some changes in the specification in order to meet some standards (here the javax.validation API was deprecated), so this is the line that solves your problem:
compile 'javax.validation:validation-api:1.1.0.Final'
Now in your file DataSource.groovy, take care of this points:
1. As you remember I set project to use Hibernate4, so the propper configuration should be done.
//DataSource.groovy
dataSource {
pooled = true
jmxExport = true
username = "db_user"
password = "db_password"
dialect = org.hibernate.dialect.Oracle10gDialect
driverClassName = 'oracle.jdbc.OracleDriver'
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'org.hibernate.cache.SingletonEhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
jdbc.use_get_generated_keys = true
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
//url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:oracle:thin:#localhost:1521:xe"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:oracle:thin:#localhost:1521:xe"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:oracle:thin:#localhost:1521:xe"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
Inside the section hibernate you have to set the value for:
cache.region.factory_class
In my case I'm using Hibernate4, so you should use the same value.
Sources:
Check this project out: https://github.com/vaadin-on-grails/sass-compilation and don't forget to buy the book Vaadin on Grails, it has lots of information related.