# unreachable variable for groovy script

**URL:** <https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070>\
**Category:** Q&A\
**Created:** [25 June 2015 20:20 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070 "2015-06-25T20:20:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![clara.lopez](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@clara.lopez](https://community.ofelia.com/u/clara.lopez)\
**Post date:** [25 June 2015 20:20 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/1 "2015-06-25T20:20:42Z")

</div>

Hi…  
I am doing a similar script to configure DB. Above is my script.

 public class ConfigurationDB { public static final instance = new ConfigurationDB ();

```
def String url
def String server
def String port
def String database
def String user
def String password
 
static getInstance() {
return instance;
}
 
public ConfigurationDB () {
 
this.server = "localhost";
this.port = "5432";
this.database = "db";
this.user = "user";
this.password = "pass";
this.url = "jdbc:postgresql://"+this.server+":"+this.port+"/"+this.database;
}
}

```

when I do the test separately for each value, I obtain the correct result for each one, but when I tried to test the total connector I have the next error:

`
    Tipo de Expresion no admitido para la prueba:
    Parametro de entrada script esta usando una expresion que contiene una referencia inalcanzable.
```
Type of expression unadmitted for the test:
Imput Parameter 'script' is using a expression that contain a unreachable variable.

```
`

thank you…  
regards…

---

<div class="post-metadata">

**Author:** ![david.doumeche.itk](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@david.doumeche.itk](https://community.ofelia.com/u/david.doumeche.itk)\
**Post date:** [30 June 2015 14:08 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/2 "2015-06-30T14:08:45Z")

</div>

Hi Johana,

I dont understand why you need to write a script to connect to a postgresql database server (if I understand well).  
You have Jdbc postgresql connectors for that.

The message :  
Imput Parameter ‘script’ is using a expression that contain a unreachable variable ← where do you use that expression ‘script’ ?

---

<div class="post-metadata">

**Author:** ![david.doumeche.itk](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@david.doumeche.itk](https://community.ofelia.com/u/david.doumeche.itk)\
**Post date:** [20 July 2015 13:29 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/3 "2015-07-20T13:29:59Z")

</div>

Hum,

It shouldn’t happen…

one solution is to extract the connector from zip to a folder, look at the files inside,

and create a connector definition & implementation with the code as in the connector I gave you.

---

<div class="post-metadata">

**Author:** ![clara.lopez](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@clara.lopez](https://community.ofelia.com/u/clara.lopez)\
**Post date:** [30 June 2015 16:50 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/4 "2015-06-30T16:50:53Z")

</div>

Hi David,

thank you for your time…

I need manage a configuration in one place because I use many connectors in my process, and my idea is when I update parameter(example change the database name or a username) in configuration, I only change in one place (in the script file in this case).

I tried create a Java Object Properties to read a properties file but I get the same error.

When I configure my connection I tried similar bellow:  
In connector configuration I put parameters; url, username, password  
Example: In username parameter I put ConfigurationDB.instance.user (when I do this I get the error “unreachable variable”)

[http://www.ibm.com/developerworks/library/j-bpm2/Figure26.jpg](http://www.ibm.com/developerworks/library/j-bpm2/Figure26.jpg) (this link is a bonita interface when I configure a connection) In this parameters I tried get the script instance.  
Lo que no quiero hacer es poner los parámetros en duro, por que entonces cada cambio en mi configuración implicaría tocar todos los conectores que he definido. (Sorry!! I speak spanish)

regards 🙂

---

<div class="post-metadata">

**Author:** ![david.doumeche.itk](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@david.doumeche.itk](https://community.ofelia.com/u/david.doumeche.itk)\
**Post date:** [1 July 2015 07:08 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/5 "2015-07-01T07:08:14Z")

</div>

Hello Johana,

I had the same issue and resolved it this way :  
first, I adapted a [properties connector](https://dl.dropboxusercontent.com/u/10911626/LoadProperties-1.0.0.zip) to bonita 6.  
You can import it in your bonita workspace with menu **Developpement** \> **Connectors** \> **import connector**  
and change the namespace

Next, I created a properties file inside bonita home folder :  
in developpement mode : C:\BonitaBPMCommunity-6.3.8bis\workspace\tomcat\bonita  
in hosting mode : C:\BonitaBPMCommunity-6.3.8-JBoss-5.1.0.GA\bonita

Finally, you must configure the LoadProperties and postgresql connectors according to the following screenshot

![configure loadproperties][configure loadproperties]   
[configure loadproperties]: [https://dl.dropboxusercontent.com/u/10911626/bonita\_loadproperties.png](https://dl.dropboxusercontent.com/u/10911626/bonita_loadproperties.png)

Please tell me if it solve your problem.

muchos saludos

---

<div class="post-metadata">

**Author:** ![clara.lopez](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@clara.lopez](https://community.ofelia.com/u/clara.lopez)\
**Post date:** [8 July 2015 14:01 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/6 "2015-07-08T14:01:00Z")

</div>

Hi David,

I´m try do this, but don´t work for me.  
When I try import your connector example in my bonita (6.5.1) I get this error:  
“Importación ha fallado. Descriptor file not found”.

When I tried create a connector definition in development → connector → new definition I do not see the Java connector.

---

<div class="post-metadata">

**Author:** ![david.doumeche.itk](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@david.doumeche.itk](https://community.ofelia.com/u/david.doumeche.itk)\
**Post date:** [20 July 2015 08:53 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/7 "2015-07-20T08:53:08Z")

</div>

Hi Johana,

you must import the connector in menu **developement \> connector \> import connector**

---

<div class="post-metadata">

**Author:** ![clara.lopez](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@clara.lopez](https://community.ofelia.com/u/clara.lopez)\
**Post date:** [20 July 2015 11:33 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/8 "2015-07-20T11:33:01Z")

</div>

Hi…  
When I import the connector in menu developement \> connector \> import connector, I qet this error:  
“Importación ha fallado. Descriptor file not found”.

---

<div class="post-metadata">

**Author:** ![clara.lopez](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@clara.lopez](https://community.ofelia.com/u/clara.lopez)\
**Post date:** [20 July 2015 13:40 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/9 "2015-07-20T13:40:17Z")

</div>

I tried to do that, but when I go in: development → connector → new definition I don’t see Java connector option… ☹

No sé si tiene que ver con mi versión de Bonita, estaba mirando otros ejemplos y en todos aparece como que yo puedo usar directamente ese conector, pero cuando descargue el mismo conector de otro lado, me da el mismo error.

Thank you…

---

<div class="post-metadata">

**Author:** ![david.doumeche.itk](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@david.doumeche.itk](https://community.ofelia.com/u/david.doumeche.itk)\
**Post date:** [20 July 2015 13:45 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/10 "2015-07-20T13:45:20Z")

</div>

You must create a _definition_ first,

and then the java connector is created automatically when you create an _implementation_

![http://i.imgur.com/kxj7HTa.png](http://i.imgur.com/kxj7HTa.png)

---

<div class="post-metadata">

**Author:** ![clara.lopez](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@clara.lopez](https://community.ofelia.com/u/clara.lopez)\
**Post date:** [21 July 2015 13:38 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/11 "2015-07-21T13:38:05Z")

</div>

Hi David…

Yesterday, I download again the connector and I import in Bonita, It’s work. Perhaps the file was damaging when I download.

Now I can read the properties file and the problem is solved…

Thank you, thank you for your time… 🙂  
regards… que estes bien!!!

---

<div class="post-metadata">

**Author:** ![david.doumeche.itk](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@david.doumeche.itk](https://community.ofelia.com/u/david.doumeche.itk)\
**Post date:** [21 July 2015 13:41 UTC](https://community.ofelia.com/t/unreachable-variable-for-groovy-script/6070/12 "2015-07-21T13:41:00Z")

</div>

I am very glad it finally work.

Beware to put the connector where it will always be read when necessary :

- as the first connector in the task when it’s needed
- at the process pool connector

Bien à toi
