ClassNotFound exception on engine startup for custom function created inside BusinessEvents(BE) project

ClassNotFound exception on engine startup for custom function created inside BusinessEvents(BE) project

book

Article ID: KB0075503

calendar_today

Updated On:

Products Versions
TIBCO BusinessEvents Enterprise Edition 5.5.0 - 5.6.0 Hf2

Description

We have custom functions defined in java file inside BusinessEvents(BE) project, under javaSrc.
The functions are compiled without any error and ear file is generated successfully. 
While starting the be-engine, we got ClassNotFound error complains on a class created in javaSrc:
>>>>>>>>>>>>>>>>>>>>>>>
Debug [pool-1-thread-1] - [model.functions] Exception while loading function category 'XYZ'.
java.lang.NoClassDefFoundError: com/tibco/be/XYZ/SaxHandler
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup.getMethod(JavaAnnotationLookup.java:1192)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup.loadCategoryInParallel(JavaAnnotationLookup.java:1106)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup.loadCatalogInParallel(JavaAnnotationLookup.java:982)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup.processClassParallel(JavaAnnotationLookup.java:848)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup.access$000(JavaAnnotationLookup.java:94)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup$JarScanner.call(JavaAnnotationLookup.java:638)
at com.tibco.be.model.functions.impl.JavaAnnotationLookup$JarScanner.call(JavaAnnotationLookup.java:571)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.tibco.be.xyz.SaxHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
 Warning [pool-1-thread-1] - [model.functions] Failed to fully load function category 'XYZ', moving on to next category.
 Error [pool-1-thread-1] - [model.functions] null
<<<<<<<<<<<<<<<<<<<<<<<

Issue/Introduction

ClassNotFound exception on engine startup for custom function created inside BusinessEvents(BE) project

Environment

All supported platforms

Resolution

This issue is caused by the mechanism used by be-engine's class loader to load the classes. During compilation, the com.tibco.be.xyz.SaxHandler has not been compiled thus ClassNotFound exception is thrown. This issue is fixed in 5.6.1 HF-03, Jira BE-27792. Upgrade to 5.6.1 and apply Hotfix-03 to get the fix of the issue.

If user is not able to upgrade, the issue can be workaround with the following approach:
- In BE project, export the SAXHelper.java to a jar file
- Configure the exported jar file as 3rd party jar dependency for BE project, also add it as external jar on Java Build Path for the project.
- Remove SAXHelper.java file from javaSrc as the same definition is provided by the jar file
- Rebuild the ear file and have the exported jar file copied to server on java path.