Illegal connection URL #2

Closed
sherod opened this Issue Aug 30, 2011 · 7 comments

2 participants

@sherod

Version built from git (pulled yesterday) 22.0.6 throws an exception with a connection URL which seems to work fine in 22.0.3 (Which is in the current maven repo)

Exception is:

Caused by: java.lang.IllegalArgumentException: Illegal connection url (force://test.salesforce.com;user=steven.herod@mysite.com.DEV;password=CHANGEDJJ3eZki3
gEZORCFrOZNz7eaSs;oauth_key=5MV442mZZZnmM6mzLV39eLlSuWQgNB2Z2R9kScjg_Xs58q7Jm9zgz5ERs5ZEZ78oA606pOSoeHQABAKW3cWc;oauth_secret=123456916284780867). The ForceCo
nnectionProperty (endpoint) must have a value

My persistence xml is:

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="forceDatabase">
    <provider>com.force.sdk.jpa.PersistenceProviderImpl</provider>
    <!-- In a single module web application, no need to specify classes. Classes 
        will be autodiscovered based on @Entity annotation -->
    <properties>
        <property name="datanucleus.storeManagerType" value="force" />
        <property name="datanucleus.autoCreateSchema" value="false" />
        <property name="datanucleus.autoCreateWarnOnError" value="false" />
        <property name="datanucleus.validateTables" value="false" />
        <property name="datanucleus.ConnectionURL" value="force://test.salesforce.com;user=steven.herod@mysite.com.DEV;password=CHANGEDJJ3eZki3gEZORCFrOZNz7eaSs;oauth_key=5MV442mZZZnmM6mzLV39eLlSuWQgNB2Z2R9kScjg_Xs58q7Jm9zgz5ERs5ZEZ78oA606pOSoeHQABAKW3cWc;oauth_secret=123456916284780867"/>
        <property name="datanucleus.validateConstraints" value="false" />
        <property name="datanucleus.Optimistic" value="false" />
        <property name="datanucleus.datastoreTransactionDelayOperations" value="true" />
        <property name="datanucleus.jpa.addClassTransformer" value="false" />
        <property name="datanucleus.cache.level2.type" value="none" />
        <property name="datanucleus.detachAllOnCommit" value="true" />
        <property name="datanucleus.copyOnAttach" value="false" />

    </properties>
</persistence-unit>

@sherod

(note password/keys have been changed from the real values)

@tkral

Hi,

The force connection url format changed slightly in 22.0.6-BETA. The username and password should now appear as standard query parameters. Try this:

force://host?user=username&password=password

@sherod

Thanks, that seems to have resolved that. Should the value in the persistence.xml files should encode & with & ?

@tkral

Yes. Otherwise you'll find that your xml is invalid.

But note, we recommend managing your connection URLs outside of your source code. Like in an environment variable for example. We should be releasing the documentation about this soon, but in 22.0.6-BETA, you can do this:

...

...

Then:

$ export FORCE_CONN_ENV_VAR=force://host?user=username&password=password

This will keep your username and password out of source control and allow you to easily swap in a production url should you run your app in a production environment.

@sherod sherod closed this Aug 30, 2011
@sherod

Okay. I just have to figure out how that would work with Heroku (It's probably something simple, I just have to look it up)

@tkral

Doh. The XML didn't show up:

...
<property name="datanucleus.ConnectionURL" value="${FORCE_CONN_ENV_VAR}"/>
...

Then:

$ export FORCE_CONN_ENV_VAR=force://host?user=username&password=password

@tkral

If you are using Heroku, then you definitely want to use environment variables like I mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment