Java "InvalidAlgorithmParameterException"? - java

Currently i am using web3j to create an account in my private block chain.
Like:
Web3j web3 = Web3j.build(new HttpService());
Web3ClientVersion web3ClientVersion;
String walletFileName = WalletUtils.generateFullNewWalletFile("password",new File("/opt/test"));
LOGGER.info("walletFileName>>>>>" + walletFileName.substring(0));
This code works fine in my local machine.But i am getting this exception in my test server:
java.security.InvalidAlgorithmParameterException: parameter object not a ECParameterSpec
at org.bouncycastle.jce.provider.JDKKeyPairGenerator$EC.initialize(Unknown Source)
at org.web3j.crypto.Keys.createSecp256k1KeyPair(Keys.java:49)
at org.web3j.crypto.Keys.createEcKeyPair(Keys.java:55)
at org.web3j.crypto.WalletUtils.generateNewWalletFile(WalletUtils.java:44)
at org.web3j.crypto.WalletUtils.generateFullNewWalletFile(WalletUtils.java:29)
at com.belrium.service.UserWalletService.createNewWallet(UserWalletService.java:91)
at com.belrium.service.UserAuthenticationService.verifyEmailAddress(UserAuthenticationService.java:126)
at com.belrium.controller.UserAuthenticationController.verifyEmailAddress(UserAuthenticationController.java:68)
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.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
I have searched a lot and tried all things but not able to resolve it.Please help.

This error is typically related to your current JDK/ceritificate/configurations installations :
Solution : RE-install the JDK/configurations on your test server.
Other possible Issue :
If you have any SSL certificate on your test server ? please refer to below URL to understand the issue :
Please go through http://iwang.github.io/support/2014/03/14/cxf-cause-https-error.html

I was using this maven plugin
<!-- flying saucer pdf -->
<!-- <dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.4</version>
</dependency> -->
for creating pdf. By removing this plugin from my pom.xml my issue is ressolved.But why it was creating that exception not know.

Related

Updating NewRelic version throwing AbstractMethodError at runtime

