Axis fault : faultString: java.io.IOException for suitetalk - lotus-notes

I am trying to use NetSuite's suiteTalk java api for writing an interface between our lotus notes system and NetSuite.
The first error thrown by the code was a class def not found error.
for :
sun/security.provider/sun.class
sun/security.provider/sun$1.class
sun/security.provider/NativePRNG.class
I figured out that rt.jar in lotus notes was actually missing this files. So I added these class files from the jdk1.6 i had downloaded separately. Once I fixed that I started getting axis.Faults error.
Here is the simple login code that I am trying to execute from lotus note agent:
public void loginTest(){
NetSuitePortType _port=null;
// In order to use SSL forwarding for SOAP message. Refer to FAQ for details
System.setProperty("axis.socketSecureFactory","org.apache.axis.components.net.SunFakeTrustSocketFactory");
// Locate the NetSuite web service
NetSuiteServiceLocator serviceLocator= new NetSuiteServiceLocator();
//Get the service port
try {
_port=serviceLocator.getNetSuitePort();
} catch (ServiceException e) {
System.out.println("Error in intializing GlobalSuiteTalkSetup");
e.printStackTrace();
}
// Setting client timeout to 2 hours for long running operatotions
((NetSuiteBindingStub) _port).setTimeout(60*60*1000*2);
try {
// Populate Passport object with all login information
Passport passport = new Passport();
RecordRef role = new RecordRef();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
passport.setEmail("username");
passport.setPassword("password.");
role.setInternalId("3");
passport.setRole(role);
passport.setAccount("111111");
// Login to NetSuite
System.out.print("\nLogging into NetSuite");
System.out.print(" Username: " + passport.getEmail());
System.out.print(" Account: " + passport.getAccount());
System.out.print(" password: " + passport.getPassword());
System.out.print(" role: " + passport.getRole());
Status status;
status = (_port.login(passport)).getStatus();
// Process the response
if (status.isIsSuccess() == true)
{
System.out.print("\nThe login was successful and a new session has been created.");
} else
{
// Should never get here since any problems with the
// login should have resulted in a SOAP fault
System.out.print("Login failed");
//System.out.print(getStatusDetails(status));
}
} catch (InvalidVersionFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidCredentialsFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InsufficientPermissionFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExceededRequestLimitFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnexpectedErrorFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAccountFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Error thrown by code:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.io.IOException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.io.IOException
at org.apache.axis.components.net.SunJSSESocketFactory.initFactory(SunJSSESocketFactory.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:79)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.netsuite.webservices.platform_2015_1.NetSuiteBindingStub.login(NetSuiteBindingStub.java:12799)
at Login.loginTest(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
{http://xml.apache.org/axis/}hostname:
java.io.IOException
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.netsuite.webservices.platform_2015_1.NetSuiteBindingStub.login(NetSuiteBindingStub.java:12799)
at Login.loginTest(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
Caused by: java.io.IOException
at org.apache.axis.components.net.SunJSSESocketFactory.initFactory(SunJSSESocketFactory.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:79)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
... 14 more

I found the solution for this issue. For anyone who might get similar issue can get some clue from this solution :
The issue was because of the following statement that I had put in the code.
System.setProperty("axis.socketSecureFactory","org.apache.axis.components.net.SunFakeTrustSocketFactory");
This statement is necessary when using Sun' JVM but since Lotus Notes uses IBM's JVM, setting axis.socketSecureFactory to org.apache.axis.components.net.SunFakeTrustSocketFactory made the system to look for Sun classes which not absent in IBM's JVM.
No need to add the missing classes from Sun JVM to rt.jat as I had done before. Just comment that statement and use the axis path available frpm NetSuite
Don't forget to put the patch in Note's /JVM/Lib/EXT folder and restart Lotus Notes before trying to run the code..

Related

How to abort a Task in JavaFX?

Is it possible to abort a Task in JavaFX? My Task could run into situations where I want to cancel the rest of the operations within it.
I would need to return a value, somehow, so I can handle the cause of the abort in the JFX Application Thread.
Most of the related answers I've seen refer to handling an already-canceled Task, but now how to manually cancel it from within the Task itself.
The cancel() method seems to have no effect as both messages below are displayed:
public class LoadingTask<Void> extends Task {
#Override
protected Object call() throws Exception {
Connection connection;
// ** Connect to server ** //
updateMessage("Contacting server ...");
try {
connection = DataFiles.getConnection();
} catch (SQLException ex) {
updateMessage("ERROR: " + ex.getMessage());
ex.printStackTrace();
cancel();
return null;
}
// ** Check user access ** //
updateMessage("Verifying user access ...");
try {
String username = System.getProperty("user.name");
ResultSet resultSet = connection.createStatement().executeQuery(
SqlQueries.SELECT_USER.replace("%USERNAME%", username));
// If user doesn't exist, block access
if (!resultSet.next()) {
}
} catch (SQLException ex) {
}
return null;
}
}
And example would be greatly appreciated.
Why not just let the task go into a FAILED state if it fails? All you need (I also corrected the errors with the type of the task and return type of the call method) is
public class LoadingTask extends Task<Void> {
#Override
protected Void call() throws Exception {
Connection connection;
// ** Connect to server ** //
updateMessage("Contacting server ...");
connection = DataFiles.getConnection();
// ** Check user access ** //
updateMessage("Verifying user access ...");
String username = System.getProperty("user.name");
ResultSet resultSet = connection.createStatement().executeQuery(
SqlQueries.SELECT_USER.replace("%USERNAME%", username));
// I am not at all sure what this is supposed to do....
// If user doesn't exist, block access
if (!resultSet.next()) {
}
return null;
}
}
Now if an exception is thrown by DataFiles.getConnection(), the call method terminates immediately with an exception (the remained is not executed) and the task enters a FAILED state. If you need access to the exception in the case that something goes wrong, you can do:
LoadingTask loadingTask = new LoadingTask();
loadingTask.setOnFailed(e -> {
Throwable exc = loadingTask.getException();
// do whatever you need with exc, e.g. log it, inform user, etc
});
loadingTask.setOnSucceeded(e -> {
// whatever you need to do when the user logs in...
});
myExecutor.execute(loadingTask);

Library for Android httpPost

It's kinda frustating me... I tried to create httpPost
code :
private void makePostRequest() {
HttpClient httpClient = new DefaultHttpClient();
// replace with your url
HttpPost httpPost = new HttpPost("www.example.com");
//Post Data
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("username", "test_user"));
nameValuePair.add(new BasicNameValuePair("password", "123456789"));
//Encoding POST data
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
// log exception
e.printStackTrace();
}
//making POST request.
try {
HttpResponse response = httpClient.execute(httpPost);
// write response to log
Log.d("Http Post Response:", response.toString());
} catch (ClientProtocolException e) {
// Log exception
e.printStackTrace();
} catch (IOException e) {
// Log exception
e.printStackTrace();
}
}
But always ended Can't resolve symbol. I used Android Studio latest update, I already downloaded http://mirror.metrocast.net/apache//httpcomponents/httpclient/binary/httpcomponents-client-4.5-bin.zip from hc.apache.org and copy jar file (httpclient-4.5.jar and httpcore-4.4.1.jar) to library and add it as a library but somehow it doesn't work.
It gives error :
Error:Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK META-INF/DEPENDENCIES File 1: Z:\Learning\Android-2\Live-code-AS\SendLocation\app\libs\httpcore-4.4.1.jar
File 2:
Z:\Learning\Android-2\Live-code-AS\SendLocation\app\libs\httpclient-4.5.jar
if I delete one of the jar file then I'll get "can't resolve HttpClient or NameValuePair"
Please help.... Thanks before.
You have some duplicate files in your dependencies. To solve it, open your build.gradle in which you define your dependencies and add the packagingOptions-section within the android-section:
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}

Out of Memory exception when retrieving Images from Website Link url

Hello i am creating an android application , and i have on my website about more than 1500 photos that i want to display on a ListView using an Array adapter
One solution i found is downloading the images from a URL link i have .
Here is the stacktrace
My problem is that i get an Out of Memory exception
: E/AndroidRuntime(1123): FATAL EXCEPTION: Thread-79
: E/AndroidRuntime(1123): Process:
android.quotations, PID: 1123
** : E/AndroidRuntime(1123): java.lang.OutOfMemoryError : E/AndroidRuntime(1123):
at** android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
: E/AndroidRuntime(1123): at
android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:613)
: E/AndroidRuntime(1123): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:589)
: E/AndroidRuntime(1123): at
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
: E/AndroidRuntime(1123): at
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
: E/AndroidRuntime(1123): at
android.graphics.drawable.Drawable.createFromStream(Drawable.java:791)
: E/AndroidRuntime(1123): at
com.c.fragments.AuthorImageFragment.loadImageFromWebOperations(AuthorImageFragment.java:77)
: E/AndroidRuntime(1123): at
com.c.fragments.AuthorImageFragment.access$0(AuthorImageFragment.java:72)
: E/AndroidRuntime(1123): at
com.c.fragments.AuthorImageFragment$1.run(AuthorImageFragment.java:109)
and here is the code from the adapter:
private ImageView imageDetail(View v, int resId, Drawable drawable) {
ImageView value = (ImageView) v.findViewById(resId);
BitmapDrawable draw = (BitmapDrawable)drawable;
// value.setAdjustViewBounds(true);
Bitmap bmp=draw.getBitmap();
// value.setLayoutParams(new android.widget.TableRow.LayoutParams((width/4), (height/4)));
value.setImageBitmap(bmp);
return value;
}
Thread networkThread = new Thread() {
#Override
public void run() {
Author author;
// This is just a test i want to do :)))
for (int i=0;i<=1000;i++){
author=new Author();
try {
author.setAuthorImage(loadImageFromWebOperations("http://mySite/Directory/images/"+5+".jpg",i));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
list.add(author);
}
getActivity().runOnUiThread (new Runnable(){
public void run() {
adapter= new AuthorImageAdapter(getActivity().getApplicationContext(),list);
}
});
}
}; networkThread.start();
****Here is the Method i use to retrieve the Image****
private Drawable loadImageFromWebOperations(String url,int id) throws MalformedURLException, IOException
{ InputStream is=null;
try{
is = (InputStream) new java.net.URL(url).getContent();
LOGGER.info("Drawable -----");
Drawable d = Drawable.createFromStream(is, id+".jpg");
return d;
}catch (Exception e) {
// log Exception
LOGGER.info("Exception "+e.toString());
return null;
}
finally {
if (is!=null){
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
LOGGER.info("Exception "+e.toString());
// log Exception
return null;
}
}
}
}
any help would be appreciated ..
Best regards :)))
Now to help more i will add the code i use to retrieve the images .
There's no way you're going to be able to hold that many images in memory. I'd suggest that you download the images to local file storage and then in your Adapter when you want to actually draw the item that has the image, you should kick off a Loader that will load the image from disk on-demand. Sorry, there's just not enough memory to store that many images at once.
A more advanced strategy is to insert a cache using WeakReferences into the loading process. You load the image from disk and insert into something like a HashMap> and see if the image you want is in there first and if not, then do a load from disk as you normally would.
If you want to get architecturally really fancy what happens is the WeakReference cache I list above, try to load from disk, but if the file isn't present on disk only then load from the network. This then becomes a two-tier cache memory, then disk, before finally hitting the web.

