Wednesday, February 25, 2015

ADF 12c: JBO-25152: Calling the constructor for class oracle.jbo.Key is not permitted.

What to do, when in JDeveloper 12c you encountered following error:

Exception in thread "AWT-EventQueue-0" oracle.jbo.JboException: JBO-29000: Unexpected exception caught: org.codehaus.groovy.control.MultipleCompilationErrorsException, msg=startup failed:

General error during semantic analysis: JBO-25152: Calling the constructor for class oracle.jbo.Key is not permitted.



oracle.jbo.ExprSecurityException: JBO-25152: Calling the constructor for class oracle.jbo.Key is not permitted.

    at oracle.jbo.script.InternalSecurityPolicyEnforcer.checkConstructor(InternalSecurityPolicyEnforcer.java:304)

    at oracle.jbo.script.ExprASTScanningVisitor.visitConstructorCallExpression(ExprASTScanningVisitor.java:127)

    at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:44)

    at org.codehaus.groovy.ast.CodeVisitorSupport.visitBinaryExpression(CodeVisitorSupport.java:144)

    at org.codehaus.groovy.ast.CodeVisitorSupport.visitDeclarationExpression(CodeVisitorSupport.java:245)

    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitDeclarationExpression(ClassCodeVisitorSupport.java:107)

    at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:86)

    at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)

    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193)

    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)

    at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)

    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)

    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)

    at org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:82)

    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:228)

    at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:42)

    at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)

    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)

    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)

    at oracle.jbo.script.ExprASTScan.visit(ExprASTScan.java:97)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:606)

    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189)

    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)

    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)

    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:55)

    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)

    at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:232)

    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1036)

    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)

    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)

    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)

    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)

    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)

    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)

    at groovy.lang.GroovyShell.parse(GroovyShell.java:625)

    at groovy.lang.GroovyShell.parse(GroovyShell.java:652)

    at oracle.jbo.ExprEval.parseScript(ExprEval.java:1571)

    at oracle.jbo.ExprEval.findScript(ExprEval.java:1152)

    at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:1956)

    at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:1928)

    at oracle.jbo.ExprEval.evaluateForRow(ExprEval.java:1647)

    at oracle.jbo.server.AttributeDefImpl.evaluateTransientExpression(AttributeDefImpl.java:2486)

    at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1947)

    at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:2036)

    at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:886)

    at oracle.jbo.server.ViewRowImpl.getAttrInvokeAccessor(ViewRowImpl.java:968)

    at oracle.jbo.server.ViewRowImpl.getAttribute(ViewRowImpl.java:916)

    at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGetAttributeValueFromRow(JUCtrlValueBinding.java:1248)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.getTargetRowData(JUCtrlListBinding.java:1988)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.matchTargetWithLov(JUCtrlListBinding.java:2064)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndexInternal(JUCtrlListBinding.java:2522)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndex(JUCtrlListBinding.java:2261)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findAndUpdateSelectedIndex(JUCtrlListBinding.java:2227)

    at oracle.jbo.uicli.jui.JUComboBoxCtrlBinding.setValueAt(JUComboBoxCtrlBinding.java:546)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.updateValuesFromRow(JUCtrlListBinding.java:2885)

    at oracle.jbo.uicli.jui.JUComboBoxBinding.updateValuesFromRow(JUComboBoxBinding.java:193)

    at oracle.jbo.uicli.jui.JUComboBoxCtrlBinding.updateValueToCurrentRow(JUComboBoxCtrlBinding.java:505)

    at oracle.jbo.uicli.jui.JUComboBoxCtrlBinding$1mRunnable.run(JUComboBoxCtrlBinding.java:417)

    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)

    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)

    at java.awt.EventQueue.access$200(EventQueue.java:103)

    at java.awt.EventQueue$3.run(EventQueue.java:694)

    at java.awt.EventQueue$3.run(EventQueue.java:692)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)

    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)

    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)

    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)



