Grails: SQLException: No suitable driver found for jdbc:oracle:thin - oracle

When I run my app in GGTS 3.6.2 using Grails 2.4.3 I've got a message:
Caused by SQLException: No suitable driver found for jdbc:oracle:thin:#server:port/OCI
->> 689 | getConnection in java.sql.DriverManager
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 247 | getConnection in ''
| 18 | <init> . in awtool.Controller
| 266 | run in java.util.concurrent.FutureTask
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . in java.lang.Thread
Error |
Forked Grails VM exited with errorJava HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
I read many posts about this error and used some recommendations.
I added ojdbc6.jar to project /lib
also I added ojdbc6.jar at project Java Build Path using Add External JAR..
Java and Grails PATHs is OK
Is there is a way how I can resolve this problem ?
BuildConfig.groovy:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
// test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
grails.project.dependency.resolver = "maven" // or ivymaven
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
// mavenRepo "http://repository.codehaus.org"
// mavenRepo "http://download.java.net/maven/2/"
// mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo "http://repo.spring.io/milestone/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
runtime 'mysql:mysql-connector-java:5.1.34'
// runtime "com.oracle:ojdbc6:11.2.0.4"
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.7'
compile ":asset-pipeline:1.9.6"
compile ":spring-security-core:2.0-RC4"
compile ":spring-security-ldap:2.0-RC2"
compile ":force-ssl:1.0.0"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.5.5" // or ":hibernate:3.6.10.17"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
grails.server.port.http=8088
DataSource.groovy
import groovy.sql.*
dataSource {
pooled = true
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
driverClassName = "com.mysql.jdbc.Driver"
username = "login"
password = "pass"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://server:port/login"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://server:port/login"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://server:port/login"
}
}
}

"Add External JAR.." and other ways of adding to the IDE classpath aren't useful when using Grails - the IDEs build their classpaths from the Grails dependencies, so you only need to ensure that Grails has access.
When adding jars to the lib dir (which should be avoided in general, but is needed in this case because Oracle annoyingly refuses to put their driver jars in public repos) you need to run
grails compile --refresh-dependencies
to get it added to the classpath - Grails hasn't had auto-detection of jars in /lib for a while.
Once you do that, if you need the jar for compilation (you don't in this case) then refresh the IDE from Grails. In GGTS/STS you can do this by right-clicking the project root node in the tree on the left and selecting Grails Tools | Refresh Dependencies.

In addition to Burt's answer explaining how to get Grails to find your Oracle library, you need to change DataSource.groovy to connect to an Oracle database (it's currently configured for MySQL). You need to change it to something like:
dataSource {
pooled = true
driverClassName = "oracle.jdbc.driver.OracleDriver"
dialect = "org.hibernate.dialect.Oracle10gDialect"
dbCreate = "update"
url = 'jdbc:oracle:thin:#localhost:1521:mydb'
username = "root"
password = "password"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = false
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "select 1 from dual"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = Connection.TRANSACTION_READ_COMMITTED
}
}
hibernate {
flush.mode = 'manual'
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = "net.sf.ehcache.hibernate.EhCacheRegionFactory"
}
Replace mydb, root, and password with the name of your schema, and the username and password you'll use to access it.

Related

Gradle, how to share a catalog via a settings plugin