Failed to connect [10048]

I've got this code on a button, when I press it I get the Error:
Error: Exception connecting to NXT.
Caused by lejos.pc.comm.NXTCommException: Open of NXT failed.
at lejos.pc.comm.NXTCommBluecove.open(NXTCommBluecove.java:136)
Caused by javax.bluetooth.BluetoothConnectionException: Failed to connect; [10048]
Only one usage of each socket address (protocol/network address/port) is normally permitted.
at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method)
Failed to connect to any NXT
I am posting because it was working fine yesterday but seems not to be working today.
btnConnectBot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (Cnt1){
try {
conn.close();
Cnt1=!Cnt1;
txtConnState.setText("Off");
txtConnState.setForeground(Color.RED);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else{
conn.addLogListener(new NXTCommLogListener() {
public void logEvent(String message) {
System.out.println(message);
}
public void logEvent(Throwable throwable) {
System.err.println(throwable.getMessage());
}
});
conn.setDebug(true);
if (!conn.connectTo(txtBotName.getText(), NXTComm.LCP)) {
System.err.println("Fallo de conexión");
txtConnState.setText("Off");
txtConnState.setForeground(Color.RED);
System.exit(1);
}
Cnt1=!Cnt1;
txtConnState.setText("On");
txtConnState.setForeground(Color.GREEN);
if (chckbxLock_2.isSelected()){
btnConnectBot_2.doClick();
}
if (chckbxLock_1.isSelected()){
btnConnectBot_1.doClick();
}
}
}
});
According to my research this is because the bluetooth port being used is being accessed by more than one instance. But I don't see how this happens in this code.
Do you have a Bluetooth virtual COM port configured for the remote device? Maybe it is opened by some program...
Or, does the error occur the first time you run your program? Are there any old copies of your program running -- check in taskmgr.exe

