InvalidDataAccessResourceUsage Exception in spring application test - java

Here is my model:-
DAO:-
public class User implements Serializable {
private int id;
private String name;
private String userIdentifier;
private String accountNumber;
private String baseURL;
private String proxy;
private int timeout;
private String configuration;
private boolean active;
// getters and setters for above variables
}
I am creating user in the test method and I have mandatory fields for the creation. Still I don't know why it is throwing error when I execute the test.
Test method:-
#RunWith(SpringRunner.class)
#SpringApplicationConfiguration(classes = TestApplication.class)
#WebAppConfiguration
public class UserRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
private static final String PATH = "/users/";
#Before
public void setup() throws Exception {
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
createUser("John");
headers = new HttpHeaders();
headers.add(CONTENT_TYPE, APPLICATION_JSON);
}
private void createUser(String name) {
user = new user();
user.setId(INTEGER_ONE);
user.setName(name);
user.setAccountNumber("1234");
user.setActive(TRUE);
user.setUserIdentifier("test");
user.setTimeout(3000);
user.setBaseUrl("https://localhost:8080");
}
#Test
public void testUser() throws Exception {
mockMvc.perform(post(PATH).content(new ObjectMapper().writeValueAsString(demandSource)).headers(headers))
.andDo(print())
.andExpect(status().isCreated());
}
I am getting below error when I execute the above test in my Spring application. What I am doing wrong here ?
Error:-
nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source)
at org.hsqldb.ParserDQL.XreadFromClause(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
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.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)
at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)
at com.sun.proxy.$Proxy112.prepareStatement(Unknown Source)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1929)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1898)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876)
at org.hibernate.loader.Loader.doQuery(Loader.java:919)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:306)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2204)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:60)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:50)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3967)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:508)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:478)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1129)
at org.hibernate.internal.SessionImpl.access$2600(SessionImpl.java:164)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2696)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:980)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:290)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:69)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:840)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:822)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:827)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:1161)
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.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298)
at com.sun.proxy.$Proxy137.merge(Unknown Source)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:509)
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.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy163.save(Unknown Source)
application.yml
spring:
datasource:
url: jdbc:hsqldb:/home/user/unittest/hsql
username: sa
password:
driver-class-name: org.hsqldb.jdbcDriver
testOnBorrow: true
validationQuery: SELECT 1
jpa:
hibernate:
ddl-auto: createordrop
properties:
hibernate:
format_sql: true
show_sql: true
endpoints:
health:
sensitive: false
server:
tomcat:
basedir: target/tomcat
accesslog:
enabled: true
pattern: "%v %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i" %S %D"
How to solve this error ? Kindly help.

I solved this issue by changing the ddl-auto value from createordrop to create-drop in application.yml. It was my mistake. Thanks all for your time and suggestions.
ddl-auto property values are none, validate, update, create, create-drop. Refer here

Related

INFO: Detected dialect: W3C [Utils] [ERROR] [Error] java.lang.NullPointerException

I have tried to run this code but it won't run... It just shows an error INFO: Detected dialect: W3C [Utils] [ERROR] [Error] java.lang.NullPointerException
Please help me with your valid suggestions
I have posted my Runner class file as well as console Error code for your clarification
Runner class:
package tR;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import cucumber.api.testng.CucumberFeatureWrapper;
import cucumber.api.testng.TestNGCucumberRunner;
import io.cucumber.testng.CucumberOptions;
#CucumberOptions(
features = "Feature/result.feature",
glue={"sD"})
public class Tr {
private TestNGCucumberRunner testNGCucumberRunner;
public static WebDriver driver;
public static void openBrowser() throws Exception {
System.setProperty("webdriver.chrome.driver","E:\\xxxxxx\\xx\\chromedriver.exe");
driver = new ChromeDriver();}
#BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
openBrowser();
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());}
#Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
public void feature(CucumberFeatureWrapper cucumberFeature) throws IOException{
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());}
#DataProvider
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();}
#AfterClass(alwaysRun=true)
public void tearDownClass() throws Exception {
testNGCucumberRunner.finish();
}}
Console
org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Utils] [ERROR] [Error] java.lang.NullPointerException
at tR.Tr.features(Tr.java:45)
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)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:77)
at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:46)
at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:146)
at org.testng.internal.Parameters.handleParameters(Parameters.java:820)
at org.testng.internal.Parameters.handleParameters(Parameters.java:762)
at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:60)
at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:39)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:771)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(Unknown Source)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
FAILED CONFIGURATION: #BeforeClass setUpClass
java.lang.NoClassDefFoundError: io/cucumber/stepexpression/TypeRegistry
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at cucumber.runtime.Reflections.hasConstructor(Reflections.java:53)
at cucumber.runtime.Reflections.instantiateSubclasses(Reflections.java:29)
at cucumber.runtime.Runtime.loadBackends(Runtime.java:99)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at cucumber.api.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:42)
at tR.Tr.setUpClass(Tr.java:35)
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)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
at java.util.ArrayList.forEach(Unknown Source)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: io.cucumber.stepexpression.TypeRegistry
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 36 more
FAILED CONFIGURATION: #AfterClass tearDownClass
java.lang.NullPointerException
at tR.Tr.tearDownClass(Tr.java:51)
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)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
at org.testng.internal.TestMethodWorker.invokeAfterClassMethods(TestMethodWorker.java:217)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:130)
at java.util.ArrayList.forEach(Unknown Source)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
SKIPPED: feature
Runs Cucumber Feature
java.lang.RuntimeException: java.lang.NullPointerException
at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:50)
at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:146)
at org.testng.internal.Parameters.handleParameters(Parameters.java:820)
at org.testng.internal.Parameters.handleParameters(Parameters.java:762)
at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:60)
at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:39)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:771)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(Unknown Source)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.NullPointerException
at tR.Tr.features(Tr.java:45)
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)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:77)
at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:46)
... 25 more
first INFO: Detected dialect: W3C is just information about the Dialect that chrome is using (w3c or OSS).
try using the updated selenium and testNG dependencies.
java.lang.NullPointerException is usually caused when you try to use a reference that points to no location in memory (null) as though it were referencing an object. Calling a method on a null reference or trying to access a field of a null reference will trigger a NullPointerException.(https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it)

