Adapter is not working as expected in my test device - ibm-mobilefirst

i have started to develop and implement adapter successfully in ibm web console and also android mobile browser simulator. But when installed in my real test device the adapter is not able to connect to the database. i do no where to find error log in mobile.
currentPage={};
currentPage.init = function() {
WL.Logger.debug("Page2 :: init");
};
currentPage.back = function(){
WL.Logger.debug("Page2 :: back");
$("#pagePort").load(pagesHistory.pop());
};
function loadSQLRecords(){
var invocationData = {
adapter : 'dball',
procedure : 'getDball',
parameters : []
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadSQLQuerySuccess,
onFailure : loadSQLQueryFailure
});
}
function loadSQLQuerySuccess(result){
alert ("success");
if (result.invocationResult.resultSet.length > 0)
displayFeeds(result.invocationResult.resultSet);
else
alert("failure here");
}
function loadSQLQueryFailure() {
alert ("failure");
}
function displayFeeds(result){
for (var i = 0; i < result.length; i++) {
$("#mytable").append("<tr><td>" + result[i].EMPID + "</td></tr>");
$("#mytable").append("<tr><td>" + result[i].EMPNAME + "</td></tr>");
$("#mytable").append("<tr><td>" + result[i].EMAILID + "</td></tr>");
}
}
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Licensed Materials - Property of IBM
5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
- <wl:adapter name="dball" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wl="http://www.ibm.com/mfp/integration" xmlns:sql="http://www.ibm.com/mfp/integration/sql">
<displayName>dball</displayName>
<description>dball</description>
- <connectivity>
- <connectionPolicy xsi:type="sql:SQLConnectionPolicy">
- <!-- Example for using a JNDI data source, replace with actual data source name
-->
- <!-- <dataSourceJNDIName>java:/data-source-jndi-name</dataSourceJNDIName>
-->
- <!-- Example for using MySQL connector, do not forget to put the MySQL connector library in the project's lib folder
-->
- <dataSourceDefinition>
<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
<url>jdbc:oracle:thin:#192.168.*.***:****:****</url>
<user>****</user>
<password>****</password>
</dataSourceDefinition>
</connectionPolicy>
</connectivity>
- <!-- Replace this with appropriate procedures
-->
<procedure name="getDball" />
<procedure name="addDball" />
</wl:adapter>

I took your project and changed the database settings to connect to mine instead (MySQL). The connection was successful and data was saved in the database.
Even if forcing it to fail, it does not fail with "Error is UNDEFINED", so I still believe this does have to do with your Oracle database settings. 192.168 is internal IP address - it is not available as a public IP address even if you think it is. It does not. You need to check this with your IT department and get the real IP address of your database.

Related

Cross reference from DSL to EMF Ecore model not working in LSP setup

I have a DSL language where we need to cross-refer EAttribute that are defined in a separate file.
This works fine in the eclipse plugin setup but it is not working in the LSP setup based on Vscode/Theia client.
Grammar Snippet -
Atomic returns Expression:
{IntConstant} value=INT |
{StringConstant} value=STRING |
{BoolConstant} value=('true' | 'false') |
{VariableRef} variable=[ecore::EAttribute|QualifiedName];
Example -
DSL file - test.mexpression
iota=1
iota is a variable which is defined in a separate file - variables.ecore
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="vari" nsURI="vvvv" nsPrefix="var">
<eClassifiers xsi:type="ecore:EClass" name="Variables">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="iota" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="Cars" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral=""/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Car">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="Model" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
Language client Snippet -
export function activate(context: ExtensionContext) {
// The server is a started as a separate app and listens on port 5007
let connectionInfo = {
port: 5008
};
let serverOptions = () => {
// Connect to language server via socket
let socket = net.connect(connectionInfo);
let result: StreamInfo = {
writer: socket,
reader: socket
};
return Promise.resolve(result);
};
let clientOptions: LanguageClientOptions = {
documentSelector: ['mexpression','ecore'],
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/*.*')
}
};
// Create the language client and start the client.
let lc = new LanguageClient('Xtext Server', serverOptions, clientOptions);
Am I missing something here ? or We have to create a standalone setup for variable file & register it via service providers to make it work in LSP environment.

Mobilefirst 8.0 cordova apps not able to connect server

POC for MobileFirst 8.0 version apps and I created sample apps and maven based adapter. Finally I invoked that adapter index.js file to call the adapter its working fine when I used browser simulator but its not working while I installed android device I got below that error in android LOGCAT,
[ERROR:xwalk_autofill_client.cc(121)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
How to resolve this issue.
please find the implementation below.
adapter
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<mfp:adapter name="HttpAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mfp="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>HttpAdapter</displayName>
<description>HttpAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>https</protocol>
<domain>mobilefirstplatform.ibmcloud.com</domain>
<port>443</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
</connectionPolicy>
</connectivity>
<procedure name="getFeed" secured="false"/>
<procedure name="unprotected" secured="false"/>
</mfp:adapter>
adapter implementation
function getFeed(tag) {
var input = {
method : 'get',
returnedContentType : 'xml',
path : getPath(tag)
};
return MFP.Server.invokeHttp(input);
}
/**
* Helper function to build the URL path.
*/
function getPath(tag){
if(tag === undefined || tag === ''){
return 'feed.xml';
} else {
return 'blog/atom/' + tag + '.xml';
}
}
/**
* #returns ok
*/
function unprotected(param) {
return {result : "Hello from unprotected resource"};
}
apps implementation
function myFunction(){
console.log('==================== inside calling ==================');
var resourceRequest = new WLResourceRequest(
"/adapters/HttpAdapter/getFeed",
WLResourceRequest.GET,3000
);
resourceRequest.setQueryParameter("params", "['']");
resourceRequest.send().then(
function(response) {
alert("------- success " +JSON.stringify(response));
},
function() {
alert("----------- >>> errror ------");
}
)
}
Please use mata tag in your HTML file it will resolve your issues for android.
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />

Mobilefirst 7.1 Adapter - CLI

I am using MobileFirst CLI 7.1. I am following the tutorial (https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/hello-world/integrating-mfpf-sdk-in-cordova-applications/) and almost everything works fine. I am using the RSSAdapter and I keep getting the following error when I deploy the app to the phone:
status : 500
responseHeaders {5}
X-Powered-By : Servlet/3.0
Content-Type : application/json
Content-Length : 430
Connection : Close
Date : Mon, 24 Aug 2015 09:55:41 GMT
responseText : {\"statusCode\":404,\"errors\":[\"White spaces are required between publicId and systemId.\",\"Failed to parse the payload from backend (procedure: HttpRequest)\"],\"isSuccessful\":false,\"statusReason\":\"Not Found\",\"responseHeaders\":{\"Date\":\"Mon, 24 Aug 2015 09:55:41 GMT\",\"Content-Length\":\"149\",\"Content-Type\":\"text/html;charset=UTF-8\",\"Connection\":\"close\",\"Server\":\"FeedsPortal\"},\"warnings\":[],\"totalTime\":276,\"responseTime\":244,\"info\":[]}
responseJSON {9}
statusCode : 404
errors [2]
0 : White spaces are required between publicId and systemId.
1 : Failed to parse the payload from backend (procedure: HttpRequest)
isSuccessful : false
statusReason : Not Found
responseHeaders {5}
warnings [0]
totalTime : 276
responseTime : 244
info [0]
invocationContext : null
This is how my code looks like:
--- RSSAdapter.xml ----
<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="RSSAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>RSSAdapter</displayName>
<description>RSSAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>rss.cnn.com</domain>
<port>80</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
</connectivity>
<procedure name="getStories"/>
<procedure name="getStoriesFiltered"/>
</wl:adapter>
----- RSSAdapter-impl.js ---
function getStories(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'xml',
path : path
};
return WL.Server.invokeHttp(input);
}
function getStoriesFiltered(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'xml',
path : path,
transformation : {
type : 'xslFile',
xslFile : 'filtered.xsl'
}
};
return WL.Server.invokeHttp(input);
}
function getPath(interest) {
if (interest == undefined || interest == '') {
interest = '';
}else {
interest = '_' + interest;
}
return 'rss/edition' + interest + '.rss';
}
--- JS ---
function invokeAdapter() {
var resourceRequest = new WLResourceRequest(
"/adapters/RSSAdapter/getStories",
WLResourceRequest.GET);
resourceRequest.send().then(success,error);
}
function success(res) {
console.log('Success');
console.log('res ', res);
/*console.log('Text ', res.responseJSON.rss.channel.item.length);*/
console.log('Text ', res.responseJSON);
alert("Total RSS Feed items received:"+res.responseJSON);
}
function error(error) {
console.log('Nei');
console.log('error ', JSON.stringify(error));
alert("Response error"+ JSON.stringify(error));
}
Update: in recent iFixes, the default adapter was changed to no longer point to CNN. If you haven't, please upgrade.
There is nothing wrong with your project. For whatever reason it appears that the default adapter created has stopped working with the CNN website; it is being investigated.
In the meanwhile you can either use an adapter from a different project (that is working with the engadget website), or create your own.
See for example the adapter that is provided as part of the Starter Application sample (you can copy the adapter folder to your MobileFirst project and use "mfp push" to deploy it to the server; make sure to update the adapter and procedure names in your applicative code).

how to invoke adapters hybrid application MobileFirst Platform 6.3

i have some error
Caused by: FWLSE0099E: An error occurred while invoking procedure [project EMoney]InquiryAdapters/HttpRequestFWLSE0100E: parameters: [project EMoney]
Http request failed: org.apache.http.conn.HttpHostConnectException: Connect to rss.cnn.com:80 [rss.cnn.com/74.125.200.121] failed: Connection timed out: connect
FWLSE0101E: Caused by: [project EMoney]org.apache.http.conn.HttpHostConnectException: Connect to rss.cnn.com:80 [rss.cnn.com/74.125.200.121] failed: Connection timed out: connectjava.lang.RuntimeException: Http request failed: org.apache.http.conn.HttpHostConnectException: Connect to rss.cnn.com:80 [rss.cnn.com/74.125.200.121] failed: Connection timed out: connect
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to rss.cnn.com:80 [rss.cnn.com/74.125.200.121] failed: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
inquiryAdapters.xml
<wl:adapter name="InquiryAdapters"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>InquiryAdapters</displayName>
<description>InquiryAdapters</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>rss.cnn.com</domain>
<port>80</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
</connectivity>
<procedure name="getStories"/>
<procedure name="getStoriesFiltered"/>
<procedure name="getFeedsFiltered"/>
</wl:adapter>
inquiryAdapters.impl
function getStories(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'xml',
path : path
};
return WL.Server.invokeHttp(input);}
function getStoriesFiltered(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'xml',
path : path,
transformation : {
type : 'xslFile',
xslFile : 'filtered.xsl'
}
};
return WL.Server.invokeHttp(input);}
function getFeedsFiltered() {
var input = {
method : 'get',
returnedContentType : 'xml',
path : "rss.xml",
transformation : {
type : 'xslFile',
xslFile : 'filtered.xsl'
}
};
return WL.Server.invokeHttp(input);}
function getPath(interest) {
if (interest == undefined || interest == '') {
interest = '';
}else {
interest = '_' + interest;
}
return 'rss/edition' + interest + '.rss';}
when i want to invoke the adapters (http adapters).
If you have followed the next steps yet you get a "Connection timed out" error, you likely have a network issue unrelated to MobileFirst Platform 6.3: check for any firewalls that prevent your connection to arrive to CNN.com
Created a new project
Create a new HTTP adapter
Right-click on adapter folder > Deploy MobileFirst Adapter
Right-click on adapter folder > Call MobileFirst Adapter
Now a browser window with the response should've opened.