I am updating the newrelic version from 2.x.x to 5.x.x in a project. I followed steps as mentioned in the newrelic docs (I updated the dependency version in pom file, updated the agent jar file and the config file).
But now on running project passing the required javaagent:
java -server -javaagent:/Users/amit.upadhyay/abcproject/abcproject-app/newrelic-stage/newrelic.jar -jar abcproject-app/target/abcproject-app-*.*.*-SNAPSHOT.jar /Users/amit.upadhyay/Downloads/abcproject.yml
I get java.lang.AbstractMethodError. Below is the error log:
ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://xml.org/sax/features/external-general-entities to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl#e320068: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:205) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:420) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231) at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243) at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getContext(LogManager.java:174) at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648) at com.newrelic.agent.logging.Log4jLogger.<init>(Log4jLogger.java:68) at com.newrelic.agent.logging.Log4jLogger.create(Log4jLogger.java:415) at com.newrelic.agent.logging.Log4jLogManager.createRootLogger(Log4jLogManager.java:38) at com.newrelic.agent.logging.Log4jLogManager.initializeRootLogger(Log4jLogManager.java:98) at com.newrelic.agent.logging.Log4jLogManager.<init>(Log4jLogManager.java:34) at com.newrelic.agent.logging.Log4jLogManager.create(Log4jLogManager.java:254) at com.newrelic.agent.logging.AgentLogManager.createAgentLogManager(AgentLogManager.java:19) at com.newrelic.agent.logging.AgentLogManager.<clinit>(AgentLogManager.java:9) at com.newrelic.agent.Agent.<clinit>(Agent.java:59) 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 com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179) at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81) 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 sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://xml.org/sax/features/external-parameter-entities to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl#e320068: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:206) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:420) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231) at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243) at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getContext(LogManager.java:174) at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648) at com.newrelic.agent.logging.Log4jLogger.<init>(Log4jLogger.java:68) at com.newrelic.agent.logging.Log4jLogger.create(Log4jLogger.java:415) at com.newrelic.agent.logging.Log4jLogManager.createRootLogger(Log4jLogManager.java:38) at com.newrelic.agent.logging.Log4jLogManager.initializeRootLogger(Log4jLogManager.java:98) at com.newrelic.agent.logging.Log4jLogManager.<init>(Log4jLogManager.java:34) at com.newrelic.agent.logging.Log4jLogManager.create(Log4jLogManager.java:254) at com.newrelic.agent.logging.AgentLogManager.createAgentLogManager(AgentLogManager.java:19) at com.newrelic.agent.logging.AgentLogManager.<clinit>(AgentLogManager.java:9) at com.newrelic.agent.Agent.<clinit>(Agent.java:59) 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 com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179) at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81) 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 sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) ERROR StatusLogger Caught java.lang.AbstractMethodError setting feature http://apache.org/xml/features/nonvalidating/load-external-dtd to false on DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl#e320068: java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:207) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:420) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:347) at com.newrelic.agent.deps.org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637) at com.newrelic.agent.deps.org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231) at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243) at com.newrelic.agent.deps.org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getContext(LogManager.java:174) at com.newrelic.agent.deps.org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648) at com.newrelic.agent.logging.Log4jLogger.<init>(Log4jLogger.java:68) at com.newrelic.agent.logging.Log4jLogger.create(Log4jLogger.java:415) at com.newrelic.agent.logging.Log4jLogManager.createRootLogger(Log4jLogManager.java:38) at com.newrelic.agent.logging.Log4jLogManager.initializeRootLogger(Log4jLogManager.java:98) at com.newrelic.agent.logging.Log4jLogManager.<init>(Log4jLogManager.java:34) at com.newrelic.agent.logging.Log4jLogManager.create(Log4jLogManager.java:254) at com.newrelic.agent.logging.AgentLogManager.createAgentLogManager(AgentLogManager.java:19) at com.newrelic.agent.logging.AgentLogManager.<clinit>(AgentLogManager.java:9) at com.newrelic.agent.Agent.<clinit>(Agent.java:59) 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 com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179) at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81) 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 sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386) at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) Mar 16, 2020 01:40:38 +0530 [8698 1] com.newrelic INFO: Configuration file not found. The agent will attempt to read required values from environment variables. Mar 16, 2020 01:40:38 +0530 [8698 1] com.newrelic INFO: Using default collector host: collector.newrelic.com Mar 16, 2020 01:40:38 +0530 [8698 1] com.newrelic ERROR: Unable to start the New Relic Agent. Your application will continue to run but it will not be monitored. com.newrelic.agent.config.ConfigurationException: The agent requires an application name. Check the app_name setting in newrelic.yml at com.newrelic.agent.config.ConfigServiceFactory.validateConfig(ConfigServiceFactory.java:64) at com.newrelic.agent.config.ConfigServiceFactory.createConfigService(ConfigServiceFactory.java:27)
Since I am encountering AbstractMethodError at runtime i.e. somewhere I am using an old interface that is updated in the new versions of newrelic java agent 5.x.x.
The error logs suggested that there is a conflict between xerces version being used in my project and what is there in the updated newrelic javaagent. On googling I found these two SO links first and second with similar kinda issue. According to answers given, I added
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
to my pom file and this AbstractMethodError error was gone.
But then on running again I started getting this exception: com.newrelic.agent.config.ConfigurationException
The logs for this exception is:
Mar 16, 2020 02:37:18 +0530 [9598 1] com.newrelic INFO: Configuration file not found. The agent will attempt to read required values from environment variables.
Mar 16, 2020 02:37:18 +0530 [9598 1] com.newrelic INFO: Using default collector host: collector.newrelic.com
Mar 16, 2020 02:37:18 +0530 [9598 1] com.newrelic ERROR: Unable to start the New Relic Agent. Your application will continue to run but it will not be monitored.
com.newrelic.agent.config.ConfigurationException: The agent requires an application name. Check the app_name setting in newrelic.yml
at com.newrelic.agent.config.ConfigServiceFactory.validateConfig(ConfigServiceFactory.java:64) ~
at com.newrelic.agent.config.ConfigServiceFactory.createConfigService(ConfigServiceFactory.java:27) ~
at com.newrelic.agent.service.ServiceManagerImpl.<init>(ServiceManagerImpl.java:126) ~
at com.newrelic.agent.Agent.premain(Agent.java:279)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
at com.newrelic.bootstrap.BootstrapAgent.startAgent(BootstrapAgent.java:179)
at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386) [?:1.8.0_222]
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401) [?:1.8.0_222]
Now, I don't understand why is this throwing ConfigurationException (or why is it not able to find the configuration file). The same java command (with exactly the same path of agent jar and configuration file) when used with an older version of newrelic agent(2.x.x or 3.x.x) runs perfectly.
I wanted to understand what is going wrong/missing here?
I was able to update to the latest newrelic version in my project. It seems that they have updated the xerces version in their java agent where version is greater than 5.0.0. Along with the fix of updating xerces version, I needed to pass the newrelic config file explicitly as system properties to resolve the ConfigurationException.
Overall summary:
- update these libraries to
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
And pass the newrelic config file as system property:
-Dnewrelic.config.file=./${NEW_RELIC_DIR_NAME}/newrelic.yml

