Oracle MAF Error "Unable to read DataControl Usages, on loadDataControl for id:" - oracle

I have created a simple SOAP web service for a remote DB which is working fine in WebLogic 12c server and also in Jdeveloper HTTP analyzer. When I am using the same web service in the code below, I am getting the following error (I have included the System.out.println outputs in ref. to the flow of the code) I am using Jdeveloper 12C MAF 2.0.0.0.41 on Mac OSx 10.9.
Chk #0
Processing row# 1
Chk #1
Chk #2
[SEVERE - oracle.adfmf.framework - AmxBindingContext - loadDataControlById] Unable to read DataControl Usages, on loadDataControl for id: WLFNewActWS.
[SEVERE - oracle.adfmf.framework - SynchronizationDC - syncDataFromOfflineToOnline] [Ljava.lang.StackTraceElement;#467c53d3
public void syncDataFromOfflineToOnline() {
Trace.log(Utility.FrameworkLogger, Level.INFO, this.getClass(), "syncDataFromOfflineToOnline",
"Executing syncDataFromOfflineToOnline Method");
try {
Connection conn = DBConnectionFactory.getConnection();
conn.setAutoCommit(false);
String select = "SELECT * FROM DEPARTMENTS";
PreparedStatement pStmt = conn.prepareStatement(select);
ResultSet rs = pStmt.executeQuery();
System.out.println("Chk #0");
int rowcount = 0;
while (rs.next()) {
rowcount++;
System.out.println("Processing row# " + rowcount);
List namesList = new ArrayList(1);
List paramsList = new ArrayList(1);
List typesList = new ArrayList(1);
Department dept = new Department();
dept.setDeptId(rs.getInt("DEPARTMENT_ID"));
dept.setDeptName(rs.getString("DEPARTMENT_NAME"));
dept.setMgrId(rs.getInt("MANAGER_ID"));
dept.setLocId(rs.getInt("LOCATION_ID"));
System.out.println("Chk #1");
GenericType gtDept =
GenericTypeBeanSerializationHelper.toGenericType("WLFNewActWS.Types.persistDepartments.arg0", dept);
System.out.println("Chk #2");
namesList.add("arg0");
paramsList.add(gtDept);
typesList.add(GenericType.class);
AdfmfJavaUtilities.invokeDataControlMethod("WLFNewActWS", null, "persistDepartments", namesList,
paramsList, typesList);
System.out.println("Chk #3");
}
} catch (SQLException e) {
Trace.log(Utility.FrameworkLogger, Level.SEVERE, this.getClass(), "syncDataFromOfflineToOnline",
e.getMessage());
} catch (Exception e) {
Trace.log(Utility.FrameworkLogger, Level.SEVERE, this.getClass(), "syncDataFromOfflineToOnline",
e.getStackTrace());
}
}

This may not be the answer to this question, but it may be the answer for someone searching for "Unable to read DataControl Usages, on loadDataControl for id"
In my case it is with Oracle MAF, but this also applies to Oracle ADF.
Your web service needs to be in your DataBindings.cpx file.
Something like:
<dataControlUsages>
<dc id="WLFNewActWS " path="mobile.WLFNewActWS "/>
</dataControlUsages>
I cheat and drag something from the WS into a one of pages and have jdeveloper add the record in DataBindings.cpx for me.

This occurs of the binding issue. Please create a reference/binding to 'WLFNewActWS' in your amx page. It will solve your problem...!

Related

MariaDB Connector J : autoReconnect does not wok for Basic Faillover

From https://mariadb.com/kb/en/library/about-mariadb-connector-j/, for option autoReconnect, When this parameter enabled when a Failover and Load Balancing Mode is not in use, the connector will simply try to reconnect to its host after a failure. This is referred to as Basic Failover.
But the problem is that the reconnect does not work after server failure. The test code is as follows:
#Test
public void waitTimeoutResultSetTest() throws SQLException, InterruptedException {
try (Connection connection = setBlankConnection("&autoReconnect=true")) {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1");
assertTrue(rs.next());
stmt.execute("set session wait_timeout=1");
Thread.sleep(3000); // Wait for the server to kill the connection
try {
rs = stmt.executeQuery("show databases;");
assertTrue(rs.next());
System.out.println("position 1");
} catch (SQLException e) {
//normal exception
System.out.println("position 2");
}
}
}
With autoReconnect, I think the expected result is that it will get to position 1, but actually it will get to position 2, with exception that "Connection reset by peer: socket write error."
My question is that whether the basic failover does not work, or my test code is wrong? I cannot find other information from web, could you kindly give me some explanation if you know about it?

Oracle OCI jdbc driver traps ORA-01403: no data found

I'm having a problem with the Oracle OCI jdbc driver not throwing ORA-01403 No data found exceptions. Relevant to Oracle 11 and 12. Maybe there is a property or something I need to set on the Connection object. The thin driver properly throws an exception, but the OCI driver just continues on with no error and updates 0 rows even though there is data in the table.
The output of the following program is:
Exception thrown from THIN Driver: ORA-01403: no data found
ORA-06512: at "EE.TABLEX_UPSERT_PRE", line 4
ORA-04088: error during execution of trigger 'EE.TABLEX_UPSERT_PRE'
rows updated from OCI Driver =0
public static void main(String[] args) {
try {
Driver d = (Driver) Class.forName("oracle.jdbc.OracleDriver").newInstance();
Properties info = new Properties();
info.put("user", "me");
info.put("password", "mypwd");
Connection thinConnection = d.connect("jdbc:oracle:thin:#host:1521:DEV",info);
Connection ociConnection = d.connect("jdbc:oracle:oci:#DEV",info);
try {
Statement s = thinConnection.createStatement();
s.execute("UPDATE tablex SET name='newname'");
System.out.println("rows updated in THIN Driver =" + s.getUpdateCount());
}
catch (SQLException e) {
System.out.println("Exception thrown from THIN Driver: " + e.getMessage());
}
try {
Statement s = ociConnection.createStatement();
s.execute("UPDATE tablex SET name='newname'");
System.out.println("rows updated from OCI Driver =" + s.getUpdateCount());
}
catch (SQLException e) {
System.out.println("Exception thrown from OCI Driver: " + e.getMessage());
}
}
catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
{////// SQL
CREATE TABLE TABLEX
(
NAME VARCHAR2(20)
);
INSERT INTO TABLEX(name) values('data1');
CREATE TABLE TABLEy
(
ID NUMBER
);
create or replace
TRIGGER TABLEX_UPSERT_PRE
BEFORE INSERT OR UPDATE ON TABLEX FOR EACH ROW
DECLARE
cid number;
BEGIN
select id into cid from tabley where id=0; -- INTENTIONAL No Data Found error
end;
}

How to close refcursor in spring when using simplejdbccall

I am using spring simpleJdbcCall to call oracle stored procedure and i am using oracle 11g .
I stumbled on a couple of posts which suggests there might be memory leak as the ref cursors are not properly closed by spring.
Is there anyway to explicitly close cursor while using spring simplejdbccall? or is increasing the oracle OPEN_CURSOR the only way out?.
I am planning to scale up my application to handle around one million transactions every hour .Any suggestions will be helpful.
Actually there is no such an issue with Spring JDBC. It closes all resources within finally after all execute. SimpleJdbcCall uses JdbcTemplate:
public <T> T execute(CallableStatementCreator csc, CallableStatementCallback<T> action)
throws DataAccessException {
try {
...
}
catch (SQLException ex) {
...
}
finally {
if (csc instanceof ParameterDisposer) {
((ParameterDisposer) csc).cleanupParameters();
}
JdbcUtils.closeStatement(cs);
DataSourceUtils.releaseConnection(con, getDataSource());
}
}
The same for ResultSet OUT parameters:
protected Map<String, Object> processResultSet(ResultSet rs, ResultSetSupportingSqlParameter param) throws SQLException {
....
finally {
JdbcUtils.closeResultSet(rs);
}
return returnedResults;
}
From other side I have a big experience with Spring JDBC and Oracle in high-loaded systems and want to say that we noticed enough open resources on Oracle with at peak loads, but they have been released properly after that.
Although we used JBOSS Pooled DataSource and its TransactionMaanger
I use CallableStatement directly and I can release statements and connections quickly and safely, try both methods and measure memory consumption, it worked perfectly for me to solve memory consumption and connection retention problems that proved many waiting and rejection of connections the applications.
try {
log.info("**** RepositoryPSostgres.getAllProducts ******** ");
Connection conn = jdbcTemplate.getDataSource().getConnection();
conn.setAutoCommit(false);
// Procedure call.
CallableStatement proc = conn.prepareCall("{? = call get_all_products() }");
proc.registerOutParameter(1, Types.OTHER);
proc.execute();
ResultSet results = (ResultSet) proc.getObject(1);
**proc.close();
proc.isClosed();
conn.close();**
ArrayList <Products> resp = new ArrayList <Products>();
while (results.next()) {
Products resp1 = new Products();
resp1.setId(results.getInt("id"));
resp1.setName((String) results.getString("name"));
resp1.setPrice((BigDecimal) results.getBigDecimal("price"));
resp.add(resp1);
log.info("***" + results.getInt("id") + "***** ");
log.info("***" + results.getString("name") + "***** ");
log.info("***" + results.getBigDecimal("price") + "***** ");
}
results.close();
return resp;
} catch (Exception e) {
e.printStackTrace();
log.error(new StringBuffer("Error en transaccion en saldo CashPooling : ").append(e.getLocalizedMessage()).toString());
return null;
}

jt400 write record throws "CPF5035 Data mapping error"

I have a table with many, many fields. When trying to insert data with jt400 (flei00.write(newrec);) I get error CPF5035 Data mapping error on member FLEI00.. Even when trying to insert empty or nearly empty record, the error message is the same. Is there a way to get know, which field is causing the problem? I've been fighting with it a whole day and have no more idea what to check :-(. Any help (e.g. where to look for more info) will be appreciated.
On IBM i, the job log is THE place to find details about errors occurring in a given job. In the case of JT400 jobs, the JT400 app connects via sockets to a server job. Typically, there are a bunch of these jobs 'prestarted', waiting for a connection. This can be difficult to navigate if you're not accustomed to the 5250 interface.
Here's a JT400 program that gets the job log messages for you. If you run this in the same session that you are getting the error in you should see the details about what field is causing the issue.
import java.util.*;
import com.ibm.as400.access.*;
public class TestJobLog {
public static void main(String[] args) {
int i = 0;
try {
AS400 system = new AS400();
JobLog jobLog = new JobLog(system);
// what attributes?
jobLog.clearAttributesToRetrieve();
jobLog.addAttributeToRetrieve(JobLog.MESSAGE_WITH_REPLACEMENT_DATA);
jobLog.addAttributeToRetrieve(JobLog.MESSAGE_HELP_WITH_REPLACEMENT_DATA);
// load the messages
jobLog.load();
// Create a list and subset it
Enumeration list = jobLog.getMessages();
System.out.println("There are " + Integer.toString(jobLog.getLength()) + " messages.");
while (list.hasMoreElements()) {
i++;
QueuedMessage message = (QueuedMessage) list.nextElement();
String text = message.getID() +
" " + message.getType() +
" " + message.getText() + "\n" +
" " + message.getMessageHelpReplacement() + "\n";
System.out.println(Integer.toString(i) + " " + text);
}
jobLog.close();
System.exit(0);
} catch (Exception e) {
System.out.println(e);
}
}
}

How to programmatically get provisioning resources with oim 11g client api

I'm using the oracle OIM 11g api (in packages oracle.iam). I use the class oracle.iam.platform.OIMClient to get all the OIM client services like UserManager.
I need to find the resources got with the provisioning workflows. Which service can I use? How can I do with the OIM api?
The method below should export all resources into an XML file-
public Boolean export() {
Boolean result = true;
String export_object="Resource";
try {
FileWriter fstream = new FileWriter("OIMResources.xml");
BufferedWriter out = new BufferedWriter(fstream);
tcExportOperationsIntf moExportUtility = (tcExportOperationsIntf) ioUtilityFactory.getUtility("Thor.API.Operations.tcExportOperationsIntf");
Collection<RootObject> lstObjects = moExportUtility.findObjects(export_object, "*");
System.out.println(lstObjects);
lstObjects.addAll(moExportUtility.getDependencies(lstObjects));
lstObjects.addAll(moExportUtility.retrieveChildren(lstObjects));
lstObjects.addAll(moExportUtility.retrieveDependencyTree(lstObjects));
String s = moExportUtility.getExportXML(lstObjects, "*");
out.write(s);
LOG.info(Resource + "Objects successfully exported");
out.close();
} catch (Exception e) {
LOG.log(Level.SEVERE, "Exception occured while exporting OIM object" + Resource, e);
}
return result;
}

Resources