The .jar doesn't get exported on preview mode?

Hello!

Im trying to fill a select widget from a Groovy script that needs a .jar as a dependency. I’ve already added the dependency to the process through the configure dialog, but I keep getting an error when trying to preview the form. This error indicates that a class cannot be found, and this class is supposed to be declared in the .jar.

Version 6.3.3

Stack trace here:
/////////////////////////////////////////////////////////////////////////////////////////////////////////
1 error

at org.bonitasoft.engine.api.impl.ProcessAPIImpl.evaluateExpressionsOnActivityInstance(ProcessAPIImpl.java:5571)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeAPI(ServerAPIImpl.java:368)
at org.bonitasoft.engine.api.impl.ServerAPIImpl$1.call(ServerAPIImpl.java:337)
at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:276)
at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeAPIInTransaction(ServerAPIImpl.java:344)
at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeAPI(ServerAPIImpl.java:286)
at org.bonitasoft.engine.api.impl.ServerAPIImpl.invokeMethod(ServerAPIImpl.java:128)
at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:88)
at com.sun.proxy.$Proxy16.evaluateExpressionsOnActivityInstance(Unknown Source)
at org.bonitasoft.forms.server.accessor.api.ExpressionEvaluatorEngineClient.evaluateExpressionsOnActivityInstance(ExpressionEvaluatorEngineClient.java:45)
... 32 more

Caused by: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script2.groovy: 13: unable to resolve class com.mysql.jdbc.Driver
@ line 13, column 115.
, “**“,””,new com.my
^
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

FYI, when I evaluate the Groovy script, and check the dependency, everything works as it is supposed to.

Thank you for your help.

Hi there,

I saw something similar with Postgres…it’s not the .jar itself it can’t find it’s the MySQL class it can’t find…

This is my code:

String url = "jdbc:postgresql://"+dbParms.get("dbHost")+":"+dbParms.get("dbPort")+"/"+dbParms.get("dbDatabase"); try { try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException ex1) { dbParms.clear(); dbParms.put("Error", thisModule+": DB Connection Error (ex1): "+ex1.toString()); logger.severe(thisModule+": DB Connection Error (ex1): "+ex1.toString()); } con = DriverManager.getConnection(url, dbParms.get("dbUser"),dbParms.get("dbPassword")); } catch (SQLException ex2) { logger.severe(thisModule+": DB Connection Error (ex2): dbParms="+dbParms); dbParms.clear(); dbParms.put("Error", thisModule+": DB Connection Error (ex2): "+ex2.toString()); logger.severe(thisModule+": DB Connection Error (ex2): "+ex2.toString()); } finally { try { if (con != null) { con.close(); } } catch (SQLException ex3) { dbParms.clear(); dbParms.put("Error", thisModule+": DB Connection Error (ex3): "+ex3.toString()); logger.severe(thisModule+": DB Connection Error (ex3): "+ex3.toString()); } }

the important bit is to add the following…and it should work.

try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException ex1) { }

obviously change postgres to MySQL…

hope it helps

regards
Seán