Unable to connect to S3 using spark-redshift library in java

I am trying to create a table in Redshift based on the spark dataset. I am using spark-redshift driver in jdbc to achieve this locally.
The code snippet to do this
data.write()
.format("com.databricks.spark.redshift")
.option("url", "jdbc:redshift://..")
.option("dbtable", "test_table")
.option("tempdir", "s3://temp")
.option("aws_iam_role", "arn:aws:iam::..")
.option("extracopyoptions", "region 'us-west-1'")
.mode(SaveMode.Append).save();
My maven pom.xml has following dependency:
<dependency>
<groupId>com.databricks</groupId>
<artifactId>spark-redshift_2.11</artifactId>
<version>2.0.1</version>
</dependency>
I am using java 1.8.
I am getting the following error:
java.io.IOException: No FileSystem for scheme: s3
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2660)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)
at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)
at com.databricks.spark.redshift.Utils$.assertThatFileSystemIsNotS3BlockFileSystem(Utils.scala:156)
at com.databricks.spark.redshift.RedshiftWriter.saveToRedshift(RedshiftWriter.scala:340)
at com.databricks.spark.redshift.DefaultSource.createRelation(DefaultSource.scala:106)
at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:45)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:86)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:127)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:155)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:152)
at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:127)
at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:80)
at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:80)
at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:668)
at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:668)
at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78)
at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125)
at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73)
at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:668)
at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:276)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:270)
at com.peak.spark.jobs.SparkDataIngestJob.writeData(SparkDataIngestJob.java:196)
at com.peak.spark.jobs.SparkDataIngestJob.exec(SparkDataIngestJob.java:123)
at com.peak.spark.core.AbstractSparkJob.run(AbstractSparkJob.java:74)
at com.peak.spark.core.SparkAppLauncher.onApplicationEvent(SparkAppLauncher.java:40)
at com.peak.spark.core.SparkAppLauncher.onApplicationEvent(SparkAppLauncher.java:16)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
at org.springframework.context.support.AbstractApplicationContext.start(AbstractApplicationContext.java:1174)
at com.peak.spark.core.SparkApp.launch(SparkApp.java:38)
at com.peak.spark.core.SparkApp.main(SparkApp.java:55)
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.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:849)
at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:167)
at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:195)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:924)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:933)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Exception in thread "main" java.lang.RuntimeException: Spark Job FailedNo FileSystem for scheme: s3
at com.peak.spark.jobs.SparkDataIngestJob.exec(SparkDataIngestJob.java:162)
at com.peak.spark.core.AbstractSparkJob.run(AbstractSparkJob.java:74)
at com.peak.spark.core.SparkAppLauncher.onApplicationEvent(SparkAppLauncher.java:40)
at com.peak.spark.core.SparkAppLauncher.onApplicationEvent(SparkAppLauncher.java:16)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
at org.springframework.context.support.AbstractApplicationContext.start(AbstractApplicationContext.java:1174)
at com.peak.spark.core.SparkApp.launch(SparkApp.java:38)
at com.peak.spark.core.SparkApp.main(SparkApp.java:55)
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.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:849)
at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:167)
at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:195)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:924)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:933)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Please help me figure out what's wrong here.
I suppose you forget to include hadoop-aws package to your project. This package will allow you to work with s3:// schema
<!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-aws -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-aws</artifactId>
<version>2.6.0</version>
</dependency>
Since you are trying to execute this code on your local system, your code won't know how to access s3 file system.
You can do one of the two things to solve this problem:
Configure AWS credentials in your system so that your code will somehow try to reach s3 bucket. I will not recommend this approach for various reasons.
Keep your file path in configuration file. Use 2 configuration files - one for testing code and other for production environment. In test environment, use paths like c:\path\to\your\dummy\folder\ and in production environment configuration file use paths like s3:\your_bucket_name\path\in\bucket.
Hope it helps.

Issue with takari lifecycle maven plugin downloading maven versions