Experiment with the new catalog feature from Gradle 7, I'm trying to share a catalog via a settings plugin
Unfortunately documentation is quite short on that:
One option to share a catalog is to write a settings plugin, publish it on the Gradle plugin portal or an internal repository, and let the consumers apply the plugin on their settings file.
I initialized via gradle init for plugin developer using kotlin both as language and build script.
Then I swapped Project for Settings and added a dummy alias on producer
class UpgradedOctoGuacamolePlugin : Plugin<Settings> {
override fun apply(settings: Settings) {
settings.dependencyResolutionManagement {
it.versionCatalogs {
it.create("libs") {
it.alias("groovy-core").to("org.codehaus.groovy:groovy:3.0.5")
}
}
}
}
}
On consumer side settings.gradle.kts
dependencyResolutionManagement {
repositories {
mavenLocal()
mavenCentral()
maven("https://jitpack.io")
}
versionCatalogs {
create("libs") {
from("com.github.elect86:upgraded-octo-guacamole:9f454a68")
}
}
}
But at the sync
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all artifacts for configuration 'incomingPlatformsForLibs'.
> Could not resolve com.github.elect86:upgraded-octo-guacamole:9f454a68.
Required by:
unspecified:unspecified:unspecified
> No matching variant of com.github.elect86:upgraded-octo-guacamole:9f454a68 was found. The consumer was configured to find attribute 'org.gradle.internal.dm.model.builder.id' with value '0', attribute 'org.gradle.category' with value 'platform', attribute 'org.gradle.usage' with value 'version-catalog' but:
- Variant 'apiElements' capability com.github.elect86:upgraded-octo-guacamole:9f454a68:
- Incompatible because this component declares attribute 'org.gradle.category' with value 'library', attribute 'org.gradle.usage' with value 'java-api' and the consumer needed attribute 'org.gradle.category' with value 'platform', attribute 'org.gradle.usage' with value 'version-catalog'
- Other compatible attribute:
- Doesn't say anything about org.gradle.internal.dm.model.builder.id (required '0')
- Variant 'runtimeElements' capability com.github.elect86:upgraded-octo-guacamole:9f454a68:
- Incompatible because this component declares attribute 'org.gradle.category' with value 'library', attribute 'org.gradle.usage' with value 'java-runtime' and the consumer needed attribute 'org.gradle.category' with value 'platform', attribute 'org.gradle.usage' with value 'version-catalog'
- Other compatible attribute:
- Doesn't say anything about org.gradle.internal.dm.model.builder.id (required '0')
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 46ms
category and usage mismatch, "platform" and "version-catalog" required, but only "library" and "java-api" were found
These are my producer variants
19:15:03: Executing task 'outgoingVariants'...
Type-safe dependency accessors is an incubating feature.
> Task :outgoingVariants
--------------------------------------------------
Variant apiElements
--------------------------------------------------
Description = API elements for main.
Capabilities
- com.github.elect86:upgraded-octo-guacamole:0.0.6 (default capability)
Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 11
- org.gradle.libraryelements = jar
- org.gradle.usage = java-api
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
Artifacts
- build/libs/upgraded-octo-guacamole-0.0.6.jar (artifactType = jar)
Secondary variants (*)
- Variant : classes
- Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 11
- org.gradle.libraryelements = classes
- org.gradle.usage = java-api
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
- Artifacts
- build/classes/java/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
--------------------------------------------------
Variant runtimeElements
--------------------------------------------------
Description = Elements of runtime for main.
Capabilities
- com.github.elect86:upgraded-octo-guacamole:0.0.6 (default capability)
Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 11
- org.gradle.libraryelements = jar
- org.gradle.usage = java-runtime
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
Artifacts
- build/libs/upgraded-octo-guacamole-0.0.6.jar (artifactType = jar)
Secondary variants (*)
- Variant : classes
- Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 11
- org.gradle.libraryelements = classes
- org.gradle.usage = java-runtime
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
- Artifacts
- build/classes/java/main (artifactType = java-classes-directory)
- build/classes/kotlin/main (artifactType = java-classes-directory)
- Variant : resources
- Attributes
- org.gradle.category = library
- org.gradle.dependency.bundling = external
- org.gradle.jvm.version = 11
- org.gradle.libraryelements = resources
- org.gradle.usage = java-runtime
- org.jetbrains.kotlin.localToProject = public
- org.jetbrains.kotlin.platform.type = jvm
- Artifacts
- build/resources/main (artifactType = java-resources-directory)
(*) Secondary variants are variants created via the Configuration#getOutgoing(): ConfigurationPublications API which also participate in selection, in addition to the configuration itself.
BUILD SUCCESSFUL in 45ms
1 actionable task: 1 executed
19:15:04: Task execution finished 'outgoingVariants'.
What am I doing wrong?
I don't think I have to modify those attributes myself..
Specs:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-milestone-1-all.zip
It turned out I simply had to literally apply the plugin in the settings.gradle.kts, I didn't know you could do that
apply {
id("guacamole")
}