How to solve jms activemq error?

I have downloaded sample work light project from getting started tutorials that implements JMS adapter with activeMQ Messsage broker. I got the following error.
[ERROR ] FWLSE0005W: JMS connection exception received:
org.apache.activemq.ActiveMQConnectionFactory cannot be cast to
javax.jms.ConnectionFactory. Closing the connection. [project Adapters].
I don't know what jars needed to add in this project.I have added activemq-all-5.3.0
only.
JMSAdapter.xml:
<displayName>JMSAdapter</displayName>
<description>JMSAdapter</description>
<connectivity>
<connectionPolicy xsi:type="jms:JMSConnectionPolicyType">
<!-- uncomment this if you want to use an external JNDI repository
<namingConnection url="MY_JNDI_URL"
initialContextFactory="providers_intial_context_factory_class_name"
user="JNDIUserName"
password="JNDIPassword"/>
-->
<namingConnection url="tcp:/9.148.225.170:61616"
initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
user="admin"
password="admin"/>
<jmsConnection
connectionFactory="ConnectionFactory"
user="admin"
password="admin"
/>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="10"/>
</connectivity>
<procedure name="writeMessage"/>
<procedure name="readMessage"/>
<procedure name="readAllMessages"/>
</wl:adapter>
JMSAdapter-impl.xml:
// The name of the JMS Administered object that you have already placed in the
repository of your choice
var DESTINATION = "dynamicQueues/IBMWorklight";
/**
* Write a message to the destination with a user defined property.
* #param messagebody
*
* #returns the result which includes the MessageID
*/
function writeMessage(messagebody) {
var inputData = {
destination: "dynamicQueues/IBMWorklight",
message:{
body: messagebody,
properties:{
MY_USER_PROPERTY:123456
}
}
};
return WL.Server.writeJMSMessage(inputData);
}
/**
* Read a message from the destination.
*
* #returns the message
*/
function readMessage() {
var result = WL.Server.readSingleJMSMessage({
destination: "dynamicQueues/IBMWorklight",
timeout: 60
});
/*var inputData = {
destination: "dynamicQueues/IBMWorklight",
timeout: 60
};
return WL.Server.readSingleJMSMessage(inputData);*/
return result;
}
/**
*
* Write some messages to a queue then read all available messages from the
destination.
* #return - the read messages.
*/
function readAllMessages() {
// As this is a test module write some test messages by calling the above
function.
writeMessage();
writeMessage();
writeMessage();
var inputData = {
destination: DESTINATION,
timeout: 60
};
// Now call the JMSAdapter function to read all the messages that we just wrote
return WL.Server.readAllJMSMessages(inputData);
}
The jar files that need to be added to your project in case you are using ActiveMQ are :
activemq-client... (the rest of the name depends on your activeMQ version)
geronimo-j2ee... (the rest of the name depends on your activeMQ version)