HSQLDB Serialization error with parallel JobSteps

I'm trying to get a complex flow of jobs done in Spring Batch using a combination of multithreaded Steps and parallel jobs.
Right now I've set up 3 jobs (1, 2, 3), the first (1) of which is running before the others (as expected) and completing withouth issues. The other two (2,3) are supposed to run parallel, having some parallel Steps of their own. All these jobs I'm trying to run are being encapsulated within JobSteps and then run within a master job (0).
The problem only occurs at jobs 2 & 3, where some JobStep fails, not always at the same point, not always the same JobStep. This is the stacktrace of such exception:
2019-01-07 17:35:57,513 ERROR: o.s.b.c.s.AbstractStep [SimpleAsyncTaskExecutor-10] Encountered an error executing step 2 in job0
org.springframework.dao.DataAccessResourceFailureException: Could not increment identity; nested exception is java.sql.SQLTransactionRollbackException: transaction rollback: serialization failure at org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer.getNextKey(AbstractIdentityColumnMaxValueIncrementer.java:113) ~[spring-jdbc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer.nextLongValue(AbstractDataFieldMaxValueIncrementer.java:128) ~[spring-jdbc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.saveJobExecution(JdbcJobExecutionDao.java:151) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:145) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:172) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at com.sun.proxy.$Proxy111.createJobExecution(Unknown Source) ~[?:?]
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:125) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at com.sun.proxy.$Proxy181.run(Unknown Source) ~[?:?]
at org.springframework.batch.core.step.job.JobStep.doExecute(JobStep.java:117) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:93) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:90) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60]
at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:271) [spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]
Caused by: java.sql.SQLTransactionRollbackException: transaction rollback: serialization failure at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer.getNextKey(AbstractIdentityColumnMaxValueIncrementer.java:110) ~[spring-jdbc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 42 more
Caused by: org.hsqldb.HsqlException: transaction rollback: serialization failure at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.Session.handleAbortTransaction(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.Session.executeCompiledStatement(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.Session.executeDirectStatement(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.Session.execute(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source) ~[hsqldb-2.3.5.jar:2.3.5]
at org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer.getNextKey(AbstractIdentityColumnMaxValueIncrementer.java:110) ~[spring-jdbc-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 42 more
I've done a bit of research and this kind of error normally shows up when the HSQLDB I'm using to store job information isn't properly set up for concurrency. However I'm already using the seemingly good config, with MVCC transaction mode:
#Configuration
public class HSqlDbConfig {
#Primary
#Bean("hsqldbDataSource")
public DataSource hsqldbDataSource() {
final SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setDriver(new org.hsqldb.jdbcDriver());
dataSource.setUrl("jdbc:hsqldb:mem:mydb;sql.enforce_strict_size=true;hsqldb.tx=mvcc");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
}
These are my code fragments I use for the configuration of these jobs. Beginning with the main job (0):
#Bean
public Job job0(JobBuilderFactory jobBuilderFactory) {
getJobParameters();
jobLauncher = (JobLauncher) ctx.getBean("jobLauncher");
Flow job1 = getJob1();
Flow job2 = getJob2();
Flow job3 = getJob3();
Flow splitFlow = getSplitFlow(job2, job3);
return jobBuilderFactory.get("Master Job")
.incrementer(new RunIdIncrementer())
.start(job1)
.next(splitFlow)
.end()
.build();
}
How I get the Flow for jobs 2 & 3:
private Flow getJob2() {
Job j2 = (Job) ctx.getBean("job2");
DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor();
Step step0 = getJobStep(j2, extractor);
return new FlowBuilder<Flow>("job2")
.start(step0)
.build();
}
private Flow getJob3() {
Job j3 = (Job) ctx.getBean("job3");
Job j3k = (Job) ctx.getBean("job3K");
Job j3l = (Job) ctx.getBean("job3L");
DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor();
Step step0 = getJobStep(j3, extractor);
Step step1 = getJobStep(j3k, params1);
Step step2 = getJobStep(j3k, params2);
Step step3 = getJobStep(j3l, params3);
Step step4 = getJobStep(j3l, params4);
Flow flow1 = new FlowBuilder<Flow>("flowJ3f1")
.start(step1)
.next(step2)
.build();
Flow flow2 = new FlowBuilder<Flow>("flowJ3f2")
.start(step3)
.next(step4)
.build();
return new FlowBuilder<Flow>("job3")
.start(step0)
.split(taskExecutor)
.add(flow1, flow2)
.build();
}
Both getJobStep() methods:
private Step getJobStep(Job job, JobParametersExtractor extractor) {
return steps.get(job.getName())
.job(job)
.launcher(jobLauncher)
.parametersExtractor(extractor)
.build();
}
private Step getJobStep(Job job, JobParameters jobParameters) {
SimpleJobParametersExtractor extractor = new SimpleJobParametersExtractor();
extractor.setJobParameters(jobParameters);
return steps.get(job.getName())
.job(job)
.launcher(jobLauncher)
.parametersExtractor(extractor)
.build();
}
The idea is to get this structure to work, as parallelization of all task possible is a requirement for this project, and it should be sturdy enough to add other parallel jobs apart from 2 & 3. Also, all jobs and steps have been tested without concurrency and they work as intended.
I can provide more code if needed. Right now I feel in a dead end so every bit of help is appreciated.
EDIT: As #MahmoudBenHassine suggested, I've configured a JobRepository, TransactionManager and JobLauncher (it solved my first issue) like so:
#Bean(name = "myTransactionManager")
public DataSourceTransactionManager transactionManager(#Qualifier("hsqldbDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
#Bean(name = "myJobRepository")
public JobRepository jobRepository(#Qualifier("hsqldbDataSource") DataSource dataSource,
#Qualifier("myTransactionManager") DataSourceTransactionManager dataSourceTransactionManager) throws Exception {
JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean();
factory.setDataSource(dataSource);
factory.setTransactionManager(dataSourceTransactionManager);
factory.setIsolationLevelForCreate("ISOLATION_READ_COMMITTED");
factory.afterPropertiesSet();
return factory.getObject();
}
#Bean(name = "myJobLauncher")
public JobLauncher getJobLauncher(#Qualifier("myJobRepository") JobRepository jobRepository) throws Exception {
SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(jobRepository);
jobLauncher.afterPropertiesSet();
return jobLauncher;
}
Then I run job 0 with the new JobLauncher and this exception occurs on the JobSteps from job3 (3K & 3L) EDIT: I've got a larger log extract to more context of what's happening:
2019-01-09 09:53:39,793 INFO: o.s.b.c.j.SimpleStepHandler [MainTaskExecutor11] Executing step: [3K]
2019-01-09 09:53:39,811 INFO: o.s.b.c.l.s.SimpleJobLauncher [MainTaskExecutor11] Job: [FlowJob: [name=3K]] launched with the following parameters: [{process=Job 3K BAR, pos_cod=BAR, per_event=EVENT, isRet=false, UNIQUE=-2347943936040182027}]
2019-01-09 09:53:39,821 INFO: o.s.b.c.j.SimpleStepHandler [MainTaskExecutor11] Executing step: [[3K] Job 3K]
2019-01-09 09:53:39,822 INFO: e.i.l.d.l.StepListener [MainTaskExecutor11] Executing Step: [3K] Job 3K
2019-01-09 09:53:41,120 INFO: e.i.l.d.l.StepListener [MainTaskExecutor11] Write Count: 0
2019-01-09 09:53:41,166 INFO: o.s.b.c.l.s.SimpleJobLauncher [MainTaskExecutor11] Job: [FlowJob: [name=3K]] completed with the following parameters: [{process=Job 3K BAR, pos_cod=BAR, per_event=EVENT, isRet=false, UNIQUE=-2347943936040182027}] and the following status: [COMPLETED]
2019-01-09 09:53:41,189 INFO: o.s.b.c.j.SimpleStepHandler [MainTaskExecutor11] Duplicate step [3K] detected in execution of job=[job 0]. If either step fails, both will be executed again on restart.
2019-01-09 09:53:41,191 INFO: o.s.b.c.j.SimpleStepHandler [MainTaskExecutor11] Executing step: [3K]
2019-01-09 09:53:41,201 ERROR: o.s.b.c.s.AbstractStep [MainTaskExecutor11] Encountered an error executing step 3K in job 0
org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={process=Job 3K BAR, pos_cod=BAR, per_event=EVENT, isRet=false, UNIQUE=-2347943936040182027}. If you want to run this job again, change the parameters.
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:126) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:172) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at com.sun.proxy.$Proxy111.createJobExecution(Unknown Source) ~[?:?]
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:125) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.step.job.JobStep.doExecute(JobStep.java:117) ~[spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:93) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.core.job.flow.support.state.SplitState$1.call(SplitState.java:90) [spring-batch-core-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]
Please note I use different JobParameters in getJob3() for each execution of job 3K and 3L (the same exception is thrown for that job too). The JobParameters I use are the following: EDIT: I've included a Random function in order to include a unique JobParameter:
Random randomizer = new Random(System.currentTimeMillis());
params1 = new JobParametersBuilder()
.addString(PROCESS, "Job 3K BAR" )
.addString("pos_cod", "BAR")
.addString("per_event", "EVENT")
.addString(IS_RET, FALSE)
.addLong("UNIQUE", randomizer.nextLong())
.toJobParameters();
params2 = new JobParametersBuilder()
.addString(PROCESS, "Job 3K 704" )
.addString("pos_cod", "704")
.addString("per_event", "EVENT")
.addString(IS_RET, FALSE)
.addLong("UNIQUE", randomizer.nextLong())
.toJobParameters();
params3 = new JobParametersBuilder()
.addString(PROCESS, "Job 3L BAR" )
.addString("pos_cod", "BAR")
.addString("per_event", "RET_EVENT")
.addString(IS_RET, FALSE)
.addLong("UNIQUE", randomizer.nextLong())
.toJobParameters();
params4 = new JobParametersBuilder()
.addString(PROCESS, "Job 3L 704" )
.addString("pos_cod", "704")
.addString("per_event", "RET_EVENT")
.addString(IS_RET, FALSE)
.addLong("UNIQUE", randomizer.nextLong())
.toJobParameters();
Having seen the duplicated job instance error keeps occurring as the JobLauncher is trying to launch the samen job (not its sibling with other JobParameters), I'm more inclined to think this is a problem with my JobRepository, but this is nothing more than speculation.
The Map based job repository is not intended for multi-threading. This job repository is by default configured with a ResourcelessTransactionManager.
Make sure to use the JDBC based job repository (even with an in-memory database like in your case) to properly support multi-threading and parallel processing along with a DataSourceTransactionManager.
As a side note, the SimpleDriverDataSource is not a pooled data source, I recommend to use one with a connection pool.

Bigquery - Simba JDBC error with scala anorm

I'm trying to query bigquery from scala (2.11.8) using Simba JDBC Driver (bigquery jdbc 4.2) through anorm (2.5.3) and play framework (2.5.8) on Ubuntu 16.04. This si my code:
class BigQueryController #Inject() (#NamedDatabase("bigquery") db: Database) extends Controller {
case class VixStudioProduct(short_name: String)
def test = Action {
val names: Seq[String] = db.withConnection { implicit connection =>
val query = SQL("SELECT name FROM dataset.table")
query.as(SqlParser.scalar[String].*)
}
Logger.debug(s"products - $names")
Ok
}
}
but I'm getting the following error.
2017-03-02T12:58:44,428-0300 [error] [org.jdbcdslog.ConnectionLogger ] - java.sql.Connection.prepareStatement:
throws exception: java.sql.SQLException: [Simba][BigQueryJDBCDriver](100038) Error getting query result object.
java.sql.SQLException: [Simba][BigQueryJDBCDriver](100038) Error getting query result object.
at com.simba.googlebigquery.client.BQClient.getQueryResults(Unknown Source)
at com.simba.googlebigquery.dataengine.BQDoubleBuffer.getResultsResponse(Unknown Source)
at com.simba.googlebigquery.dataengine.BQDoubleBuffer.<init(Unknown Source)
at com.simba.googlebigquery.dataengine.BQResultSet.<init(Unknown Source)
at com.simba.googlebigquery.dataengine.BQSQLExecutor.<init(Unknown Source)
at com.simba.googlebigquery.dataengine.BQDataEngine.prepare(Unknown Source)
at com.simba.jdbc.common.SPreparedStatement.<init(Unknown Source)
at com.simba.jdbc.jdbc41.S41PreparedStatement.<init(Unknown Source)
at com.simba.jdbc.jdbc42.S42PreparedStatement.<init(Unknown Source)
at com.simba.jdbc.jdbc42.JDBC42ObjectFactory.createPreparedStatement(Unknown Source)
at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:310)
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
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.jdbcdslog.GenericLoggingHandler.invoke(GenericLoggingHandler.java:30)
at com.sun.proxy.$Proxy24.prepareStatement(Unknown Source)
at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:40)
at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:39)
at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:61)
at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:53)
at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
at resource.DefaultManagedResource.open(AbstractManagedResource.scala:110)
at resource.AbstractManagedResource.acquireFor(AbstractManagedResource.scala:87)
at resource.ManagedResourceOperations$$anon$2.acquireFor(ManagedResourceOperations.scala:49)
at resource.DeferredExtractableManagedResource.acquireFor(AbstractManagedResource.scala:27)
at resource.ManagedResourceOperations$class.apply(ManagedResourceOperations.scala:26)
at resource.DeferredExtractableManagedResource.apply(AbstractManagedResource.scala:24)
at resource.ManagedResourceOperations$class.acquireAndGet(ManagedResourceOperations.scala:25)
at resource.DeferredExtractableManagedResource.acquireAndGet(AbstractManagedResource.scala:24)
at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
at scala.util.Try$.apply(Try.scala:192)
at anorm.Sql$.asTry(Anorm.scala:228)
at anorm.WithResult$class.asTry(SqlResult.scala:181)
at anorm.SimpleSql.asTry(SimpleSql.scala:6)
at anorm.WithResult$class.as(SqlResult.scala:173)
at anorm.SimpleSql.as(SimpleSql.scala:6)
at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:26)
at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:24)
at play.api.db.DefaultDatabase.withConnection(Databases.scala:155)
at play.api.db.DefaultDatabase.withConnection(Databases.scala:149)
at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:24)
at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:18)
at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:371)
at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:370)
at play.api.mvc.Action$.invokeBlock(Action.scala:498)
at play.api.mvc.Action$.invokeBlock(Action.scala:495)
at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:458)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:111)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:110)
at scala.Option.map(Option.scala:146)
at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:110)
at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:103)
at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:405)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
Caused by: com.simba.support.exceptions.GeneralException: [Simba][BigQueryJDBCDriver](100038) Error getting query result object.
... 77 common frames omitted
Caused by: java.lang.NullPointerException: Required parameter jobId must be specified.
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229)
at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:140)
at com.google.api.services.bigquery.Bigquery$Jobs$GetQueryResults.<init(Bigquery.java:1248)
at com.google.api.services.bigquery.Bigquery$Jobs.getQueryResults(Bigquery.java:1221)
at com.simba.googlebigquery.client.BQClient.getQueryResults(Unknown Source)
at com.simba.googlebigquery.dataengine.BQDoubleBuffer.getResultsResponse(Unknown Source)
at com.simba.googlebigquery.dataengine.BQDoubleBuffer.<init(Unknown Source)
at com.simba.googlebigquery.dataengine.BQResultSet.<init(Unknown Source)
at com.simba.googlebigquery.dataengine.BQSQLExecutor.<init(Unknown Source)
at com.simba.googlebigquery.dataengine.BQDataEngine.prepare(Unknown Source)
at com.simba.jdbc.common.SPreparedStatement.<init(Unknown Source)
at com.simba.jdbc.jdbc41.S41PreparedStatement.<init(Unknown Source)
at com.simba.jdbc.jdbc42.S42PreparedStatement.<init(Unknown Source)
at com.simba.jdbc.jdbc42.JDBC42ObjectFactory.createPreparedStatement(Unknown Source)
at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
at com.simba.jdbc.common.SConnection.prepareStatement(Unknown Source)
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:310)
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
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.jdbcdslog.GenericLoggingHandler.invoke(GenericLoggingHandler.java:30)
at com.sun.proxy.$Proxy24.prepareStatement(Unknown Source)
at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:40)
at anorm.SimpleSql$$anonfun$2.apply(SimpleSql.scala:39)
at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:61)
at anorm.SimpleSql.unsafeStatement(SimpleSql.scala:53)
at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
at anorm.Sql$$anonfun$preparedStatement$1.apply(Anorm.scala:90)
at resource.DefaultManagedResource.open(AbstractManagedResource.scala:110)
at resource.AbstractManagedResource.acquireFor(AbstractManagedResource.scala:87)
at resource.ManagedResourceOperations$$anon$2.acquireFor(ManagedResourceOperations.scala:49)
at resource.DeferredExtractableManagedResource.acquireFor(AbstractManagedResource.scala:27)
at resource.ManagedResourceOperations$class.apply(ManagedResourceOperations.scala:26)
at resource.DeferredExtractableManagedResource.apply(AbstractManagedResource.scala:24)
at resource.ManagedResourceOperations$class.acquireAndGet(ManagedResourceOperations.scala:25)
at resource.DeferredExtractableManagedResource.acquireAndGet(AbstractManagedResource.scala:24)
at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
at anorm.Sql$$anonfun$asTry$1.apply(Anorm.scala:228)
at scala.util.Try$.apply(Try.scala:192)
at anorm.Sql$.asTry(Anorm.scala:228)
at anorm.WithResult$class.asTry(SqlResult.scala:181)
at anorm.SimpleSql.asTry(SimpleSql.scala:6)
at anorm.WithResult$class.as(SqlResult.scala:173)
at anorm.SimpleSql.as(SimpleSql.scala:6)
at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:26)
at controllers.BigQueryController$$anonfun$asdf$1$$anonfun$1.apply(BigQueryController.scala:24)
at play.api.db.DefaultDatabase.withConnection(Databases.scala:155)
at play.api.db.DefaultDatabase.withConnection(Databases.scala:149)
at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:24)
at controllers.BigQueryController$$anonfun$asdf$1.apply(BigQueryController.scala:18)
at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
at play.api.mvc.ActionBuilder$$anonfun$apply$14.apply(Action.scala:403)
at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:371)
at play.api.mvc.ActionBuilder$$anonfun$apply$13.apply(Action.scala:370)
at play.api.mvc.Action$.invokeBlock(Action.scala:498)
at play.api.mvc.Action$.invokeBlock(Action.scala:495)
at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:458)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:111)
at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:110)
at scala.Option.map(Option.scala:146)
at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:110)
at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:103)
at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:405)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
and this is the log of bigquery in google cloud platform
serviceData: {
#type: "type.googleapis.com/google.cloud.bigquery.logging.v1.AuditData"
jobInsertRequest: {
resource: {
jobName: {
projectId: "zentinel-datawarehouse"
}
jobConfiguration: {
query: {
query: "SELECT id,short_name FROM vix_studio.product "
destinationTable: {…}
createDisposition: "CREATE_IF_NEEDED"
writeDisposition: "WRITE_EMPTY"
defaultDataset: {…}
}
dryRun: true
}
jobStatus: {
state: "PENDING"
error: {…}
}
jobStatistics: {…}
}
}
}
I've found this reported issue https://issuetracker.google.com/issues/35906079
The cause is the same because anorm use prepared statement.
thanks in advance for your help

