Thanks, Alex.

Now I get a java.lang.ClassNotFoundException:

Caused by: java.lang.ClassNotFoundException: DateTimeFunctions.class
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at 
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:284)
        ... 40 more

Full exception is further below.

I verified that the class is in the library.

> jar tvf libs/icpoc-pojo.jar | grep DateTimeFunctions.class
  3583 Thu Jul 20 14:51:52 PDT 2017 
com/abc/poc/icpoc/function/DateTimeFunctions.class

And I verified that the jar is in the classpath (using echo in the ignite.sh). 
Besides, the same JAR also includes the POJO for the cached objects, which are 
loaded correctly.

The client also reports the same exception. The client is a fat jar with the 
DateTimeFunctions class included.

Configuration:

                <bean 
class="org.apache.ignite.configuration.CacheConfiguration">

                    <property name="sqlFunctionClasses">
                        <list>
                            <value>DateTimeFunctions.class</value>
                        </list>
                    </property>

Version: ver. 2.0.0#20170430-sha1:d4eef3c6

Any suggestions?

Thanks…

Roger

PS: Full exception:

class org.apache.ignite.IgniteException: Failed to instantiate Spring XML 
application context (make sure all classes used in Spring configuration are 
present at CLASSPATH) 
[springUrl=file:/home/ignite/ignite/test-ignite-cassandra/config-server-cassandra.xml]
        at 
org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:949)
        at org.apache.ignite.Ignition.start(Ignition.java:350)
        at 
org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:302)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to 
instantiate Spring XML application context (make sure all classes used in 
Spring configuration are present at CLASSPATH) 
[springUrl=file:/home/ignite/ignite/test-ignite-cassandra/config-server-cassandra.xml]
        at 
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:387)
        at 
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
        at 
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
        at 
org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:668)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:869)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:778)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:648)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:617)
        at org.apache.ignite.Ignition.start(Ignition.java:347)
        ... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'grid.cfg' defined in URL 
[file:/home/ignite/ignite/test-ignite-cassandra/config-server-cassandra.xml]: 
Cannot create inner bean 
'org.apache.ignite.configuration.CacheConfiguration#3b084709' of type 
[org.apache.ignite.configuration.CacheConfiguration] while setting bean 
property 'cacheConfiguration' with key [0]; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'org.apache.ignite.configuration.CacheConfiguration#3b084709' defined 
in URL 
[file:/home/ignite/ignite/test-ignite-cassandra/config-server-cassandra.xml]: 
Initialization of bean failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert property 
value of type 'java.util.ArrayList' to required type 'java.lang.Class[]' for 
property 'sqlFunctionClasses'; nested exception is 
java.lang.IllegalArgumentException: Cannot find class [DateTimeFunctions.class]
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:313)
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:157)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
        at 
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
        at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
        at 
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:381)
        ... 9 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 
'org.apache.ignite.configuration.CacheConfiguration#3b084709' defined in URL 
[file:/home/ignite/ignite/test-ignite-cassandra/config-server-cassandra.xml]: 
Initialization of bean failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert property 
value of type 'java.util.ArrayList' to required type 'java.lang.Class[]' for 
property 'sqlFunctionClasses'; nested exception is 
java.lang.IllegalArgumentException: Cannot find class [DateTimeFunctions.class]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
        at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:299)
        ... 24 more
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert 
property value of type 'java.util.ArrayList' to required type 
'java.lang.Class[]' for property 'sqlFunctionClasses'; nested exception is 
java.lang.IllegalArgumentException: Cannot find class [DateTimeFunctions.class]
        at 
org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:610)
        at 
org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:617)
        at 
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:216)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1577)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1536)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        ... 26 more
Caused by: java.lang.IllegalArgumentException: Cannot find class 
[DateTimeFunctions.class]
        at 
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:287)
        at 
org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:63)
        at 
org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:468)
        at 
org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:441)
        at 
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:199)
        at 
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:143)
        at 
org.springframework.beans.TypeConverterDelegate.convertToTypedArray(TypeConverterDelegate.java:479)
        at 
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:216)
        at 
org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:590)
        ... 32 more
Caused by: java.lang.ClassNotFoundException: DateTimeFunctions.class
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at 
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:284)
        ... 40 more

From: afedotov [mailto:[email protected]]
Sent: Thursday, July 20, 2017 2:28 AM
To: [email protected]
Subject: Re: Custom SQL Functions

Hello,