Exception when Implementing RPC Security Management in corda using spring webserver

Spring Web server not started when we specify RPC Security Management configuration in node.conf file.
Getting error as Unresolved reference: proxy, while running PartyAServer.
Below is my server configuration for PartyA node :-
task runPartyAServer(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'com.example.server.Server'
environment "server.port", "10022"
environment "config.rpc.host", "localhost"
environment "config.rpc.port", "10006"
}
I am able to start the node with following node A configuration, but facing error while running PartyA server.
node {
name "O=PartyA,L=London,C=GB"
advertisedServices = ["com.example"]
p2pPort 10005
rpcPort 10006
cordapps = ["$corda_release_group:corda-finance:$corda_release_version",
"com.example:java-source:$version",
"com.example:base:$version"]
}
Below is my node.conf for PartyA node :-
extraAdvertisedServiceIds=[
"com.example"
]
myLegalName="O=PartyA,L=London,C=GB"
networkMapService {
address="localhost:10002"
legalName="O=Controller,L=London,C=GB"
}
p2pAddress="localhost:10005"
rpcAddress="localhost:10006"
rpcUsers=[]
security = {
authService = {
dataSource = {
type = "DB",
passwordEncryption = "SHIRO_1_CRYPT",
connection = {
jdbcUrl = "jdbc:oracle:thin:#172.16.105.21:1521:SFMS"
username = "abinay"
password = "abinay"
driverClassName = "oracle.jdbc.OracleDriver"
}
}
options = {
cache = {
expireAfterSecs = 120
maxEntries = 10000
}
}
}
}
Without having username and password how nodeRPCConnection(proxy) will be established with following code,
#PostConstruct
public void initialiseNodeRPCConnection() {
NetworkHostAndPort rpcAddress = new NetworkHostAndPort(host,rpcPort);
CordaRPCClient rpcClient = new CordaRPCClient(rpcAddress);
rpcConnection = rpcClient.start(username, password);
proxy = rpcConnection.getProxy();
staticMap.put("proxy",proxy);
}
This strikes me as more likely to be an oracle connection issue.
I'd start by writing some java code just to ensure that you can connect to the oracle DB, and then focus on getting that to work in the cordapp environment.
There's a good developer example on this (in both java and kotlin: https://github.com/corda/samples-java/tree/master/Basic/flow-database-access ; https://github.com/corda/samples-kotlin/tree/master/Basic/flow-database-access)
Best of luck on this!

geb.Browser is trying to use FirefoxDriver instead of PhatomJSDriver

