when deploying grails app to cloudfoundry, if define multi-datasource ,there are error:
Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'n/a'
dataSource {
dialect = "org.hibernate.dialect.MySQLInnoDBDialect"
driverClassName = 'com.mysql.jdbc.Driver'
username = 'n/a'
password = 'n/a'
url = 'n/a'
dbCreate = 'update'
}
dataSource_postgre {
dialect = "org.hibernate.dialect.PostgresPlusDialect"
driverClassName = "org.postgresql.Driver"
username = 'n/a'
password = 'n/a'
url = "n/a"
dbCreate = 'update'
}
but as i known from http://blog.springsource.com/2011/04/12/one-step-deployment-with-grails-and-cloud-foundry/ as following:
When you bind a service to an application in Cloud Foundry, you are telling the cloud to pass the connection settings for that service to the application at runtime. The Cloud Foundry plugin then picks up that information and overrides the connection settings in your application. As if by magic, your application then transparently works against the cloud service without you having done anything! And this works for all available services, not just MySQL
CloudFoundry will reconfigure the data source and replace your local DataSource definition. The way you notify CloudFoundry about the services you need is interacting with CF with vmc Tunneling with Caldecott command or Cloud Foundry Integration for STS.
Check the logs of the application using VMC if possible, in the staging.log, you should see a summary of the services that have been auto-configured.
I would have to check if this is possible with two services, you may have to configure one manually using the VCAP_SERVICES environment variable.
Related
I am creating a Spring Boot App with Mongo DB and scratching my head a bit with how to set up the production database configuration.
With a SQL-based Database, I'd be used to setting up a data source bean like this
#Bean
public DataSource getDataSource()
{
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.driverClassName("org.h2.Driver");
dataSourceBuilder.url("jdbc:h2:file:C:/temp/test");
dataSourceBuilder.username("sa");
dataSourceBuilder.password("");
return dataSourceBuilder.build();
}
However,
It doesn't seem to be needed - my local app connects to a spun up instance of mongo db without any explicit configuration.
It doesn't seem to be a standard with mongo according to [this post][1]
I figured I'd give it a go to see if it would automagically configure in production, but I'm getting a DataAccessResourceFailureException. Info: heroku, did the mLab MongoDB add on.
I have no problem getting the url and I can certainly throw that in an environment variable, but I'm just not sure what I need to add to my app to configure it.
Set values in application.properties file like below
spring.data.mongodb.database = ${SPRING_DATA_MONGODB_DATABASE}
spring.data.mongodb.host = ${SPRING_DATA_MONGODB_HOST}
spring.data.mongodb.port = ${SPRING_DATA_MONGODB_PORT}
You can use the #Value annotation and access the property in whichever Spring bean you're using
#Value("${userBucket.path}")
private String userBucketPath;
The Externalized Configuration section of the Spring Boot docs, explains all the details that you might need.
I'm trying to configure MongoDB user store as our primary user store in WSO2 Identity Server v5.9.0 following steps provided in below GITHUB repo:
MongoDB user store extension
[user_store]
type = "database"
class = "org.wso2.carbon.mongodb.user.store.mgt.MongoDBUserStoreManager"
connection_url = "mongodb://localhost:27017/wso2_carbon_db"
connection_name = "wso2_admin"
connection_password = "test123"
I tried running the wso2server.bat after copying the mongodb.user.store.mgt-1.0.0-SNAPSHOT.jar in both the paths
latestwso2\repository\components\plugins
latestwso2\repository\components\dropins
WSO2 Identity Server Console
WSO2 Identity Server Console
Please let me know what else do I need to configure to make it work.
It seems like the bundle is not getting activated. [1]
The extension that you are using may not be compatible with IS-5.9.0. It's compatible with IS-5.5.0. So the versions should be upgraded relevant to the dependency versions used in IS-5.9.0[2]
[1].https://movingaheadblog.blogspot.com/2014/01/how-to-debug-wso2-carbon-products-using.html
[2].https://github.com/wso2/product-is/blob/v5.9.0/pom.xml
I have setup an EA pro cloud server and its successfully connected from the client side. The connection to the data base server is also established via client. Now i want to access the content of the database over the the cloud via browser and for that i have to make changes to webea.config on the cloud server. The webea.config has lots of properties, actually i have no idea what all to add against those fields for accessing the database over the browser. Following is the webea_config.ini:
model1 = "Pro Cloud "
model2 = "Pro Cloud2"
[model1 : settings]
sscs_protocol = "http"
sscs_server = "localhost"
sscs_port = "804"
sscs_db_alias = "MY_SERVER"
auth_code = ""
login_prompt = "false"
default_diagram = ""
show_discuss = "false"
On the browser i see as :
But when i click on pro cloud it does not take me to the database contents.
Can anyone please explain me what all do i need to add webea_config.ini file So that i get to the contents inside the database.
maybe localhost isn't known from outside, did you try providing a IP address?
Also i'd first test the same connection in 'Connect to Cloud' option in EA (from the machine where I'm trying to access from browser).
Also please ensure you have set the license and other settings required for PCS to work, refer to https://prolaborate.com/resources/documentation/installation-guide?articles=SetupProCloudServer to double check all configs are in place.
I want to use Apache Shiro Security to secure my Java standalone application but I can't find an example about this.
Please help me how I can implement and configure Apache Shiro Standalone App to connect to database and authenticate my app.
Thank You for all.
A good start is the Shiro tutorial that especially targets standalone applications. For a good reference in creating and connecting your app to a SQL-like server i recommend this tutorial. The datasourceof the PostgreSQL depends on your implementation.
Here is an example for the shiro.ini modified for PostgreSQL
[main]
# Create and setup user filter.
user = com.example.filter.FacesAjaxAwareUserFilter
user.loginUrl = /login.xhtml
# Create JDBC realm.
jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
# Configure JDBC realm datasource.
dataSource = org.postgresql.Driver
dataSource.URL = jdbc:postgresql://127.0.0.1:5432/db
dataSource.user = sa
dataSource.password = sa
jdbcRealm.dataSource = $dataSource
# Configure JDBC realm SQL queries.
jdbcRealm.authenticationQuery = SELECT password FROM User WHERE username = ?
jdbcRealm.userRolesQuery = SELECT role FROM UserRoles WHERE userId = (SELECT id FROM User WHERE username = ?)
[urls]
/login.xhtml = user
/app/** = user
I'm not sure how far along you are but I recommend reading this documentation on Programmatic Configuration of Shiro. Which will allow you to create a JdbcRealm, configure it programatically, and then authenticate against it.
I'm currently writing a Grails app using Grails 2.2.2 and MySQL, and have been deploying it to Cloudfoundry.
Until recently I've just used a single MySQL datasource for my domain, which Cloudfoundry detects and automagically creates and binds a MySQL service instance to.
I now have a requirement to store potentially large files somewhere, so I figured I'd take a look at MongoDB's GridFS. Cloudfoundry supports MongoDB, so I'd assumed Cloudfoundry would do some more magic when I deployed my app and would provide me with a MongoDB datasource as well.
Unfortunately I'm not prompted to create/bind a MongoDB service when I deploy my app, and I think this may be down to the way I'm connecting to Mongo.
I'm not using the MongoDB plugin, as this conflicts with another plugin I'm using, and in any case I don't need to persist any of my domain to Mongo - just some large files - so I'm using the Mongo java driver directly (similar to this - http://jameswilliams.be/blog/entry/171).
I'm unsure how Cloudfoundry detects that your application requires a particular datasource, but I'd assumed it would figure this out somehow from DataSource.groovy.
Mine looks like this...
environments {
development {
dataSource {
driverClassName = "com.mysql.jdbc.Driver"
dbCreate = "create-drop"
...
}
dataSourceMongo {
host = "localhost"
port = 27017
dbName = "my_mongo_database_name"
...
}
}
}
Is there something I'm missing? Or do I need to manually bind the MongoDB service somehow?
Using answer instead of comments for better formatting. :)
I guess you have already followed step to create the MongoDB service in Cloudfoundry as mentioned here otherwise this has to be done. Plus, it will be lot easier if you use the Groovy wrapper of the Java Driver of MongoDB called GMongo. Refer the GitHUb Source and this Mongo blog for more details.