Spring Auto Reconfiguration Oracle User-Provided Service Failing

368 views
Skip to first unread message

Steve Wall

unread,
Oct 17, 2014, 12:09:20 PM10/17/14
to vcap...@cloudfoundry.org

I have a Spring application that uses an Oracle DB. I created a user-provided service and bound it to my application. The Auto Reconfiguration starts but does not find a matching service. The Auto Reconfiguration does work in this environment if I use a MySQL DB. Based on the log output, it appears the Oracle data source creator is called, but it does not reconfigure the Oracle data source I have defined.

When I enter the Oracle DB information directly into the Spring configuration file that defines the Data Source, the application does connect to the DB. Which leads me to believe,the Data Source is being configured. Here’s the snippet from the Spring conf file –

<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">

<property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=10.52.23.39)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=HELIUM)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))))" />

<property name="user" value="xxxxxx" />

<property name="password" value="xxxxx" />

</bean>

The class oracle.jdbc.pool.OracleDataSource does implement the javax.sql.DataSource interface, so I would expect it to be recognized by the Auto Reconfiguration framework. But for some reason, the framework is not recognizing this as a DataSource that needs to be reconfigured. Although when I created a MySQL data source it did recognize it and it was reconfigured. Here’s the snippet when I defined the MySQL DB.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

<property name="driverClassName" value="com.mysql.jdbc.Driver" />

<property name="url" value="jdbc:mysql://us-cdbr-iron-east-01.cleardb.net:3306/ad_fb072289a01776b" />

<property name="username" value="XXXXX" />

<property name="password" value="XXXX" />

</bean>

cflog.txt
cfpush.txt

Ken Krueger

unread,
Oct 17, 2014, 2:43:44 PM10/17/14
to vcap...@cloudfoundry.org
Hi Steve, what version of spring auto configure is being used?  (you can find this in the buildpack output when you do the push)

thx,
k

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/5bf560ba-bb35-46fb-902f-832c10482495%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Ken Krueger  
Manager, Global Education Delivery
407 256 9737 Mobile
kenkrueger65 Skype

Education questions?  educ...@pivotal.io

Steve Wall

unread,
Oct 17, 2014, 3:52:25 PM10/17/14
to vcap...@cloudfoundry.org
Hi Ken,
I had actually the "cf push" and "cf log" files and forgot to call that out in the original email. Anyway... I think this is the info you are wondering about.

spring-auto-reconfiguration=1.4.0_RELEASE

Also, here's how the user provider service is defined. Just in case that would be useful.

{"user-provided":[{"name":"oracle-sv2","label":"user-provided","tags":[],"credentials":{"URL":"jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=10.52.23.39)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=HELIUM)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))))","password":"XXXX","user":"xxxxxxx"},"syslog_drain_url":""}]}

Also, here are some insight I received from another source.

1.) The Oracle support looks for a "uri" or "url" property. Case does matter, so you're going to want to change your example to user lower case.

2.) The value for the "uri" or "url" should have the format "oracle://myuser:myp...@10.20.30.40:1234/database". This looks a little odd, but will get parsed and actually result in creating a JDBC URL of "jdbc:oracle:thin:myuser/myp...@10.20.30.40:1234/database".

3.) I don't see any support for the type of URl that you've specified, "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=10.52.23.39)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=HELIUM)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))))". Trying to wedge that into the existing "uri" or "url" fields ends up with parsing errors

Thanks for the help!
-Steve

--
You received this message because you are subscribed to a topic in the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/CA%2BYXpzkb8P8fSsFftAtt%3DEFUG%2BV-6EGBunQtFBQO6d7brQAyng%40mail.gmail.com.

bjim...@pivotal.io

unread,
Oct 17, 2014, 4:39:55 PM10/17/14
to vcap...@cloudfoundry.org
I was under the impression that Spring autoconfiguration didn't work with UPS, because autoconfiguration tries to apply the right 'type' of service to its configuration, and there's no way to tell what type of service the UPS is.  For example, Spring will try to apply an JDBC service to a data source, an RMQ service to an AMQP connection factory, etc.  But a UPS could be anything; a mainframe SNA connection, a 3rd party SOAP service, or in your case a JDBC service.

Brian

Daniel Mikusa

unread,
Oct 17, 2014, 4:46:33 PM10/17/14
to vcap...@cloudfoundry.org
I think there is some support for user provided services but it's just less flexible, since there are no tags or labels for a ups.

Dan

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.

Cornelia Davis

unread,
Oct 17, 2014, 4:51:46 PM10/17/14
to vcap...@cloudfoundry.org
Scott can correct me if I am wrong but I do believe auto reconfig with UPSIs are supported - spring will look for certain clues as to the type, like if the URI starts with jdbc:.

Steve Wall

unread,
Oct 17, 2014, 10:43:19 PM10/17/14
to vcap...@cloudfoundry.org
Dan is correct! And I was able to get it working with this incantation -

The user provided service was defined with one parameter "uri" :
cf cups myInstance -p "uri"

In the Spring context file:

    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close"> 
 <property name="uri" value="" /> 
    </bean>

This didn't provide all the configuration parameters required for my needs. If you notice in the connection string I was trying to pass in originally, load balancing and failover are indicated. So even though this solution works, be aware it appears to be a bit limited.

Best,
Steve

--
You received this message because you are subscribed to a topic in the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/CAEBZkOYcqRtOuzTc86m%2Be9j2E05PrXzKoyJM%3DM1uYPY5Zn46cg%40mail.gmail.com.

Scott Frederick

unread,
Oct 17, 2014, 11:03:38 PM10/17/14
to vcap...@cloudfoundry.org, steve...@primetimesoftware.com
Steve, 

I'm glad you got this working. Here are some details on what you've found. 

The Spring Cloud Connectors service type detection (which auto-reconfiguration uses) will detect based on URI scheme (e.g. "oracle://") as well as tags, as you've discovered. This was done partly to support user-provided services and partly because tags are inconsistent across CF platform providers.

Spring Cloud Connectors prefers non-JDBC URLs for portability across runtimes and frameworks. JDBC is, of course, Java specific, and pretty much every other runtime/framework uses the style "servicetype://username:password@host:port/resource". Service brokers for managed services typically provide the non-JDBC style of URL, so Spring Cloud Connectors chooses this convention also. 

Scott
To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+unsubscribe@cloudfoundry.org.

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+unsubscribe@cloudfoundry.org.

Steve Wall

unread,
Oct 18, 2014, 7:13:59 PM10/18/14
to vcap...@cloudfoundry.org
Thanks for the insight scott!
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/c426616b-1702-4141-882a-daed0f8e86cf%40cloudfoundry.org.
Reply all
Reply to author
Forward
0 new messages