1 error



    at oracle.jbo.ExprEval.parseScript(ExprEval.java:1594)

    at oracle.jbo.ExprEval.findScript(ExprEval.java:1152)

    at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:1956)

    at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:1928)

    at oracle.jbo.ExprEval.evaluateForRow(ExprEval.java:1647)

    at oracle.jbo.server.AttributeDefImpl.evaluateTransientExpression(AttributeDefImpl.java:2486)

    at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1947)

    at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:2036)

    at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:886)

    at oracle.jbo.server.ViewRowImpl.getAttrInvokeAccessor(ViewRowImpl.java:968)

    at oracle.jbo.server.ViewRowImpl.getAttribute(ViewRowImpl.java:916)

    at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGetAttributeValueFromRow(JUCtrlValueBinding.java:1248)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.getTargetRowData(JUCtrlListBinding.java:1988)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.matchTargetWithLov(JUCtrlListBinding.java:2064)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndexInternal(JUCtrlListBinding.java:2522)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findListIndex(JUCtrlListBinding.java:2261)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.findAndUpdateSelectedIndex(JUCtrlListBinding.java:2227)

    at oracle.jbo.uicli.jui.JUComboBoxCtrlBinding.setValueAt(JUComboBoxCtrlBinding.java:546)

    at oracle.jbo.uicli.binding.JUCtrlListBinding.updateValuesFromRow(JUCtrlListBinding.java:2885)

    at oracle.jbo.uicli.jui.JUComboBoxBinding.updateValuesFromRow(JUComboBoxBinding.java:193)

    at oracle.jbo.uicli.jui.JUComboBoxCtrlBinding.updateValueToCurrentRow(JUComboBoxCtrlBinding.java:505)

    at oracle.jbo.uicli.jui.JUComboBoxCtrlBinding$1mRunnable.run(JUComboBoxCtrlBinding.java:417)

    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)

    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)

    at java.awt.EventQueue.access$200(EventQueue.java:103)

    at java.awt.EventQueue$3.run(EventQueue.java:694)

    at java.awt.EventQueue$3.run(EventQueue.java:692)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)

    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)

    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)

    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

General error during semantic analysis: JBO-25152: Calling the constructor for class oracle.jbo.Key is not permitted.


This error occurs because of the difference between the EO.xml in ADF 11.x and  12.x.
ADF 12.x adds "trustMode" attribute to the groovy expression definition. By example:

<ViewAttribute
    Name="Ikona"
    IsUpdateable="false"
    IsSelected="false"
    IsPersistent="false"
    PrecisionRule="true"
    Type="java.lang.String"
    ColumnType="CHAR"
    AliasName="VIEW_ATTR"
    SQLType="VARCHAR"
    Passivate="true">
    <TransientExpression><![CDATA[try{
oracle.jbo.Key key2 = new oracle.jbo.Key(GrupaZainteresowanId);
if(GrupyZainteresowanLov1.findByKey(key2,1)[0]==null) return "";
else return GrupyZainteresowanLov1.findByKey(key2,1)[0].getAttribute("Ikona");
}
catch(e){
return "Blad: "+e.toString();
}]]></TransientExpression>
    <RecalcCondition
      trustMode="trusted"><![CDATA[true]]></RecalcCondition>
  </ViewAttribute>


As shown in ADF 12.1.3.0 release note:

"JDeveloper 12.1.3 and ADF has introduced a tightening security model for ADF BC Groovy expressions as a stepping stone for upcoming Oracle products. Oracle is progressively introducing this feature to reduce the burden on customers.
For any new ADF application, customers must set via the property inspector trustMode="true" for any ADF BC attributes or similar using a Groovy expression. Otherwise at runtime JBO-25152 will be raised.
For customers porting applications from previous releases of JDeveloper the trustMode will be set to true for existing Groovy expressions, though any new expressions still require developers explicitly set the trustMode."

Just as it is written the groovy expressions are executed by default in untrusted mode.
So you should change trustMode="untrusted"  to "trusted"(in xml or through Property Inspector).

If you invoke java method from expression then you can also use @AllowUntrustedScriptAccess annotation on such method.

No comments:

Post a Comment