Unable to open camera on samsung phone in j2me

I have written following piece of code. It is used to create camera player. I tested it on nokia phones. It's working fine and I am able to see camera and use its functionality.
But the issue is that when the code is tested on samsung phone it throws Media exception and eventually have to make an exit from the application. Due to this code, my inbuilt camera functionality (i.e. on samsung phone) also stops working. So what's the reason to it?
public void startCamera()
{
try
{
try
{
// if player==null
player = createPlayer();
}
catch (Exception ex)
{
ex.printStackTrace();
ErrorDialog.show(ex, "We are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
try
{
player.realize();
player.prefetch();
}
catch (MediaException ex)
{
ex.printStackTrace();
ErrorDialog.show(ex, "We are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
//Grab the video control and set it to the current display.
videoControl = (VideoControl)(player.getControl("VideoControl"));
if (videoControl == null)
{
//discardPlayer();
stopCamera();
ErrorDialog.show("Unsupported:\n"+
"Can't get video control\n"+
"We are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
mediaComponent = new MediaComponent(player);
mediaComponent.setFocusable(false);
m_cameraScreen.showCamera(mediaComponent);
start();
}
catch(Exception ex)
{
ex.printStackTrace();
//discardPlayer();
stopCamera();
ErrorDialog.show("Sorry,Resources unavailable.\nWe are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
}
private Player createPlayer()throws MediaException, Exception
{
Player mPlayer = null;
// try capture://image first for series 40 phones
try
{
mPlayer = Manager.createPlayer("capture://image");
}
catch (Exception e)
{
e.printStackTrace();
}
catch (Error e)
{
e.printStackTrace();
}
// if capture://image failed, try capture://video
if (mPlayer == null)
{
try
{
mPlayer = Manager.createPlayer("capture://video");
}
catch (Exception e)
{
e.printStackTrace();
throw new MediaException("Sorry,Resources unavailable.");
}
}
if(mPlayer == null)
throw new Exception("Sorry,Resources unavailable.");
return mPlayer;
}
First things first, you have to realize that printStackTrace() is pretty much useless outside of the emulator unless you are using a Symbian phone.
You can also use java.lang.Throwable instead of separating Exception and Error
You can figure out exactly what happens by gathering information as a String and appending it to a simple lcdui Form while you are testing:
try {
// do something that could potentially fail
} catch (Throwable th) {
myDebugLcduiForm.append("potential failure number xx." + th + th.getMessage());
// if necessary, throw a new RuntimeException
}
You might want to update/repost your question once you know exactly what line of code throws what exception.

Resources