Having an issue running the takari maven plugin to test my custom maven plugin.
For each version I specify, I get an error like this (with only the version changing):
java.lang.Exception: Could not resolve maven version 3.5.0
at io.takari.maven.testing.executor.junit.MavenJUnitTestRunner$1.error(MavenJUnitTestRunner.java:129)
at io.takari.maven.testing.executor.junit.MavenVersionResolver.resolve(MavenVersionResolver.java:63)
at io.takari.maven.testing.executor.junit.MavenJUnitTestRunner.getRunners(MavenJUnitTestRunner.java:131)
at io.takari.maven.testing.executor.junit.MavenJUnitTestRunner.<init>(MavenJUnitTestRunner.java:89)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:250)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.io.FileNotFoundException: Could not download maven version 3.5.0 from any configured repository
at io.takari.maven.testing.executor.junit.MavenVersionResolver.createMavenInstallation(MavenVersionResolver.java:178)
at io.takari.maven.testing.executor.junit.MavenVersionResolver.resolve(MavenVersionResolver.java:61)
... 24 more
Caused by: java.io.IOException: HTTP/401 Unauthorized
at io.takari.maven.testing.executor.junit.MavenVersionResolver.openStream(MavenVersionResolver.java:207)
at io.takari.maven.testing.executor.junit.MavenVersionResolver.createMavenInstallation(MavenVersionResolver.java:161)
... 25 more
I feel like I have to be missing something. I haven't seen anything in the takari-lifecycle-plugin docs on configuring credentials for downloading the jars - anyone have suggestions? Note we're using a custom artifactory maven repo in our settings.xml if that makes a difference.
EDIT: Answers that don't deal specifically with configuring the takari plugin aren't really helpful, I know what a HTTP 401 is
error HTTP/401 Unauthorized is occur because the request has not been applied because it lacks valid authentication credentials for the target resource. and you are using custom artifactory maven so you are specify the repository url, you need to check there url and also use proper authentication credentials with it. check your settings.xml and pom.xml

Spring Boot JSP

Is there any simple way to generate Spring Boot Mvc project for .jsp views?
I've tried to create project in similar way like Spring Boot Rest project, but it's not soo easy for me. I've tried to use official Spring Boot Mvc jsp sample, but when I try to run this I get exception like this:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [sample.jsp.SampleWebJspApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.context.web.SpringBootServletInitializer
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1182) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1171) [spring-boot-1.4.0.BUILD-20160427.203128-289.jar:1.4.0.BUILD-SNAPSHOT]
at sample.jsp.SampleWebJspApplication.main(SampleWebJspApplication.java:33) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.context.web.SpringBootServletInitializer
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:300) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173) ~[spring-context-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_65]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_65]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_65]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.0.BUILD-20160427.201731-353.jar:4.3.0.BUILD-SNAPSHOT]
... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_65]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_65]
... 25 common frames omitted
This blog post explains what steps you should take and why. Its fairly easy and I've fixed it myself.
TD:LR
Add Maven Dependencies
In order to enable JSP support, we need to add a few dependencies to our new project in pom.xml.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Place the JSP templates under src/main/resources/META-INF/resources/WEB-INF/jsp/
As I know, the spring boot default page technology is thymeleaf and the official recommends us to use it.
If you want to use jsp, you could do some configuration.
The following steps may be useful.
1. Creating src/main/webapp/WEB-INF/jsp folder.
2. Modify application.properties file.
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
3.Add jar support for jsp. You could add the followings maven repository to your project pom.xml file.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Hope it helps. Any concerns, please feel free to let me know.
Add below dependencies to your POM file:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Create below structure
/src/main/resources/META-INF/resources
Now the above folder is equivalent to your WebContent folder. Inside this you can put your static contents. Add WEB-INF folder here and now you can place your JSP files like any other web project.
In your application.properties file add below:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
Any chance you're running in IntelliJ? I've noticed this issue as well and the solution is to remove the <scope>provided</scope> from the spring-boot-starter-tomcat dependency, like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!-- <scope>provided</scope> -->
</dependency>
There's a bug in IntelliJ, causing it not to add provided dependencies to the classpath when running locally.
EDIT: Removing the provided scope might cause issues when you're going to run it within a servlet container, so be cautious about that, an explanation about how to fix that could be found in Run Spring-boot's main using IDE.
I have had similar problems, see the link to github.
jsf-spring-boot-2.1.6 parent use spring boot 1.4.0
everything has worked and there is no problems, believe it or not!
https://github.com/joinfaces/joinfaces-example-war
Adding dependency in POM file below
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
Full code avaliable on github link click here
Download the code and import the eclipse/STS using exiting maven project
Next to run the project.
Go to the package on com.chandrakumar.test.demo.
it has "DemoApplication.java" and right click the mouse and select run as
choose the java application.
The browser address bar type "http://localhost:8080/".
Following johnny's reply, I actually wasn't aware that JSP files could be ran while deploying the application as a JAR. Though apparently there are some extensions that I haven't heard of... Typically, a JSP application is deployed as a WAR, and all JSP-related files are located in the webapp/WEB-INF/ folder. You may need to add <packaging>war</packaging> to your POM if if you are comfortable packaging your application as a WAR. This doesn't sound like a bad idea if your application is not a microservice or does not utilize cloud-based technologies. But the majority of cloud-based technologies (excluding cloud-foundry and maybe some others) only support JAR packaging. In that case, you may want to use alternative templates such as Thymeleaf or FreeMarker, over JSP, if you decide to go the JAR route.
Use a maven run configuration with spring-boot:run as the "Command line" value.