For some reason, my code tries to use the firefox browser when it should be using phantomjs.
My groovy code looks like this:
import geb.Browser
...
env = System.getenv()
def username = env.username
def password = env.password
def gateway = env.gateway
def matcher = gateway =~ /^(https?:\/\/)([^:^\/]*)(:\d*)?(.*)?.*$/
def host = matcher[0][2]
def port = matcher[0][3]
if (env.driver == 'firefox') {
driver = new FirefoxDriver()
} else {
println env.phantomjspath
def caps = DesiredCapabilities.phantomjs()
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, env.phantomjspath
)
driver = new PhantomJSDriver(caps)
driver.manage().window().setSize(new Dimension(1028, 768))
}
def browser = new Browser(driver: driver)
BiHome = "https://" + username + ":" + password + "#" + host + port + "/gateway/default/BigInsightsWeb/#/welcome"
browser.drive {
go BiHome
// code omitted for brevity
}
browser.close()
Unfortunately, for some reason geb.Browser is trying to use the FirefoxDriver:
:CheckHomePhantomJS
/Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/build/webdriver/phantomjs/bin/phantomjs
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: /Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/build/webdriver/phantomjs/bin/phantomjs
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 19084
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=19084, --webdriver-logfile=/Users/snowch/Repos/biginsight-examples2/examples/BiginsightsHome/phantomjsdriver.log]
May 10, 2016 10:13:57 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
PhantomJS is launching GhostDriver...
[INFO - 2016-05-10T09:13:58.925Z] GhostDriver - Main - running on port 19084
[INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
[INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - page.customHeaders: - {}
[INFO - 2016-05-10T09:13:59.117Z] Session [8784a390-168f-11e6-bcd7-a7a5f8e205b1] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"mac-unknown-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2016-05-10T09:13:59.117Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 8784a390-168f-11e6-bcd7-a7a5f8e205b1
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: MAC
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'xxxxxxx', ip: 'xxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: 'xxxxx', java.version: '1.8.0_66'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:75)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
....
My build.gradle:
import org.apache.tools.ant.taskdefs.condition.Os
// set the dependencies for running the groovy script
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.codehaus.groovy:groovy-all:latest.release'
}
}
plugins {
id 'groovy'
}
apply from: "osSpecificDownloads.gradle"
// set the dependencies for compiling the groovy script
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:latest.release'
compile 'org.codehaus.geb:geb-core:latest.release'
compile 'org.seleniumhq.selenium:selenium-firefox-driver:2.53.0'
compile('com.codeborne:phantomjsdriver:1.3.0') {
transitive = false
}
}
// tell gradle the groovy script is in the same folder as the build.gradle file
sourceSets {
main {
groovy {
srcDirs = ['.']
}
}
}
Properties props = new Properties()
props.load(new FileInputStream("$projectDir/../../connection.properties"))
task("CheckHomePhantomJS", type: JavaExec) {
dependsOn unzipPhantomJs
def phantomJsFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "phantomjs.exe" : "bin/phantomjs"
environment 'phantomjspath', new File(unzipPhantomJs.outputs.files.singleFile, phantomJsFilename).absolutePath
environment 'driver', 'phantomjs'
environment 'gateway', props.gateway
environment 'username', props.username
environment 'password', props.password
main = 'CheckHome'
classpath = sourceSets.main.runtimeClasspath
}
Any idea what is going wrong here?
Geb creates a new Browser instance when you call.
Browser drive(Closure script)
Instead try with
Browser drive(Browser browser, Closure script)
So change your code to
Browser.drive(browser) {
go BiHome
// code omitted for brevity
}

multiple times triggering of Datasource.groovy in grails application ( throwing exception when called second time)

Work Around for creating the application :
creating a Grails Application using Postgres database.
Needs to create Database when the application is executed (i.e database is to be created from the project itself instead of creating the database manually).
For creating the database I am calling a groovy service CreateDatabaseService in datasource.groovy as follows :
import demo.grails.CreateDatabaseService
CreateDatabaseService.serviceMethod()
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.postgresql.Driver"
dialect = "org.hibernate.dialect.PostgreSQLDialect"
username = "postgres"
password = "password"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:postgresql://localhost:5432/SampleAppDb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql://localhost:5432/SampleAppDb"
}
} .....
Full code for CreateDatabaseService :
package demo.grails
import groovy.sql.Sql
import java.sql.DriverManager
import java.sql.Connection
import java.sql.SQLException
import java.sql.*
class CreateDatabaseService {
public static flag =0
def static serviceMethod() {
Connection conn = null;
Statement stmt = null;
try{
if(flag == 0) {
//STEP 2: Register JDBC driver
Class.forName("org.postgresql.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432", "postgres", "password");
//STEP 4: Execute a query
System.out.println("Creating database...");
stmt = conn.createStatement();
String isDatabase = "select datname from pg_catalog.pg_database where lower(datname) = lower('SampleAppDb')"
ResultSet rs = stmt.executeQuery(isDatabase);
String idr
while(rs.next()){
//Retrieve by column name
idr = rs.getString("datname");
}
if(!idr.equals("SampleAppDb")) {
String sql = "create database SampleAppDb";
stmt.executeUpdate(sql);
System.out.println("Database created successfully...");
flag =1
}
else {
flag =1
}
}
}catch(Exception e){
e.printStackTrace();
}
finally{
stmt.close();
conn.close();
}
}
}
On running the grails app following is the full stack trace that shows datasource.groovy is called multiple times, though the database is created from the application but complains about no suitable driver found when datasource.groovy is called second time.
|Loading Grails 2.4.5
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
................Connecting to database...
Creating database...
Database created successfully...
....................
|Running Grails application
Connecting to database...
Error |
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432
Error |
at java.sql.DriverManager.getConnection(DriverManager.java:689)
Error |
at java.sql.DriverManager.getConnection(DriverManager.java:247)
Error |
at java_sql_DriverManager$getConnection.call(Unknown Source)
Error |
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
Error |
at demo.grails.CreateDatabaseService.serviceMethod(CreateDatabaseService.groovy:23)
Error |
at demo.grails.CreateDatabaseService$serviceMethod.call(Unknown Source)
Error |.......
Please suggest how to overcome this error.
BuildConfig.groovy
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
runtime 'postgresql:postgresql:9.0-801.jdbc4'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55.2" // or ":tomcat:8.0.20"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:2.1.5"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.8.1" // or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
Validate that you have the following configuration in your BuildConfig
dependencies {
...
compile 'org.grails.plugins:hibernate:4.3.10.4'
provided 'org.postgresql:postgresql:9.4-1203-jdbc4'
...
}