Is there anything special about configuring the use of multiple buckets in a spring-data-couchbase Java application?

I'm working on a Java-based spring-data-couchbase application that connects to multiple buckets to do its work. We are seeing TimeoutExceptions being thrown when trying to retrieve documents from the buckets with a stack trace like this:
10-17-2016 14:28:10 (WebContainer : 9) ERROR [com.cars.ss.cp.resources.ProfileResource] - [RESOURCE] [ERROR] Service com.sun.proxy.$Proxy195.getConsumerProfileSummaryVersion throws org.springframework.dao.QueryTimeoutException.
org.springframework.dao.QueryTimeoutException: java.util.concurrent.TimeoutException; nested exception is java.lang.RuntimeException: java.util.concurrent.TimeoutException
at org.springframework.data.couchbase.core.CouchbaseExceptionTranslator.translateExceptionIfPossible(CouchbaseExceptionTranslator.java:122)
at org.springframework.data.couchbase.core.CouchbaseTemplate.execute(CouchbaseTemplate.java:500)
at org.springframework.data.couchbase.core.CouchbaseTemplate.exists(CouchbaseTemplate.java:464)
at org.springframework.data.couchbase.repository.support.SimpleCouchbaseRepository.exists(SimpleCouchbaseRepository.java:110)
at sun.reflect.GeneratedMethodAccessor241.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.couchbase.repository.support.ViewPostProcessor$ViewInterceptor.invoke(ViewPostProcessor.java:87)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy148.exists(Unknown Source)
at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy174.exists(Unknown Source)
at com.cars.ss.cp.service.impl.ProfilePhotoService.findByConsumerId(ProfilePhotoService.java:43)
at com.cars.ss.cp.dao.impl.ConsumerAccountDAO.findConsumerAccountByPartyId(ConsumerAccountDAO.java:77)
at sun.reflect.GeneratedMethodAccessor287.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy186.findConsumerAccountByPartyId(Unknown Source)
at com.cars.ss.cp.service.impl.ProfileService.getBOConsumerProfileVersion(ProfileService.java:235)
at com.cars.ss.cp.service.impl.ProfileService.getProfileSummaryByPersonPartyId(ProfileService.java:489)
at com.cars.ss.cp.service.impl.ProfileService.getProfileSummaryByConsumerId(ProfileService.java:479)
at sun.reflect.GeneratedMethodAccessor286.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy195.getProfileSummaryByConsumerId(Unknown Source)
at com.cars.ss.cp.resources.ProfileResource.getSummaryReadByConsumerId(ProfileResource.java:362)
at com.cars.ss.cp.resources.ProfileResource.getConsumerProfileSummaryVersion(ProfileResource.java:320)
at com.cars.ss.cp.resources.ProfileResource.getConsumerProfile(ProfileResource.java:252)
at sun.reflect.GeneratedMethodAccessor261.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63)
...
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1225)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:775)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:457)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1032)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:908)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1815)
Caused by: java.lang.RuntimeException: java.util.concurrent.TimeoutException
at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:75)
at com.couchbase.client.java.CouchbaseBucket.exists(CouchbaseBucket.java:159)
at com.couchbase.client.java.CouchbaseBucket.exists(CouchbaseBucket.java:154)
at org.springframework.data.couchbase.core.CouchbaseTemplate$5.doInBucket(CouchbaseTemplate.java:467)
at org.springframework.data.couchbase.core.CouchbaseTemplate$5.doInBucket(CouchbaseTemplate.java:464)
at org.springframework.data.couchbase.core.CouchbaseTemplate.execute(CouchbaseTemplate.java:497)
... 120 more
Caused by: java.util.concurrent.TimeoutException
... 126 more
I configured my Couchbase configuration class with multiple buckets like this:
#EnableCouchbaseRepositories(basePackages = { "com.cars.ss.cp.nosql.repository" })
#Configuration
public class CouchbaseConfiguration extends AbstractCouchbaseConfiguration {
private static Logger logger = Logger.getLogger(CouchbaseConfiguration.class);
private static final long TIMEOUT_IN_SECONDS = 10;
#Autowired
#Qualifier("propertyService")
private PropertyService propertyService;
#Bean(name = { "defaultBucket" })
public Bucket defaultBucket() throws Exception {
return couchbaseCluster().openBucket(getBucketName());
}
#Override
protected List<String> getBootstrapHosts() {
String rawPropertyValue = this.propertyService.getPropertyValue(COUCHBASE_HOSTS);
if (StringUtils.isNotBlank(rawPropertyValue)) {
StringTokenizer st = new StringTokenizer(rawPropertyValue, ",");
List<String> returnValue = new ArrayList<>(st.countTokens());
while (st.hasMoreTokens()) {
returnValue.add(st.nextToken().trim());
}
return returnValue;
}
logger.error("Unable to process the couchbaseHosts property. Property value: " + rawPropertyValue);
return Collections.emptyList();
}
#Override
protected String getBucketName() {
return this.propertyService.getPropertyValue(COUCHBASE_BUCKET);
}
#Override
protected String getBucketPassword() {
return null;
}
#Override
protected CouchbaseEnvironment getEnvironment() {
return DefaultCouchbaseEnvironment.builder().connectTimeout(TimeUnit.SECONDS.toMillis(TIMEOUT_IN_SECONDS)).kvTimeout(TimeUnit.SECONDS.toMillis(TIMEOUT_IN_SECONDS)).build();
}
#Bean
public Bucket consumerProfileBucket() throws Exception {
return couchbaseCluster().openBucket(this.propertyService.getPropertyValue(CONSUMER_PROFILE_BUCKET), this.propertyService.getPropertyValue(CONSUMER_PROFILE_BUCKET_PASSWORD));
}
#Bean
public CouchbaseTemplate consumerProfileTemplate() throws Exception {
CouchbaseTemplate template = new CouchbaseTemplate(couchbaseClusterInfo(), consumerProfileBucket(), mappingCouchbaseConverter(), translationService());
template.setDefaultConsistency(getDefaultConsistency());
return template;
}
#Override
protected void configureRepositoryOperationsMapping(RepositoryOperationsMapping baseMapping) {
try {
baseMapping.mapEntity(OwnedVehicle.class, consumerProfileTemplate());
baseMapping.mapEntity(ProfilePhoto.class, consumerProfileTemplate());
} catch (Exception e) {
logger.error("Errors encountered during configuration. Exception: " + e);
}
}
}
I originally didn't have the "getEnvironment" method overridden. Based on some recommendations that I saw online, I overrode that method and increased both the connection timeout and key-value timeout to 10 seconds to see if that might help, but it did not. When I increased the timeout from the defaults to 10 seconds, the timeout of the document retrieval became exactly 10 seconds. The TimeoutException is occurring against a document that is trying to be retrieved using the document's key.
The application has the following specifications:
* Java version: 1.7
* spring-data-couchbase version: 2.1.1.RELEASE
* java-client version: 2.2.5
* IBM WebSphere version: 8.5
Is there something obvious that I am missing in the way I have things configured? Are there any other ideas out there of things that I can look at to repair this problem?
10/24/2016 - Added a thread analysis image from the javacore:
thread analysis image from javacore

