User defined function on jboss teiid
aakash03 May 16, 2017 2:20 AMHi,
I am trying to create user defined function and for this I am referring below link :
I have gone through the below steps:
1. Created Java class and a method under it
package org.something;
public class TempConv
{
public static Double celsiusToFahrenheit(Double doubleCelsiusTemp)
{
if (doubleCelsiusTemp == null)
{
return null;
}
return (doubleCelsiusTemp)*9/5 + 32;
}
}
2. converted this java class into the jar file and have placed on below location:
teiid-9.1.3\modules\celsiusToFahrenheit\
3. VDB:
<?xml version="1.0" ?><vdb name="SvcSourceVdb_testConnection" version="1">
<description>VDB for: SvcSourceVdb_testConnection, Version: 1</description>
<connection-type>BY_VERSION</connection-type>
<property name ="lib" value ="celsiusToFahrenheit"></property>
<model name="{model-name}" type="VIRTUAL">
<metadata type="DDL"><![CDATA[
CREATE VIRTUAL FUNCTION celsiusToFahrenheit(celsius decimal) RETURNS decimal OPTIONS (JAVA_CLASS 'org.something.TempConv', JAVA_METHOD 'celsiusToFahrenheit');]]>
</metadata>
</model>
<model name="testConnection" type="PHYSICAL" visible="true">
<property name="importer.tableTypes" value="TABLE"></property>
<source name="testConnection" translator-name="mysql5" connection-jndi-name="java:/DSMYSQL2017051611225212"></source></model>
<model name="testConnectionNative" type="PHYSICAL" visible="true">
<source name="testConnectionNative" translator-name="mysql-native" connection-jndi-name="java:/DSMYSQL2017051611225212"></source>
</model>
<translator name="mysql-native" type="mysql5">
<property name="SupportsDirectQueryProcedure" value="true"></property></translator>
</vdb>
4. deploying the vdb
I am getting below error message
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."SvcSourceVdb_testConnection-vdb.xml".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.unit."SvcSourceVdb_testConnection-vdb.xml".DEPENDENCIES: WFLYSRV0153: Failed to process phase DEPENDENCIES of deployment "SvcSourceVdb_testConnection-vdb.xml"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: TEIID50088 Failed to load module celsiusToFahrenheit for UDF in VDB SvcSourceVdb_testConnection.1:org.jboss.modules.ModuleNotFoundException: celsiusToFahrenheit:main
at org.teiid.jboss.VDBDependencyDeployer.deploy(VDBDependencyDeployer.java:85)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
Note: I am using wildfly 10.0.0 and Teiid 9.1.3
Thanks,
Aakash Sen