February 14, 2017

Error: Calling the constructor for class oracle.jbo.server.SequenceImpl is not permitted

[JDev 12.1.3]

I have created an EntityObject in the Model project and assigned a DB sequence to the key attribute of it. While running the project, I got the below error.

[Static type checking] - [ADF security error] Calling the constructor for class oracle.jbo.server.SequenceImpl is not permitted.


To avoid this issue,
  • Go to the source of the entity object xml file
  • Search for the tag "TransientExpression"
  • Check the attribute trustMode. It may have the value "untrusted"
  • Change the value to "trusted". Save and run the app
Now the issue should be solved.

Note: The same solution is given in my previous post for the below error. This solution worked for both the issues.

Error: [ADF security error] The method getDBTransaction on class oracle.jbo.server.EntityImpl is not permitted



December 20, 2016

How to Export or Import oracle database

Oracle database is providing some command line tools to import or export any schema , data of a schema or the total oracle database from one to another. These tools come along with the oracle database installation by default.

Exporting:
There are two command tools to export database exp and expdp.

exp command:
Open the console and give the exp command on the command prompt. It will prompt for information like username, password, export filename and path etc as below.

Example of using oracle database command "exp"

And also it will show few options like below. You can export entire database or only users/schemas or only the tables. You can also mention, whether you want to export permission and data inside the tables also.


 After providing all these information, it will start exporting the database. After finishing it you can observe a statement like "Export terminated successfully"


Instead of following the above step by step procedure, we can give all this in a single command which will do the same. Below is the example of the command.

Ex:  Exp userid=mytestings/welcome1@xe file=d:\mydump.dmp



expdp command:
Another tool to export database is expdp command. Which works like exp command but it is more powerful. Below is the example to use this command.

expdp mytestings/welcome1 dumpfile=mydump_1.dmp logfile=mydump.log


Importing:
There are two command tools to import database from the .dmp files are imp and impdp.
These two works like the above export commands.

Below are the syntax and example to use imp command.
Syntax:
imp userid/password@Connect_identifier fromuser=user_name_you_have_data_unloaded_from touser=new_user_name file=Path_to_*.dmp file

Ex: imp testuser/welcome1@xe fromuser=mytestings touser=testuser file=D:\Data\MYDUMP.dmp

The result would look like as below.


Below is the example to use impdp command.

impdp mytestings/welcome1@orcl TABLE_EXISTS_ACTION=REPLACE dumpfile=MYDUMP.dmp

Instead of passing options to the command line, we can create a .par file and give all these properties in that file and pass that file to the command as below. This .par file option is available for both impdp and expdp commands but not imp and exp commands.

impdp sccinternal/welcome1@orcl parfile=impdata.par

Sample .par file look like as below.

schemas=mytestings
logfile=importlog.log
dumpfile=MYDUMP.dmp
TABLE_EXISTS_ACTION=REPLACE




December 6, 2016

Error: [ADF security error] The method getDBTransaction on class oracle.jbo.server.EntityImpl is not permitted

[JDev 12.2.1.0]

I have created an EntityObject from database table and assigned an expression to its key attribute to get the value from a database sequance (See this post to know how to assign a db sequence to a property in entity object ). But while building the project, I got the below error.

Error(11,53): [Static type checking] - [ADF security error] The method getDBTransaction on class oracle.jbo.server.EntityImpl is not permitted.
 @ line 11, column 53. Locations.bcs D:\Application2\Model\src\model Model.jpr


Which means that the entity is not trusted the expression changes. To avoid this issue,

  • Go to the source of the entity object xml file 
  • Search for the tag "TransientExpression"
  • Check the value of the attribute "trustMode"
  • If it is "untrusted", change it to "trusted"
  • Now rebuild the project
The above change solved my issue .






November 22, 2016

TypeError: h.apply is not a function

This is a Knockout JS error. I faced this issue when I am trying to invoke click action of a link created. My link statement is like below.

<a data-bind="attr:{id:Reqid},text: Title,click: $('#popup1').ojPopup('open', '#btnTitle')"></a>

And on click of this link, I am getting the below error.

TypeError: h.apply is not a function

This is because the click handler needs to be wrapped within a function. Below updated statement resolved the issue.

<a data-bind="attr:{id:Reqid},text: Title,hover: function(){$('#popup1').ojPopup('open', '#btnTitle')}"></a>

November 1, 2016

How to open device camera or picture gallery from MAF app

MAF provides a device feature method getPicture() to open the device camera or picture gallery. You can create binding to it if you want to open camera on the app. But if you want to handle this from java code in MAF, then check the below post.

Below is the code should be used to access the camera from the java code in MAF.

DeviceManager dm = DeviceManagerFactory.getDeviceManager();
String result=   dm.getPicture(75, dm.CAMERA_DESTINATIONTYPE_DATA_URL, dm.CAMERA_SOURCETYPE_CAMERA, false, dm.CAMERA_ENCODINGTYPE_PNG, 300, 250);

This method returns a string value with either base46 encoding string or the file path of the image based on the given destination type.

Syntax of the method is:
getPicture(int quality, int destinationType, int sourceType, boolean allowEdit, int encodingType, int targetWidth, int targetHeight) 

Where

quality: Quality of saved image
destinationType: Type of the return value whether it is base64 encoding string or file path. For base64 use 0=DESTINATIONTYPE_DATA_URL or for file path use 1 = DESTINATIONTYPE_FILE_URI
sourceType: What is the source of the picture whether it is device camera or photo gallery. For gallery use 0=CAMERA_SOURCETYPE_PHOTOLIBRARY or for camera use 1=CAMERA_SOURCETYPE_CAMERA
allowEdit: Allow simple editing of image before selection
encodingType: the encoding of the returned image file. Select 0 = CAMERA_ENCODINGTYPE_JPEG for JPEG image or 1 = CAMERA_ENCODINGTYPE_PNG for PNG image
targetWidth: Width in pixels to scale image
targetHeight: Height in pixels to scale image

Note: you can not test camera in iOS Simulator or Android Emulator. The camera can be tested only on the device, but you can test the gallery in the Simulator or Emulator. To check if the running device is Simulator or Emulator, you have to give a condition like,

if (dm.getName().indexOf("Simulator") != -1)  // For iOS Simulator
if (dm.getName().indexOf("sdk") != -1)            //For Android Emulator