dao is always null in serviceimpl class

Below is my code. I am using remoting to get reference to the service. once i get the service reference and try to get event.dao call i get a NPE in EventServiceImpl class. When I use xml based config it works but i want it to be annotation based.
EventDao.class
public interface EventDao {
void saveEvent(Event employee);
List<Event> findAllEvents();
void deleteEmployeeBySsn(String ssn);
Event findBySsn(String ssn);
void updateEvent(Event employee);
}
EventImplDao.class
#Repository
public class EventDaoImpl extends AbstractDao implements EventDao{
public void saveEvent(Event employee) {
persist(employee);
}
#SuppressWarnings("unchecked")
public List<Event> findAllEvents() {
Criteria criteria = getSession().createCriteria(Event.class);
return (List<Event>) criteria.list();
}
EventServiceImpl
#Service
#Transactional
public class EventServiceImpl implements EventService{
private EventDao eventDao;
public void setEventDao(EventDao eventDao) {
this.eventDao = eventDao;
}
public void saveEvent(Event employee) {
eventDao.saveEvent(employee);
}
public List<Event> findAllEvents() {
return eventDao.findAllEvents();
}
EventService
#ServiceInterface
public interface EventService {
void saveEvent(Event employee);
List<Event> findAllEvents();
void deleteEmployeeBySsn(String ssn);
Event findBySsn(String ssn);
void updateEvent(Event employee);
}
appconfig
#Configuration
#ComponentScan(basePackages = "com.xxx.spring")
public class AppConfig {
#Bean
public com.xxx.spring.dao.EventDao EventDao() {
return new EventDaoImpl();
}
#Bean
public com.xxxx.spring.service.EventService eventService() {
return new EventServiceImpl();
}
hibernateconfig class
#Configuration
#EnableTransactionManagement
#ComponentScan({ "com.xxxxx.configuration.hib" })
public class HibernateConfiguration {
#Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan(new String[] { "com.xxxxxx.spring.component" });
sessionFactory.setHibernateProperties(hibProperties());
return sessionFactory;
}
#Bean
public DataSource dataSource() {
FileUtils ft = new FileUtils();
ft.getProperties();
DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
driverManagerDataSource.setDriverClassName(ft.getProperties().getProperty("driver"));
driverManagerDataSource.setUrl(ft.getProperties().getProperty("url"));
driverManagerDataSource.setUsername(ft.getProperties().getProperty("username"));
driverManagerDataSource.setPassword(ft.getProperties().getProperty("password"));
return driverManagerDataSource;
}
private Properties hibProperties() {
Properties properties = new Properties();
properties.put(Environment.DIALECT, "org.hibernate.dialect.SQLServer2012Dialect");
properties.put(Environment.SHOW_SQL, false);
return properties;
}
#Bean
#Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(s);
return txManager;
}
}
Stacktrace:
HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
type Exception report
message Request processing failed; nested exception is java.lang.NullPointerException
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
root cause
java.lang.NullPointerException
com.xxxx.spring.service.Impl.EventServiceImpl.findAllEvents(EventServiceImpl.java:28)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy24.findAllEvents(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:78)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy25.findAllEvents(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:212)
org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:39)
org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
org.springframework.remoting.rmi.RmiBasedExporter.invoke(RmiBasedExporter.java:73)
org.springframework.remoting.rmi.RmiInvocationWrapper.invoke(RmiInvocationWrapper.java:74)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
sun.rmi.transport.Transport$1.run(Unknown Source)
sun.rmi.transport.Transport$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
sun.rmi.transport.Transport.serviceCall(Unknown Source)
sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$256(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
org.springframework.remoting.support.RemoteInvocationUtils.fillInClientStackTraceIfPossible(RemoteInvocationUtils.java:45)
org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:353)
org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:260)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy30.findAllEvents(Unknown Source)
com.xxxx.controller.WebController.initiateEventsPage(WebController.java:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.57 logs.
new error now. I think caused becaue eventDaoIml has #Repository attached to it.
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.xxxxx.spring.dao.EventDao com.xxx.spring.service.Impl.EventServiceImpl.eventDao; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.xxxi.spring.dao.EventDao] is defined: expected single matching bean but found 2: eventDaoImpl,EventDao
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 26 more
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [comxxx.i.spring.dao.EventDao] is defined: expected single matching bean but found 2: eventDaoImpl,EventDao
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:970)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 28 more
Try to use annotation in your daowith #Autowired
#Autowired
private EventDao eventDao;

Categories