What version(s) of adjacent tools is(are) compatible with Spring XD?

Spring XD interacts with the following backing components:
Zookeeper
JDBC Datastore (MySql, Postgres, etc...)
RabbitMQ, Redis, or Kafka (Transport)
Redis (Analytics)
Is there any documentation on which versions of these technologies should be used when running Spring XD in Distributed Mode?
Presumably when new versions of Spring XD are released, the compatible versions of the adjacent technologies may change. Is this documented anywhere?
I found a dependency list in the build.gradle file in GitHub. This is from the master:
ext {
xdAdminUIVersion = '1.2.0.RELEASE'
// Not in IO
activemqVersion = '5.6.0'
apacheFtpServerVersion = '1.0.6'
args4jVersion = '2.0.16'
curatorVersion = '2.6.0'
equalsverifierVersion = '1.1.3'
ftpServerVersion = '1.0.6'
apacheSshdVersion = '0.10.1'
greenmailVersion = '1.3.1b'
httpClientVersion = '4.2.5'
jcloudsVersion = '1.7.0'
oracleToolsVersion = '1.2.2'
platformVersion = '1.0.1.RELEASE'
postgresqlVersion = '9.4-1201-jdbc41'
splunkVersion = '1.3.0'
springBatchAdminMgrVersion = '1.3.0.RELEASE'
springIntegrationSplunkVersion = '1.1.0.RELEASE'
springIntegrationKafkaVersion = '1.2.1.RELEASE'
kafkaVersion = '0.8.2.1'
springShellVersion = '1.1.0.RELEASE'
zookeeperVersion = '3.4.6'
sparkVersion = '1.2.1'
sparkScalaVersion = '2.10'
sqoopVersion = '1.4.5'
// Also in IO
nettyVersion = '3.7.0.Final' // N.B. Reactor depends on Netty 4
hadoopGuavaVersion = '11.0.2' // This is only used by the mini cluster in the spring-xd-batch-extension tests
cdh5GuavaVersion = '14.0.1' // This is only used by the CDH 5 module for the xd/lib/cdh5 classpath jars
oldGuavaVersion = '15.0' // This is only used by spring-xd-integration-test, IO uses version 17.0
guavaVersion = '16.0.1'
springDataHadoopBase = '2.2.0.RELEASE'
// //Reactor 1.1 is used in spring-xd-extension-batch transitively though spring integration
// reactor11xVersion = '1.1.5.RELEASE'
singleNodeServerProcess = new SingleNodeServerProcess()
}

Resources