DBunit generates java.lang.ClassCastException: java.lang.String cannot be cast to oracle.sql.CLOB when trying to load a CLOB field

I am using the latest version of DBUnit (2.4.7), on Oracle 11GR2. I'm using Java 6 (1.6.0_15) and the latest version of Oracle's client jar (jdbc6.jar)
I've been unable to successfully load any data referenced by a CLOB Oracle field from an XML file into the database.
I've used all sorts of combinations of versions of the:
Oracle JDBC library ojdbc5.jar, ojdbc6.jar, oracle 10 jars
Hibernate library etc... I think the problem lies in DBUnit. See below for stack trace.
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.0-CR-2</version>
and
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
I'm running Java 6, 1.6.0_15.
I've tried:
1) FlatXmlDataSet using this definition
<MESSAGE msg_id="1" mtp_id="1" msg_detail="asadds" />
2) XmlDataSet using this definition
<table name="MESSAGE">
<column>MSG_ID</column>
<column>MTP_ID</column>
<column>MSG_DETAIL</column>
<row>
<value>1</value>
<value>1</value>
<value>dsad</value>
</row>
</table>
Any help would be much appreciated!
Stack trace follows:
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:980)
ERROR [10032010 14:15:13,031] - exception creating EntityManager: [] (MessageDAOTest.java:97)
java.lang.RuntimeException: Exception in JpaDBTestCase
at com.ert.commons.junit4.hibernate.JpaDBTestCase.loadDbunitFiles(JpaDBTestCase.java:97)
at com.ert.ertmon.dao.ejb.impl.MessageDAOTest.setUpBeforeClass(MessageDAOTest.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:334)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:980)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to oracle.sql.CLOB
at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7898)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7511)
at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:7984)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:237)
at org.dbunit.dataset.datatype.ClobDataType.setSqlValue(ClobDataType.java:71)
at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73)
at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186)
at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:190)
at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
at com.ert.commons.junit4.hibernate.JpaDBTestCase.loadDbunitFile(JpaDBTestCase.java:136)
at com.ert.commons.junit4.hibernate.JpaDBTestCase.loadDbunitFiles(JpaDBTestCase.java:92)
... 21 more
Use
org.dbunit.ext.oracle.Oracle10DataTypeFactory
in datafactory config.
This looks like Bug ID 1984596 and I don't really understand the status (it is closed but... I don't get if the issue has been fixed). Could you try with DbUnit 2.2.1 as suggested in the issue (it seems that a change introduced in version 2.2.2 is causing the problem). If this works, you should definitely reopen the issue.
I also encountered this problem the other day using Ant and DBUnit. I'm using Ant version 1.7.1, DBUnit 2.4.5., with Oracle 10g. The 'work around' I found was to specify the database dialect in the Ant Task:
<dbunit driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin#127.0.0.1:1521:MyOracleDb" userid="[userid]" password="[password]" schema="[MySchema]">
<dbconfig>
<property name="datatypeFactory" value="org.dbunit.ext.oracle.OracleDataTypeFactory"/>
</dbconfig>
<operation type="CLEAN_INSERT" src="MY_DATA.xml" />
</dbunit>
Once I added the dbconfig property, the String / CLOB cast issue was gone. Hope this helps anyone that has seen this error with Ant.

Categories