4 Replies Latest reply: Aug 5, 2013 12:34 AM by ad1e9977-cd19-4bc6-9c4e-62bb863f0713 RSS

    Custom Function giving compile error

    ad1e9977-cd19-4bc6-9c4e-62bb863f0713

      Hi All,

       

      I have created a custom function to get the current time stamp. Below is the java code:

       

      package com.oracle.determinations.examples;

      import com.oracle.determinations.engine.CustomFunction;

      import com.oracle.determinations.engine.EntityInstance;

      import java.util.*;

      import java.text.*;

       

      public class CurrentTimeStamp extends CustomFunction {

        

         public Object evaluate(EntityInstance entityInstance, Object[] objects) {

            Date dNow = new Date( );

            SimpleDateFormat ft =

            new SimpleDateFormat ("MM/dd/yyyy HH:mm:ss");

          /*System.out.println(ft.format(dNow));*/

            return ft.format(dNow);

           

       

         }

      }

       

      My Extension.xml is as below:

      <?xml version="1.0" encoding="utf-8"?>

      <extension>

        <functions>

          <function name="CurrentTimeStamp" return-type="text">

        <arg name="entered-name" type="text"/>

             <handler platform="java" class="com.oracle.determinations.examples.CurrentTimeStamp"/>

            </function>

        </functions>

      </extension>

       

      The extension.xml is placed under following path:

      Development/Extension/CurrentTimeStamp/extension.xml

       

      The JAR file is palced under following path:

      Development/Extension/CurrentTimeStamp/lib/CurrentTimeStamp.jar (the jar file includes the com.oracle.determination.example folder structure)

       

       

      When i am using CurrentTimeStamp() in the rule base, it is throwing compile error saying:

      Error after text CurrentTimeStamp(' Fount Text: ')'. Exptected value variable or constant OPA - E00111

       

      Can you please help me where i am getting wrong and why it is not identifying the function?

       

      Thanks,

      KK

        • 1. Re: Custom Function giving compile error
          ad1e9977-cd19-4bc6-9c4e-62bb863f0713

          Hi,

           

          I tried using the function with blank arguments like:CurrentTimeStamp("") and it was compiled successfully. When I tried running this rulebase in the tomcat server (web determinations).. i got the below error; Can someone please let me know what is happening here:

           

          HTTP Status 500 - Servlet.init() for servlet WebDeterminationsServlet threw exception


          type Exception report

          message Servlet.init() for servlet WebDeterminationsServlet threw exception

          description The server encountered an internal error that prevented it from fulfilling this request.

          exception

          javax.servlet.ServletException: Servlet.init() for servlet WebDeterminationsServlet threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.lang.Thread.run(Unknown Source) 

           

          root cause

          java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0 java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClassCond(Unknown Source) java.lang.ClassLoader.defineClass(Unknown Source) java.lang.ClassLoader.defineClass(Unknown Source) com.oracle.determinations.engine.local.CustomResourceClassLoader.findClass(CustomResourceClassLoader.java:120) java.lang.ClassLoader.loadClass(Unknown Source) java.lang.ClassLoader.loadClass(Unknown Source) java.lang.Class.forName0(Native Method) java.lang.Class.forName(Unknown Source) com.oracle.determinations.util.PlatformClassLoader.newInstance(PlatformClassLoader.java:61) com.oracle.determinations.engine.local.RulebaseLoader.loadCustomFunctions(RulebaseLoader.java:267) com.oracle.determinations.engine.local.RulebaseLoader.loadRulebase(RulebaseLoader.java:178) com.oracle.determinations.interview.engine.InterviewRulebase.<init>(InterviewRulebase.java:137) com.oracle.determinations.interview.engine.local.LocalRulebaseService.applyChangeSet(LocalRulebaseService.java:250) com.oracle.determinations.interview.engine.plugins.rulebaseresolver.ClassloaderRulebaseResolverPlugin.initialise(ClassloaderRulebaseResolverPlugin.java:73) com.oracle.determinations.interview.engine.local.LocalRulebaseService.<init>(LocalRulebaseService.java:53) com.oracle.determinations.interview.engine.local.LocalInterviewEngine.initialise(LocalInterviewEngine.java:181) com.oracle.determinations.interview.engine.local.LocalInterviewEngine.<init>(LocalInterviewEngine.java:66) com.oracle.determinations.interview.engine.InterviewEngineFactory.createInstance(InterviewEngineFactory.java:19) com.oracle.determinations.web.platform.servlet.WebDeterminationsServletContext.init(WebDeterminationsServletContext.java:180) com.oracle.determinations.web.platform.servlet.WebDeterminationsServletContext.<init>(WebDeterminationsServletContext.java:116) com.oracle.determinations.web.platform.servlet.WebDeterminationsServlet.init(WebDeterminationsServlet.java:73) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.lang.Thread.run(Unknown Source) 

           

          note The full stack trace of the root cause is available in the Apache Tomcat/7.0.40 logs.

          • 2. Re: Custom Function giving compile error
            Bradtuckett-Oracle

            Class version 51 is Java 7, so this suggests you have compiled your classes in the Java 7 JDK but are trying to load them in an earlier Java version (I would guess Java 6 since that's the earliest Java version that supports Apache Tomcat 7). 

             

            You can tell the JDK compiler to create classes that target Java 6 which should then work - see "javac - Java programming language compiler"

            • 3. Re: Custom Function giving compile error
              Bradtuckett-Oracle

              I got this to work - based on your comments I am assuming you didn't pass it any parameters in the first instance, even though the extension.xml says that "entered-name" is a required parameter.

              • 4. Re: Custom Function giving compile error
                ad1e9977-cd19-4bc6-9c4e-62bb863f0713

                Hello Brad,

                 

                Thanks for that input. I compiled in Java 6 and it resolved the error.

                 

                Thanks,

                KK