1) No, functions can't be overloaded. Functions with the same name must have a 
different number of parameters
3) To register a class with custom SQL functions via XML just use regular 
Spring bean notation

<bean id="ccfg" class="org.apache.ignite.configuration.CacheConfiguration">
    ...
    <property name="sqlFunctionClasses">
        <list>
            <value>Functions1.class</value>
            <value>Functions2</value>
            ...
        </list>
    </property>
</bean>

Kind regards,
Alex.

On Thu, Jul 20, 2017 at 6:31 AM, Roger Fischer (CW) [via Apache Ignite Users] 
<[hidden email]</user/SendEmail.jtp?type=node&node=15170&i=0>> wrote:
Hello,

I have a couple of questions on custom SQL functions:

1) Can functions be overloaded, ie. could there be a to_string( Date) and a 
to_string( Double) function?

2) If yes, how is the applicable function identified? Based on parameters? Or 
does the function need to be qualified with the class name?

3) How are functions registered using XML configuration? The documentation only 
shows programmatic registration.

Thanks…

Roger


________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-ignite-users.70518.x6.nabble.com/Custom-SQL-Functions-tp15153.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__apache-2Dignite-2Dusers.70518.x6.nabble.com_Custom-2DSQL-2DFunctions-2Dtp15153.html&d=DwMFaQ&c=IL_XqQWOjubgfqINi2jTzg&r=1esZO0r0bYS90lcsaLA6N4AFxuNo6lzauhETGwdJQoQ&m=Jk0V6qcRfFi1NvHvBS8wSRMg0_LfPriSveES5_hWkl4&s=Klxioe3sgLA4RwnVlaYQIxh3l04gqIC2LQfkVnIbqvQ&e=>
To start a new topic under Apache Ignite Users, email [hidden 
email]</user/SendEmail.jtp?type=node&node=15170&i=1>
To unsubscribe from Apache Ignite Users, click here.
NAML<https://urldefense.proofpoint.com/v2/url?u=http-3A__apache-2Dignite-2Dusers.70518.x6.nabble.com_template_NamlServlet.jtp-3Fmacro-3Dmacro-5Fviewer-26id-3Dinstant-5Fhtml-2521nabble-253Aemail.naml-26base-3Dnabble.naml.namespaces.BasicNamespace-2Dnabble.view.web.template.NabbleNamespace-2Dnabble.view.web.template.NodeNamespace-26breadcrumbs-3Dnotify-5Fsubscribers-2521nabble-253Aemail.naml-2Dinstant-5Femails-2521nabble-253Aemail.naml-2Dsend-5Finstant-5Femail-2521nabble-253Aemail.naml&d=DwMFaQ&c=IL_XqQWOjubgfqINi2jTzg&r=1esZO0r0bYS90lcsaLA6N4AFxuNo6lzauhETGwdJQoQ&m=Jk0V6qcRfFi1NvHvBS8wSRMg0_LfPriSveES5_hWkl4&s=WfX-lc9FbfpqqdoSEG1JUP5DUSKCx6zxzSzvoyfVNOI&e=>


________________________________
View this message in context: Re: Custom SQL 
Functions<https://urldefense.proofpoint.com/v2/url?u=http-3A__apache-2Dignite-2Dusers.70518.x6.nabble.com_Custom-2DSQL-2DFunctions-2Dtp15153p15170.html&d=DwMFaQ&c=IL_XqQWOjubgfqINi2jTzg&r=1esZO0r0bYS90lcsaLA6N4AFxuNo6lzauhETGwdJQoQ&m=Jk0V6qcRfFi1NvHvBS8wSRMg0_LfPriSveES5_hWkl4&s=FPG4pv55wsIE9ZzTjUWBIpQyoRUTWHOQMsvQa1F9M7k&e=>
Sent from the Apache Ignite Users mailing list 
archive<https://urldefense.proofpoint.com/v2/url?u=http-3A__apache-2Dignite-2Dusers.70518.x6.nabble.com_&d=DwMFaQ&c=IL_XqQWOjubgfqINi2jTzg&r=1esZO0r0bYS90lcsaLA6N4AFxuNo6lzauhETGwdJQoQ&m=Jk0V6qcRfFi1NvHvBS8wSRMg0_LfPriSveES5_hWkl4&s=FU2L7ACvI6GX-gqykcKlCrJI8whNXZxbYLVptqtiT5k&e=>
 at Nabble.com.

Reply via email to