Printing a hashtable to screen, Server & Client (Java & CORBA)
Hi all,
I have written a server method that prints a hashtable's contents to screen:
public void viewAllEquipment () throws noEquipmentInTable {
// Does any equipment exist?
if (equipmentList.isEmpty() == true) {
throw new noEquipmentInTable();
System.out.println("The equipment list is as follows: ");
Enumeration tableEntries = equipmentList.keys();
int i = 1;
while (tableEntries.hasMoreElements()) {
String names = (String) tableEntries.nextElement();
System.out.print(i + ". Name = " + names + ", Description = " + equipmentList.get(names));
i++;
}The Client uses simple code to call this method:
hireCompanyServant.viewAllEquipment();As I'm sure you're probably aware, the Hashtable's contents gets printed to the Server screen not the Client screen! How can I get it printing on the Client instead? I'm unsure whether returning a value via the method would work, and can't think of any other way to do this.
Any help would be greatly appreciated.
Thanks
Edited by: JonBetts2004 on Mar 7, 2008 5:14 AM
Haha, ok sorry, will do. It's all command-line based, CORBA client-sever model.
Client: A file/program that implements and calls methods given by the Server.
Server: A file/program that contains methods that can be called by other clients/servers.
Screen: command line interface.
As it is a CORBA implementation, an ORB is started, then the Java Server is started, and finally the Java Client is run in the command prompt, which shows a list of actions to take (add equipment, edit equipment, view equipment, etc).
Sorry if that's too vague, I find these things hard to explain.
But basically, the 'client' makes use of the viewAllEquipment method provided by the 'server', which prints the contents of a hashtable to the command line. It is printed to the Server's command line rather than the Client's. I need it printing to the Client's command line, but am unsure what is the best way to approach it. Changing the method from a void to a string, and then returning a value? Or something else?
thanks
Similar Messages
-
Server /Client Java/C++
I was asked to implement a client/server application that constrained by size of 10 MB or less with JRE included,As this application is targeted to single OS users only so the solution was to use C++ instead but still on the other hand the server can use the advantage of Java networking and JDBC so anyway the question is:
Can I implement server in Java* and implement client using C++*,I haven't tried it yet but i need to know if it is possible.A browser like Firefox and IE is a stand alone program you install on a desktop and can use without connectivity to the internet. While a browser can run any web application using code from the internet, a browser is not run from a server cannot run in another browser.
A web application is one which is deployed and typically used only on the web and usually runs inside a browser, but the browser is a desktop app.
if you mean that i already told my supervisor that but he still not convinced We cannot say what your supervisor will approve of as this is a not question of what is technically possible. You have to ask him/her as your supervisor is setting the requirements. -
Not able to connect to Lotus Domino server using java/corba
Hi
I am new to Lotus Domino server and Java.
I have INstalled Lotus Domino server5 on 1 machine and was successful in installing the Lotus client on another machine.
Throught the lotus client i am able to connect to the server and send and receive the mails.
Now I want to connect to the domino server using the Lotus Domino Tolkit for Java/Corba.
In this Toolkit they have given the sample code program ..
if I run the code I am getting the error
java.io.FileNotFoundException: http://<IPADDRESS>/diiop_ior.txtjava.io.FileNotFoundException: http://<IPADDRESS>/diiop_ior.txt
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:691)
at java.net.URL.openStream(URL.java:942)
at lotus.domino.NotesFactory.getIOR(NotesFactory.java:314)
at lotus.domino.NotesFactory.createSession(NotesFactory.java:66)
at IntroCorbaApp.run(IntroCorbaApp.java:65)
at java.lang.Thread.run(Thread.java:539)
lotus.domino.NotesException: Could not get IOR from HTTP Server
lotus.domino.NotesException
at lotus.domino.NotesFactory.getIOR(NotesFactory.java:344)
at lotus.domino.NotesFactory.createSession(NotesFactory.java:66)
at IntroCorbaApp.run(IntroCorbaApp.java:65)
at java.lang.Thread.run(Thread.java:539)
I also tried to find this file in the Domino server directory.
The file exists in drive:\LotusServer\Domino\Data\Domino\HTML directory..
I am not getting what exactly is the Problem
Plz any one help me in this regard..
thanks in advanceYou should be able to access the diiop_ior.txt file from browser without authentication,only then it will work. This file should not
be protected. -
Java Server/Client Applicaton - problem with sending data back
Hello!
I'm trying to write a small server/client chat application in Java. It's server with availability to accept connections from many clients and it's app just for fun... However, I've come up against a huge problem: everything what clients send, arrives to server (I'm sure about that because it is displayed on the Server Application screen) and then server should send it back to all clients but it doesn't work. I have no faintest idea what causes this problem. Maybe you can help me?
Here is my server app code:
import java.net.*;
import java.util.*;
import java.io.*;
* @author Robin
public class Server {
ServerSocket serw = null;
Socket socket = null;
String line = null;
Vector<ClientThread> Watki = new Vector();
ClientThread watek = null;
public Server(int port) {
try {
serw = new ServerSocket(port);
line = "";
while(true) {
System.out.println("Running. Waiting for client to connect...");
socket = serw.accept();
System.out.println("Connected with:\n" + socket.getInetAddress() + "\n");
watek = new ClientThread(socket);
Watki.addElement(watek);
Watki.firstElement().Send("doszlo?");
}catch (IOException e) {
System.out.println("BLAD: " + e);
public void sendToAll(String s) {
for(int i = 0; i < Watki.size(); i++) {
Watki.elementAt(i).Send(s);
public class ClientThread extends Thread {
Socket socket;
DataInputStream in = null;
DataOutputStream out = null;
String line = null;
public ClientThread(Socket s) {
try {
this.socket = s;
in = new DataInputStream(s.getInputStream());
out = new DataOutputStream(s.getOutputStream());
start();
}catch (IOException e) {
System.out.println("BLAD: " + e);
public void Send(String s) {
try {
out.writeUTF(s);
}catch (IOException e) {
System.out.println("BLAD: " + e);
public void run() {
try {
line = "";
while (true) {
line = in.readUTF();
System.out.println(line);
sendToAll(line);
}catch (IOException e) {
System.out.println("BLAD: " + e);
public static void main(String[] args) {
Server serwer = new Server(5000);
}And here is client app code:
import java.net.*;
import java.util.*;
import java.io.*;
* @author Robin
public class Client implements Runnable {
Socket socket = null;
BufferedReader keyIn = new BufferedReader(new InputStreamReader(System.in));
DataInputStream in = null;
DataOutputStream out = null;
String line = null;
public Client(String host, int port) {
try {
System.out.println("Connecting to " + host + ":" + port);
socket = new Socket(host, port);
System.out.println("Connected\nTALK:");
out = new DataOutputStream(socket.getOutputStream());
in = new DataInputStream(socket.getInputStream());
line = "";
while(!line.toLowerCase().equals(".bye")) {
line = keyIn.readLine();
Send(line);
}catch (UnknownHostException e) {
System.out.println("BLAD: " + e);
}catch (IOException e) {
System.out.println("BLAD: " + e);
public void Send(String s) {
try {
out.writeUTF(s);
}catch (IOException e) {
System.out.println("BLAD: " + e);
public void run() {
String loaded = "";
try {
while(true) {
loaded = in.readUTF();
System.out.println(loaded);
}catch (IOException e) {
System.out.println("BLAD: " + e);
public static void main(String[] args) {
Client client = new Client("localhost", 5000);
}By the way, this app is mainly written in English language (text that appears on the screen) however in functions I used Polish language (for example: BLAD - it means ERROR in English). Sorry for that :)Yeap, I will change those exceptions later, thanks for advice.
You asked what's going on with it: both applications start with no errors, but when I write something in client side it should be sent to the server and then forwarded to all connected clients but it stops somewhere. However, I added a one line to the server code
line = in.readUTF();
System.out.println(line);
sendToAll(line); and after it reads message from client (no matter which one) it shows that message on the server side screen, then it should send this message to all clients but it doesn't work in this moment. What's confusing: no errors occurs, so it's rather a mistake in my code, but where?
Edited by: Robin3D on Sep 30, 2009 9:07 AM -
File transfer, read write through sockets in client server programming java
Hello All, need help again.
I am trying to create a Client server program, where, the Client first sends a file to Server, on accepting the file, the server generates another file(probably xml), send it to the client as a response, the client read the response xml, parse it and display some data. now I am successful sending the file to the server, but could not figure out how the server can create and send a xml file and send it to the client as response, please help. below are my codes for client and server
Client side
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
public class XMLSocketC
public static void main(String[] args) throws IOException
//Establish a connection to socket
Socket toServer = null;
String host = "127.0.0.1";
int port = 4444;
try
toServer = new Socket(host, port);
} catch (UnknownHostException e) {
System.err.println("Don't know about host: localhost.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to host.");
System.exit(1);
//Send file over Socket
//===========================================================
BufferedInputStream fileIn = null;
BufferedOutputStream out = null;
// File to be send over the socket.
File file = new File("c:/xampp/htdocs/thesis/sensorList.php");
// Checking for the file to be sent.
if (!file.exists())
System.out.println("File doesn't exist");
System.exit(0);
try
// InputStream to read the file
fileIn = new BufferedInputStream(new FileInputStream(file));
}catch(IOException eee)
System.out.println("Problem, kunne ikke lage fil");
try
InetAddress adressen = InetAddress.getByName(host);
try
System.out.println("Establishing Socket Connection");
// Opening Socket
Socket s = new Socket(adressen, port);
System.out.println("Socket is clear and available.....");
// OutputStream to socket
out = new BufferedOutputStream(s.getOutputStream());
byte[] buffer = new byte[1024];
int numRead;
//Checking if bytes available to read to the buffer.
while( (numRead = fileIn.read(buffer)) >= 0)
// Writes bytes to Output Stream from 0 to total number of bytes
out.write(buffer, 0, numRead);
// Flush - send file
out.flush();
// close OutputStream
out.close();
// close InputStrean
fileIn.close();
}catch (IOException e)
}catch(UnknownHostException e)
System.err.println(e);
//===========================================================
//Retrieve data from Socket.
//BufferedReader in = new BufferedReader(new InputStreamReader(toServer.getInputStream()));
DataInputStream in = new DataInputStream(new BufferedInputStream(toServer.getInputStream()));
//String fromServer;
//Read from the server and prints.
//Receive text from server
FileWriter fr = null;
String frn = "xxx_response.xml";
try {
fr = new FileWriter(frn);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
try{
String line = in.readUTF(); //.readLine();
System.out.println("Text received :" + line);
fr.write(line);
} catch (IOException e){
System.out.println("Read failed");
System.exit(1);
in.close();
toServer.close();
public class XMLSocketS
public static void main(String[] args) throws IOException
//Establish a connection to socket
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4444);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
Socket clientLink = null;
while (true)
try
clientLink = serverSocket.accept();
System.out.println("Server accepts");
BufferedInputStream inn = new BufferedInputStream(clientLink.getInputStream());
BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:/xampp/htdocs/received_from_client.txt")));
byte[] buff = new byte[1024];
int readMe;
while( (readMe = inn.read(buff)) >= 0)
{ //reads from input stream, writes the file to disk
ut.write(buff, 0, readMe);
// close the link to client
clientLink.close();
// close InputStream
inn.close();
// flush
ut.flush();
// close OutputStream
ut.close();
//Sending response to client
//============================================================
//============================================================
System.out.println("File received");
}catch(IOException ex)
{System.out.println("Exception.");}
finally
try
if (clientLink != null) clientLink.close();
}catch(IOException e) {}
clientLink.close();
//serverSocket.close();
}SERVER
import java.net.*;
import java.io.*;
public class XMLSocketS
public static void main(String[] args) throws IOException
//Establish a connection to socket
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4545);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
Socket clientLink = null;
try
clientLink = serverSocket.accept();
System.out.println("Server accepts the client request.....");
BufferedInputStream inn = new BufferedInputStream(clientLink.getInputStream());
BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:/xampp/htdocs/received_from_client.txt")));
byte[] buff = new byte[1024];
int readMe;
while( (readMe = inn.read(buff)) >= 0)
{ //reads from input stream, writes the file to disk
ut.write(buff, 0, readMe);
ut.flush();
//Sending response to client
//============================================================
BufferedInputStream ftoC = null;
BufferedOutputStream outtoC = null;
// File to be send over the socket.
File file = new File("c:/xampp/htdocs/thesis/user_registration_response.xml");
try
// InputStream to read the file
ftoC = new BufferedInputStream(new FileInputStream(file));
}catch(IOException eee)
{System.out.println("Problem reading file");}
// OutputStream to socket
outtoC = new BufferedOutputStream(clientLink.getOutputStream());
byte[] buffer = new byte[1024];
int noRead;
//Checking if bytes available to read to the buffer.
while( (noRead = ftoC.read(buffer)) >= 0)
// Writes bytes to Output Stream from 0 to total number of bytes
outtoC.write(buffer, 0, noRead);
outtoC.flush();
//============================================================
System.out.println("File received");
}catch(IOException ex)
{System.out.println("Exception.");}
finally
try
if (clientLink != null) clientLink.close();
}catch(IOException e) {}
clientLink.close();
//serverSocket.close();
}CLIENT SIDE
import java.io.*;
import java.net.*;
public class XMLSocketC
@SuppressWarnings("deprecation")
public static void main(String[] args)
// Server: "localhost" here. And port to connect is 4545.
String host = "127.0.0.1";
int port = 4545;
BufferedInputStream fileIn = null;
BufferedOutputStream out = null;
// File to be send over the socket.
File file = new File("c:/xampp/htdocs/thesis/sensorList.xml");
try
// InputStream to read the file
fileIn = new BufferedInputStream(new FileInputStream(file));
}catch(IOException eee)
{System.out.println("Problem");}
try
System.out.println("Establishing Socket Connection");
// Opening Socket
Socket clientSocket = new Socket(host, port);
System.out.println("Socket is clear and available.....");
// OutputStream to socket
out = new BufferedOutputStream(clientSocket.getOutputStream());
byte[] buffer = new byte[1024];
int numRead;
//Checking if bytes available to read to the buffer.
while( (numRead = fileIn.read(buffer)) >= 0)
// Writes bytes to Output Stream from 0 to total number of bytes
out.write(buffer, 0, numRead);
// Flush - send file
out.flush();
//=======================================
DataInputStream in = new DataInputStream(new BufferedInputStream(clientSocket.getInputStream()));
BufferedWriter outf = new BufferedWriter(new FileWriter("c:/xampp/htdocs/received_from_server.txt",true));
String str;
while(!(str = in.readLine()).equals("EOF")) {
System.out.println("client : Read line -> <" + str + ">");
outf.write(str);//Write out a string to the file
outf.newLine();//write a new line to the file (for better format)
outf.flush();
//=======================================
// close OutputStream
out.close();
// close InputStrean
fileIn.close();
// close Socket
clientSocket.close();
}catch (IOException e)
{System.out.println("Exception.");}
Could you please point where am I doing the stupid mistake, client to server is working properly, but the opposite direction is not.
Thanks -
I have a Windows 2012 Server set up offering print services to our network, there are about 20 printers set up all deployed via group policy. Recently, on one of our Windows 7 machines I am finding that I an unable to connect to one of the printers shared
on the print server while other clients seem to be able to connect to the same printer with no problem. Also, the printer used to work just fine from this same Windows 7 machine.
To test things further I logged onto the Win7 machine as the domain administrator, connected to the print server and double clicked on the printer to attempt to install it manually (rather than letting Group Policy do it). When I do so I receive the following
message, "Windows cannot connect to the printer. Operation failed with error 0x00004005.
I have done some searching but the only references I am finding to this particular error message involved users attempting to connect to a printer hosted on a 32-bit version of Windows from a 64-bit client. However, in my case both the server and client
are 64-bit.
Can any one help me troubleshoot this 0x00004005 error?
Thank you.Sorry for the delay. I just went and attempted to add the printer again on the client machine, the installation failed just as before, no log entries were recorded in the PrintService Admin log and the Operational log was disabled, I enabled it and added
the printer again. This time when the installation failed seven log entries appeared in the Operational log, all of them informational, no errors or warnings, the events are as follows...
1. Event 300, Printer {71688D29-F70C-42F2-90E1-DA5D450E772D} was created. No user action is required.
2. Event 304, Printer {71688D29-F70C-42F2-90E1-DA5D450E772D} was resumed. No user action is required.
3. Event 306, Settings for printer {71688D29-F70C-42F2-90E1-DA5D450E772D} were changed. No user action is required.
4. Event 306, Settings for printer {71688D29-F70C-42F2-90E1-DA5D450E772D} were changed. No user action is required.
5. Event 302, Printer {71688D29-F70C-42F2-90E1-DA5D450E772D} will be deleted. No user action is required.
6. Event 302, Printer {71688D29-F70C-42F2-90E1-DA5D450E772D},8 will be deleted. No user action is required.
7. Event 301, Printer {71688D29-F70C-42F2-90E1-DA5D450E772D} was deleted, and users will no longer be able to print to this printer. No user action is required.
There are a couple log entries in the Admin log indicating an error occurred, those errors occurred yesterday afternoon at 4:30pm or so. I did not try to add the printer then so I don't know if these are related to this particular problem or not. This same
entry appeared twice at exactly the same time...
The print spooler failed to load a plug-in module C:\Windows\system32\spool\DRIVERS\x64\3\PrintConfig.dll, error code 0xc1. See the event user data for context information.
As a temporary workaround I installed the drivers for that printer directly on the Windows 7 client machine and that works fine, however this is less than ideal because I had set up group policy to only install that printer for specific users, not for everyone. -
After installing Final cut server client on OSX 10.6.8 error: Apple QuickTime or the QuickTime Java component is not installed.
I know this error on windows machines but cannot get a solution for OSX.I have fixed this by installing the latest combo update
-
Rich-client Java application that is client to WLS6.1 but behind corporate proxy server
We have a rich-client Java application that is a client to WLS6.1 that can't
connect to the WLS6.1 server when the client is behind a corporate proxy
server. What is a remedy for this?
Thanks,
Jim WeavereFound solution. Followed Part 2 of the solution as explained in http://support.bea.com/application?namespace=askbea&origin=ask_bea_answer.jsp&event=link.view_answer_page_solution&answerpage=solution&page=wlw/S-19283.htm
What surprises me is that this solution to a common problem is hidden and hard
to find. If I am correct, no part of WLS 8.1 documentation suggests this. Rather
the doc says, set the system properties for the standard JDK 1.4 network properties
and it should work fine. If it is actually supposed to work like this, is it a
bug then?
"Naveen Kumar" <[email protected]> wrote:
>
Hi,
I have a web application deployed on WebLogic server 8.1 sp1. And my
server is
behind a http proxy server. Now one of the components in the application
makes
a web service call to a service located external to the system, and it
always
throws "java.net.UnknownHostException". I have set the Java system properties
http.proxyHost = my proxy server, http.proxySet = true and http.proxyPort
= 80
and it still does not help.
If I try to evaluate the web service component as a stand alone client
using WebLogic's
webserviceclient.jar, everything works fine. I can't figure what I have
to do
to get this component working from within the WebLogic server. Can anybody
provide
me with inputs, comments or suggestions.
Naveen. -
How Can I Take Print Screen With in java Application
Hello Every One,
Hope U all r fine.
How can i take print screen with in java code,
Please Help me outhttp://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Btitle%3A%22print+screen%22&col=javaforums
-
Java Chat, server/client*x
Hey,
I'm trying to make a chat and I've made the server and client, and the server can accept several clients. Only; they communicate client-server, and not client-server-client (if you get what I mean) like I want them to, pretty obviously, since its a chat. I'm still very new to this, heres my code anyhow:
Server
import java.net.*;
import java.io.*;
public class OJChatServer{
public static void main(String[] args) throws IOException{
int port=2556;
boolean listening = true;
ServerSocket cServerSocket = null;
try{
cServerSocket = new ServerSocket(port);
System.out.println("Server started; Waiting for client(s) to connect.");
} catch(IOException e){
System.err.println("Could not listen on port: "+port);
System.exit(1);
while(listening){
try{
new handleClient(cServerSocket.accept()).start();
} catch(IOException e){
System.err.println("Accept has failed");
System.exit(1);
cServerSocket.close();
static class handleClient extends Thread{
private Socket clientSocket = null;
private PrintWriter send;
private BufferedReader recieve;
private String inputString, outputString;
private String clientName = "";
public handleClient(Socket acceptedSocket){
//super("handleClient");
this.clientSocket = acceptedSocket;
public void run(){
try{
recieve = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
send = new PrintWriter(clientSocket.getOutputStream(), true);
inputString = recieve.readLine();
clientName = inputString;
System.out.println("Client \""+clientName+"\" has connected. ("+clientSocket+")");
while(inputString != null){
outputString = processInput(inputString);
// outputString = send.readLine();
send.println(outputString);
if(inputString.equalsIgnoreCase("Quit")||inputString.equalsIgnoreCase("/Quit")) break;
inputString = recieve.readLine();
System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
send.close();
recieve.close();
clientSocket.close();
} catch(IOException e){
//e.printStackTrace();
System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
}//run()
static String processInput(String theInput){
String theOutput = "From server. Test";
return theOutput;
}//handleClient
}//OJChatServer---------------------------------------------------------------------------------------------
Client
import java.net.*;
import java.io.*;
public class OJChatClient{
public static void main(String[] args) throws IOException{
String nickname = "Guest";
String host = "localhost";
int port = 2556;
Socket cClientSocket = null;
PrintWriter send = null;
BufferedReader recieve = null;
BufferedReader stdIn = null;
String fromServer, fromUser;
System.out.println("Welcome to Ove's Java Chat!\nFor help and commands type: /help");
nickname = KeyboardReader.readString("Enter nickname: ");
System.out.println("Connecting to host...");
try{
cClientSocket = new Socket(host, port);
send = new PrintWriter(cClientSocket.getOutputStream(), true);
System.out.println("Connection established.");
} catch(UnknownHostException e){
System.err.println("Unknown host: "+host);
System.exit(1);
} catch(IOException e){
System.err.println("Couldn't get I/O for connection: "+host+"\nRequested host may not exist or server is not started");
System.exit(1);
send.println(nickname);
stdIn = new BufferedReader(new InputStreamReader(System.in));
recieve = new BufferedReader(new InputStreamReader(cClientSocket.getInputStream()));
while((fromServer = recieve.readLine())!=null){
System.out.println("Server: "+fromServer);
fromUser = stdIn.readLine();
if(fromUser!=null){
//System.out.println(nickname+": "+fromUser);
send.println(fromUser);
if(fromUser.equalsIgnoreCase("Quit")||fromUser.equalsIgnoreCase("/Quit")) break;
System.out.println("Closing connection...");
send.close();
recieve.close();
stdIn.close();
cClientSocket.close();
System.out.println("Connection terminated.");
System.out.println("Goodbye and happy christmas!");
}I want to make it graphical too, but I want to make it work like it should, before i tackle trying Swing out. This code isn't completely complete yet, as you can see. It doesn't handle the clients messages correctly yet.
What I want to know is how i should send a message from a client to all the other Sockets on the server.It compiles, but it gives an error when the client connects.
import java.net.*;
import java.io.*;
public class OJChatServer4{
static Socket[] clientSockets = new Socket[100];
static int socketCounter = 0;
public static void main(String[] args) throws IOException{
int port=2556;
boolean listening = true;
ServerSocket cServerSocket = null;
try{
cServerSocket = new ServerSocket(port);
System.out.println("Server started; Waiting for client(s) to connect.");
} catch(IOException e){
System.err.println("Could not listen on port: "+port);
System.exit(1);
while(listening){
try{
clientSockets[socketCounter] = cServerSocket.accept();
new handleClient(clientSockets[socketCounter]).start();
socketCounter++;
} catch(IOException e){
System.err.println("Accept has failed");
System.exit(1);
cServerSocket.close();
static class handleClient extends Thread{
private Socket clientSocket = null;
public static PrintWriter send;
private BufferedReader recieve;
private String inputString, outputString;
private String clientName = "";
public handleClient(Socket acceptedSocket){
//super("handleClient");
this.clientSocket = acceptedSocket;
public void run(){
try{
recieve = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
send = new PrintWriter(clientSocket.getOutputStream(), true);
inputString = recieve.readLine();
clientName = inputString;
System.out.println("Client \""+clientName+"\" has connected. ("+clientSocket+")");
while(inputString != null){
//outputString =
processInput(inputString);
// outputString = send.readLine();
send.println(outputString);
if(inputString.equalsIgnoreCase("Quit")||inputString.equalsIgnoreCase("/Quit")) break;
inputString = recieve.readLine();
System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
send.close();
recieve.close();
clientSocket.close();
} catch(IOException e){
//e.printStackTrace();
System.out.println("Client \""+clientName+"\" has disconnected. ("+clientSocket+")");
}//run()
static void processInput(String theInput) throws IOException{
//String theOutput = "Test From server.";
PrintWriter sendToAll;
sendToAll = new PrintWriter(clientSockets[socketCounter].getOutputStream(), true);
for(int i=0;i<socketCounter;i++){
sendToAll.println(theInput);
//return theOutput;
}//handleClient
}//OJChatServer -
Call Client Java Proxy from Server Java Proxy
Hi Gurus!!
I'm trying to call a Client Java Proxy from a Server Java Proxy.
Is possible to do this? I think must be possible.
I have called this Client Java Proxy from another application, and run ok.
I have tried to call it following the Guide to call Java Client Proxies:
es.navantia.xi.mm.dispositivosRobotizadosKasto.MIRobotOut_PortTypeHome queryOutHome = null;
es.navantia.xi.mm.dispositivosRobotizadosKasto.MIRobotOut_PortTypeRemote queryOutRemote = null;
try {
// Get naming context
Properties p = new Properties();
p.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
p.put(Context.PROVIDER_URL, "myurl:50104");
p.put(Context.SECURITY_PRINCIPAL, "MMIGUEZ");
p.put(Context.SECURITY_CREDENTIALS, mypasswrod);
Context ctx = new InitialContext(p);
Object ref = ctx.lookup("RobotOut");
// Look up jndi name of proxy bean
try {
queryOutHome =
(MIRobotOut_PortTypeHome) PortableRemoteObject.narrow(
ref,
MIRobotOut_PortTypeHome.class);
} catch (Exception e) {
throw new RuntimeException(e + "1");
// Get Remote interface
queryOutRemote = queryOutHome.create();
} catch (Exception e) {
throw new RuntimeException(e + "2");
but I get this error
"com.sap.aii.af.ra.ms.api.DeliveryException: Error invoking method mIRobotIn of proxy bean $Proxy351: es.navantia.xi.mm.dispositivosRobotizadosKasto.MIRobotOut_PortTypeHome: com.sap.aii.proxy.xiruntime.core.XmlInboundException: Error invoking method mIRobotIn of proxy bean $Proxy351: es.navantia.xi.mm.dispositivosRobotizadosKasto.MIRobotOut_PortTypeHome"
es.navantia.xi.mm.dispositivosRobotizadosKasto.MIRobotOut_PortTypeHome is the corresponding PortTypeHome to the Client Java Proxy.
I have tried to call too calling directly from the server Java Proxy to the method correcponding to the Client Java Proxy. The error I get is:
"com.sap.aii.af.ra.ms.api.DeliveryException: Error invoking method mIRobotIn of proxy bean $Proxy351: es/navantia/xi/mm/dispositivosRobotizadosKasto/DTRobot_Type: com.sap.aii.proxy.xiruntime.core.XmlInboundException: Error invoking method mIRobotIn of proxy bean $Proxy351: es/navantia/xi/mm/dispositivosRobotizadosKasto/DTRobot_Type"
Tha call to the client is:
es.navantia.xi.mm.dispositivosRobotizadosKasto.MIRobotOut_PortType clase = null;
es.navantia.xi.mm.dispositivosRobotizadosKasto.DTRobot_Type client_req = null;
es.navantia.xi.mm.dispositivosRobotizadosKasto.DTRobotResponse_Type client_res = null;
client_res = clase.mIRobotOut(client_req);
Please, any help will be useful.
Thanks and regards,
Manuel Míguez.Hi,
Now I get another error message:
com.sap.aii.af.ra.ms.api.DeliveryException: Error invoking method mIRobotIn of proxy bean $Proxy351: es/navantia/xi/mm/dispositivosRobotizadosKasto/MITextoOut_PortTypeRemote: com.sap.aii.proxy.xiruntime.core.XmlInboundException: Error invoking method mIRobotIn of proxy bean $Proxy351: es/navantia/xi/mm/dispositivosRobotizadosKasto/MITextoOut_PortTypeRemote
Now, my source is:
MITextoOut_PortTypeHome queryOutHome = null;
MITextoOut_PortTypeRemote queryOutRemote = null;
try {
// Get naming context
Context ctx = new InitialContext();
// Look up the EJB name in the environment
Object ref = ctx.lookup("java:comp/env/ejb/TextoOut");
// Object ref = ctx.lookup("java:comp/env/ejb/MITextoOut_PortTypeBean");
// Cast to Home interface
queryOutHome = (MITextoOut_PortTypeHome)
PortableRemoteObject.narrow(ref,
MITextoOut_PortTypeHome.class);
// Get Remote interface
queryOutRemote = queryOutHome.create();
} catch (Exception e) {
System.out.println("RemoteException occurred: "+e.getMessage());
e.printStackTrace();
//return;
try {
queryOutRemote.$messageSpecifier();
} catch (RemoteException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
DTTexto_Type Texto_type = new DTTexto_Type();
Texto_type.setTexto(req_texto);
DTTextoResponse_Type Texto_response = new DTTextoResponse_Type();
try {
Texto_response = queryOutRemote.mITextoOut(Texto_type);
} catch (SystemFaultException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ApplicationFaultException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
I have tryed removing queryOutRemote.$messageSpecifier() and I get the error:
com.sap.aii.af.ra.ms.api.DeliveryException: Error invoking method mIRobotIn of proxy bean $Proxy351: es/navantia/xi/mm/dispositivosRobotizadosKasto/DTTexto_Type: com.sap.aii.proxy.xiruntime.core.XmlInboundException: Error invoking method mIRobotIn of proxy bean $Proxy351: es/navantia/xi/mm/dispositivosRobotizadosKasto/DTTexto_Type
Somebody knows what could be the cause of these errors?
Thanks and regards,
Manuel. -
Register Client Java Proxies to Proxy Server
Hi All,
Is it required to register the client java proxies with the proxy server?
Thanks in advancelol Some people dont know how to give the correct links as well.
Next wiki --> how to give correct links for questions asked on SDN.. will be a huge hit I guess -
Server/Client connection using an actionListener
Hey guys,
New to this board, so hopefully I can be of assistance :)
What I am currently working on is a networked Monopoly game. My part of the assignment is to create a simple game lobby (just GUI based, buttons, action listeners, etc) where players can create games and join games already created.
What I have is this. When a player clicks on the "Create Game" button, an anonomus inner action listener will detect the push and create a hosted game (Server side connection). When a player clicks on the newly created game, they will be a joined player (Client side connection).
The problem is this, keep in mind that I have created a very, very simple server/client chat to test this out. When a Socket is created for the clients to connect to upon the Create Game button push, my program essentially just hangs. Nothing happens at all.
Here are the 3 classes I used. I understand this is probably not the most efficient way to post, but this is the only way you can see what I exactly have. I took out all my GUI stuff to make it easier to follow (if you want me to post full classes I can):
Thanks for all the help!
- Ry
//package Mackopoly;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.io.EOFException;
import java.io.IOException;
import java.net.ServerSocket;
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
public class gameList extends JFrame {
MackPlayer tc1;
MackPlayer tc2;
MackPlayer tc3;
HostPlayer ts1;
HostPlayer ts2;
HostPlayer ts3;
private String temp = ""; //used to display chat area
private int gameCounter = 0; //number of games created
private boolean game1Started = false;
private boolean game2Started = false;
private boolean game3Started = false;
public void start()
//Sets up the screen
enterField.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent ae)
if (ae.getSource() == enterField)
temp = enterField.getText();
chatBox.append(temp + "\n");
enterField.setText("");
createGame.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent ae)
if (ae.getSource() == createGame)
gameCounter++;
if(gameCounter == 1)
//create a new host game on the server
//instanciate an object accordingly
game1.setText("Game " + gameCounter + "started!");
game1Started = true;
ts1 = new HostPlayer();
ts1.execute();
else if(gameCounter == 2)
game2.setText("Game " + gameCounter + "started!");
game2Started = true;
ts2 = new HostPlayer();
ts2.execute();
else if(gameCounter == 3)
game3.setText("Game " + gameCounter + "started!");
game3Started = true;
ts3 = new HostPlayer();
ts3.execute();
else
System.out.println("games full");
joinGame1.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent ae)
if (ae.getSource() == joinGame1)
if(game1Started == false)
JOptionPane.showMessageDialog(null,"Start a game!");
if(game1Started == true)
JOptionPane.showMessageDialog(null,"Joined!");
tc1 = new MackPlayer("Game 1");
tc1.startClient();
joinGame2.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent ae)
if (ae.getSource() == joinGame2)
if(game2Started == false)
JOptionPane.showMessageDialog(null,"Start a game!");
if(game2Started == true)
JOptionPane.showMessageDialog(null,"Joined!");
tc2 = new MackPlayer("Game 2");
tc2.startClient();
joinGame3.addActionListener(
new ActionListener()
public void actionPerformed(ActionEvent ae)
if (ae.getSource() == joinGame3)
if(game3Started == false)
JOptionPane.showMessageDialog(null,"Start a game!");
if(game3Started == true)
JOptionPane.showMessageDialog(null,"Joined!");
tc3 = new MackPlayer("Game 3");
tc3.startClient();
}//End start method
}//End of my class
import java.awt.*;
import java.awt.event.*;
import java.net.Socket;
import java.net.InetAddress;
import java.io.IOException;
import javax.swing.*;
import java.util.Formatter;
import java.util.Scanner;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
//Imports necessary packages
public class MackPlayer extends JFrame implements Runnable
//Client class
private JTextField idField;
private JTextArea displayArea;
private JTextField guessArea;
private JPanel panel2;
private Socket connection;
private Scanner input;
private Formatter output;
private String Host;
private String myMark;
private boolean myTurn;
private final String X_MARK = "1";
private final String O_MARK = "2";
public MackPlayer(String host)
Host = host;
displayArea = new JTextArea(10,30);
displayArea.setEditable(false);
add(new JScrollPane(displayArea), BorderLayout.SOUTH);
//Creates the message area
idField = new JTextField();
idField.setEditable(false);
add(idField, BorderLayout.NORTH);
//Creates the name field
guessArea = new JTextField(10);
guessArea.setEditable(false);
add(new JScrollPane(guessArea), BorderLayout.CENTER);
//Creates the guess area
panel2 = new JPanel();
panel2.add(guessArea, BorderLayout.CENTER);
add(panel2, BorderLayout.CENTER);
setSize(350, 275);
setVisible(true);
TextHandler tHandler = new TextHandler();
idField.addActionListener(tHandler);
guessArea.addActionListener(tHandler);
//Adds the area's to the handler
startClient();
public void startClient()
//Gets connection and starts thread
try
connection = new Socket(InetAddress.getByName(Host), 12345);
input = new Scanner(connection.getInputStream());
output = new Formatter(connection.getOutputStream());
catch(IOException e)
e.printStackTrace();
ExecutorService worker = Executors.newFixedThreadPool(1);
worker.execute(this);
public void run()
myMark = input.nextLine();
SwingUtilities.invokeLater(
new Runnable()
public void run()
idField.setText("Enter name here");
guessArea.setText("Enter guess");
//Default text
);//end call
myTurn = (myMark.equals(X_MARK));
while(true)
if(input.hasNextLine())
processMessage(input.nextLine());
private void processMessage(String message)
//Handles all possible messages from the server
if(message.equals("Guess too low."))
displayMessage("Guess too low\n");
else if(message.equals("Guess too high."))
displayMessage("Guess too high\n");
else if(message.equals("You Win!"))
displayMessage("You Win!\n");
else if(message.equals("Other player connected. Your turn."))
displayMessage("Other player connected. Your turn\n");
guessArea.setEditable(true);
else if(message.equals("Name1"))
displayMessage("Enter your name.\n");
idField.setEditable(true);
else if(message.equals("Name2"))
displayMessage("Enter your name.\n");
idField.setEditable(true);
else if(message.equals("Player 2 has entered name"))
displayMessage("Player 2 has entered name. Your turn\n");
guessArea.setEditable(true);
else if(message.equals("Invalid guess, try again"))
displayMessage(message + "\n");
myTurn = true;
guessArea.setEditable(true);
else if(message.equals("Opponent guessed"))
int sw = input.nextInt();
displayMessage("Opponent guessed " + sw);
sendGuess(sw);
displayMessage("\nOpponent moved. Your turn.\n");
guessArea.setEditable(true);
else if(message.equals("Opponent guessed and won"))
int sw = input.nextInt();
displayMessage("Opponent guessed and won with number " + sw);
sendGuess(sw);
guessArea.setEditable(false);
else
displayMessage(message + "\n");
private void displayMessage(final String messageToDisplay)
SwingUtilities.invokeLater(
new Runnable()
public void run()
displayArea.append(messageToDisplay);
public void sendGuess(int guess)
if(myTurn)
output.format("%d\n", guess);
output.flush();
private class TextHandler implements ActionListener
//Handles the fields
public void actionPerformed(ActionEvent event)
if(event.getSource() == idField)
idField.setEditable(false);
output.format("%s\n", idField.getText());
output.flush();
myTurn = false;
//Sends the name to the server
//Sets text to the name and sets it uneditable and sets turn to false
if(event.getSource() == guessArea)
guessArea.setEditable(false);
output.format("%s\n", guessArea.getText());
output.flush();
guessArea.setText("");
myTurn = false;
//Send the guess to the server
//Clears the past guess from the screen
import java.awt.BorderLayout;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.IOException;
import java.util.*;
import javax.swing.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
//Imports necessary packages
public class HostPlayer extends JFrame
//Server class
private JTextArea outputArea;
private Player[] players;
private ServerSocket server;
private int currentPlayer;
private final static int PLAYER_1 = 0;
private final static int PLAYER_2 = 1;
private final static String[] MARKS = { "1", "2"};
private ExecutorService runGame;
private Lock gameLock;
private Condition otherPlayerConnected;
private Condition otherPlayerTurn;
private Random generator = new Random();
private int randomNumber;
private String p1Name, p2Name;
//Variables
public HostPlayer()
super("Guessing game");
//Title of server window
runGame = Executors.newFixedThreadPool(2);
//Hanldes up to two clients
gameLock = new ReentrantLock();
//The lock
otherPlayerConnected = gameLock.newCondition();
otherPlayerTurn = gameLock.newCondition();
//The condition variables
players = new Player[2];
currentPlayer = PLAYER_1;
//The players
try
server = new ServerSocket(12345, 2);
catch(IOException e)
e.printStackTrace();
System.exit(1);
//Establishes server
randomNumber = generator.nextInt(10);
//The number to be guessed 0-10
outputArea = new JTextArea();
add(outputArea, BorderLayout.CENTER);
outputArea.setText("Server awaiting connections \n");
//The output area
displayMessage("The number is " + randomNumber + " \n");
//Prints out what the number is
setSize(300, 300);
setVisible(true);
//Sets the size of the server window
public void execute()
for(int i = 0; i < players.length; i++)
try
players[i] = new Player(server.accept(), i);
runGame.execute(players);
//Runs the threads to handle clients
catch(IOException e)
e.printStackTrace();
System.exit(1);
gameLock.lock();
try
players[PLAYER_1].setSuspended(false);
otherPlayerConnected.signal();
finally
gameLock.unlock();
private void displayMessage(final String messageToDisplay)
//Function that displays messages
//Class + method that can update the GUI for threads
SwingUtilities.invokeLater(
new Runnable()
public void run()
outputArea.append(messageToDisplay);
public boolean validateAndMove(int guess, int player)
//Function that determines what the output should be based on the guess
while(player != currentPlayer)
//The player can only guess if it is his turn
gameLock.lock();
try
otherPlayerTurn.await();
catch(InterruptedException e)
e.printStackTrace();
finally
gameLock.unlock();
if(correctRange(guess))
//If the guess is a valid guess
currentPlayer = (currentPlayer + 1) % 2;
//Switches player turn
players[currentPlayer].otherPlayerGuessed(guess);
gameLock.lock();
try
otherPlayerTurn.signal();
//Signals other player
finally
gameLock.unlock();
return true;
else
return false;
public boolean correctRange(int guess)
//Tests for a valid guess between 0-10
if(guess >= 0 && guess <= 10)
return true;
else
return false;
private class Player implements Runnable
//Player class
private Socket connection;
private Scanner input;
private Formatter output;
private int playerNumber;
private String mark;
private boolean suspended = true;
private boolean game = true;
public Player(Socket socket, int number)
playerNumber = number;
mark = MARKS[playerNumber];
connection = socket;
try
//Tries to get the data streams
input = new Scanner(connection.getInputStream());
output = new Formatter(connection.getOutputStream());
catch(IOException e)
e.printStackTrace();
System.exit(1);
public void otherPlayerGuessed(int guess)
//Function that detemines whether the guess is too high/low or correct
if(guess == randomNumber)
output.format("Opponent guessed and won\n");
output.format("%d\n", guess);
output.flush();
else
output.format("Opponent guessed\n");
output.format("%d\n", guess);
output.flush();
public void run()
//The start of the threads, at the beginning messages go back and forth to set up the connection
//and player names
try
displayMessage("Player " + mark + "connected \n");
output.format("%s\n", mark);
output.flush();
//Sends the message that the player has connected
if(playerNumber == PLAYER_1)
output.format("%s\n%s", "Player 1 connected ", "Waiting for another player\n");
output.flush();
gameLock.lock();
try
while(suspended)
otherPlayerConnected.await();
//Waits for player 2
catch(InterruptedException e)
e.printStackTrace();
finally
gameLock.unlock();
output.format("Name1\n");
output.flush();
p1Name = input.nextLine();
displayMessage("Player 1 = " + p1Name + "\n");
//Sends a message to enter the name and puts the received name
//in the variable p1Name
output.format("Other player connected. Your turn.\n");
output.flush();
//Starts the game when the other player has connected
//A lot of the turn base is done with message handling
//on the client side
else
output.format("Name2\n");
output.flush();
p2Name = input.nextLine();
displayMessage("Player 2 = " + p2Name + "\n");
output.format("Player 2 connected. Please wait.\n");
output.flush();
//Sets up player 2's name and turn
while(game)
//while the game is not over
int guess = 0;
if(input.hasNext())
guess = input.nextInt();
}//Gets next input
if(validateAndMove(guess, playerNumber))
//Sends the correct output based on the guess
if(guess < randomNumber)
if(playerNumber == 0)
displayMessage(" \n"+p1Name+ " guess: " + guess);
else
displayMessage(" \n" p2Name " guess: " + guess);
output.format("Guess too low.\n");
output.flush();
else if(guess > randomNumber)
if(playerNumber == 0)
displayMessage(" \n"+p1Name+ " guess: " + guess);
else
displayMessage(" \n" p2Name " guess: " + guess);
output.format("Guess too high.\n");
output.flush();
else
if(playerNumber == 0)
displayMessage(" \n"+p1Name+ " guess: " + guess);
else
displayMessage(" \n" p2Name " guess: " + guess);
output.format("You Win!\n");
output.flush();
game = false;
//Ends game
else
output.format("Invalid guess, try again\n");
output.flush();
finally
try
connection.close();
catch(IOException e)
e.printStackTrace();
System.exit(1);
}//End run
public void setSuspended(boolean status)
suspended = status;
}//End player class
}//End Server class
Thanks for the response
I think I understand what you are saying, I just want to make sure I get it fully. I need to create a separate thread that runs just my connection process to make sure that the processes actually occur? If so, how would I go about doing this?
Thanks again -
500 Internal server error - java.lang.NullPointerException: null
While trying to access the initial login screen of EP, we face this '500 Internal server error - java.lang.NullPointerException: null' issue very randomly. It appears sometimes and when opened from new browser we get the login screen sometimes. It is not a problem that reproduces always. On the screen where the error appears, we refresh any number of times, no help, the error remains the same, but when we open in a new window, it might give the login screen or end up with this error.
We have 4 Dialog Instances and a Cisco load balancer.
Upon repeated redirection to a particular instance and particular server node(https://<hostname>:<port>/irj/portal;sapj2ee_irj= XXX) from the trace files, I could get the following information :-
#0019BBEB9F4C00190000409700001707000478F21B0BBACE#1258881142025#com.sap.tc.webdynpro.sessionmanagement#sap.com/tcwddispwda#com.sap.tc.webdynpro.sessionmanagement.ExceptionHandler.handleThrowable#2449#32347##n/a##245825a0d74711de92700019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_12##0#0#Error#1#/System/UserInterface#Java###Exception occured during processing of Web Dynpro application . The causing exception is nested.
[EXCEPTION]
#2#sap.com/pb/PageBuilder#java.lang.NullPointerException
#1.5_#0019BBEB9F4C00190000409800001707000478F21B0BD29A#1258881142031#com.sap.engine.services.servlets_jsp.client.RequestInfoServer#sap.com/tcwddispwda#com.sap.engine.services.servlets_jsp.client.RequestInfoServer#2449#32347##n/a##245825a0d74711de92700019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_12##0#0#Error##Plain###application [webdynpro/dispatcher] Processing HTTP request to servlet [dispatcher] finished with error. The error is: java.lang.NullPointerException
#1.5_#0019BBEB9F4C00190000409A00001707000478F21B0C5FDE#1258881142068#com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl#sap.com/tcwddispwda#com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl#2449#32347##n/a##245825a0d74711de92700019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_12##0#0#Error#1#/System/Server/WebRequests#Plain###application [webdynpro/dispatcher] Processing HTTP request to servlet [dispatcher] finished with error.
The error is: java.lang.NullPointerException: null
Exception id: [0019BBEB9F4C00190000409800001707000478F21B0BD29A]#
#1.5_#0019BBEB9F4C00310000372500001707000478F21D348764#1258881178254#com.sap.security.core.server.destinations.service.DestinationServiceImpl#sap.com/tcwddispwda#com.sap.security.core.server.destinations.service.DestinationServiceImpl.getDestination#5180#32285##juepp01_EPP_16040550#5180#392ddb50d74711de87f40019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_10##0#0#Error#1#/System/Security/destinations#Java###An error occurred while reading the destination , type . The error was .#3#sap_inbox$WebFlowConnector#RFC#<Localization failed: ResourceBundle='com.sap.exception.io.IOResourceBundle', ID='No such destination sap_inbox$WebFlowConnector of type RFC exists ', Arguments: []> : Can't find resource for bundle java.util.PropertyResourceBundle, key No such destination sap_inbox$WebFlowConnector of type RFC exists #
#1.5_#0019BBEB9F4C00310000372600001707000478F21D34893F#1258881178255#System.err#sap.com/tcwddispwda#System.err#5180#32285##juepp01_EPP_16040550#5180#392ddb50d74711de87f40019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_10##0#0#Error##Plain###java.lang.Exception: Problem occured while creating JCO client for destination: sap_inbox#
#1.5_#0019BBEB9F4C00310000372700001707000478F21D34A80D#1258881178262#System.err#sap.com/tcwddispwda#System.err#5180#32285##juepp01_EPP_16040550#5180#392ddb50d74711de87f40019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_10##0#0#Error##Plain### at com.sap.netweaver.bc.uwl.utils.r3.R3SystemInfo.createJCOClient(R3SystemInfo.java:67)#
#1.5_#0019BBEB9F4C00310000372800001707000478F21D34A887#1258881178263#System.err#sap.com/tcwddispwda#System.err#5180#32285##juepp01_EPP_16040550#5180#392ddb50d74711de87f40019bbeb9f4c#SAPEngine_Application_Thread[impl:3]_10##0#0#Error##Plain### at com.sap.netweaver.bc.uwl.utils.r3.R3SystemInfo.hasFunctionModule(R3SystemInfo.java:591)#
Kindly advise as to what could be the issue..Hi, either the problem should come always for us to be able to trouble shoot it or should not come at all.
Now since it comes sometimes, i feel that you surely are using more than one app. servers in your enviroment and some of them are not fine.
I received this error when i accidently had deleted my sso ticket pairs in the visual admin.
First troubleshoot by login to individual app servers where the issue is coming. after that check the certificate-cert key pair in keystore admin. you can also delete them and make new ticket pairs..
If this does not help, replace your login page with the standard sap login page par com.sap.portal.runtime.logon.par.
This should certainly troubleshoot u
cheers,
Ankur -
Non-blocking Server/Client is blocking...?!
First, a simple question:
Why in most example code using Selectors, when iterating over the Set returned by Selector.selectedKeys() does the currently selected SelectionKey get removed from the Iterator? I see it all the time, but since the SelectionKey is still bound to the underlying Selector it seems to not really do anything.
Now to my main problem:
I been working with 1.4 for a week now trying to implement a simple test server/client, whereby the server constantly sends out the current time to any subscribing clients, who in turn display the time to stdout. Pretty straight forward, huh?
Well, everything seems to go fine...once. The Server accepts the client connection, sends out a the current time, the client (only one for now) receives it, displays to the screen, but then both server and client block on the Selector.select() method.
If I shut down the client, the server then continues through the select() method, finding one SelectionKey, tries to write to it and throws an IOException (since the client is no more). I'm catching that exception and then removing the channel from the Selector, so that the server may continue to service requests.
When starting a second client while the first is still running causes the following sequence of events:
Server: starts up
ClientA: connects to server
Server: broadcasts the time
ClientA: displays time
// nothing else happens until...
ClientB: connects to server
Server: broadcasts the time
ClientA: displays time
ClientB: displays time
//everything blocks again...
ClientA: disconnects from server
Server: broadcasts the time
ClientB: displays time
As you can see it seems everything blocks until a client does something (connect/disconnect).
I will post code if anyone asks, but I don't want to spam the board if no one is willing to help me.
-JustinYou got it!
// ********** SERVER **********
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
public class TestServer
private static final int DEFAULT_PORT = 9999;
public static void main(String[] args)
TestServer s = new TestServer();
}//end of main(String[])
public TestServer()
this(DEFAULT_PORT);
}// end of TestServer()
public TestServer(int port)
InetSocketAddress addr = new InetSocketAddress(port);
try
Selector acceptSelector = Selector.open();
Selector broadcastSelector = Selector.open();
ConnectionList connections = new ConnectionList(broadcastSelector);
Acceptor a = new Acceptor(acceptSelector, addr, connections);
Broadcaster b = new Broadcaster(broadcastSelector, connections);
a.start();
b.start();
}// end of try
catch (Exception ex)
ex.printStackTrace();
}// end of catch
}// end of TestServer(int)
private static String status(Selector s)
StringBuffer sb = new StringBuffer(100);
sb.append("Selector: ");
Set keys = s.keys();
sb.append("\n\tNum Keys: ");
sb.append(keys.size());
Iterator iter = keys.iterator();
int i = 0;
while (iter.hasNext())
try
sb.append("\n\t[");
sb.append(i++);
sb.append("]:");
SelectionKey key = (SelectionKey)iter.next();
sb.append(" acceptable=");
sb.append(key.isAcceptable());
sb.append(" connectable=");
sb.append(key.isConnectable());
sb.append(" readable=");
sb.append(key.isReadable());
sb.append(" writable=");
sb.append(key.isWritable());
}// end of try
catch (CancelledKeyException cke)
sb.append("*** CANCELLED KEY");
}// end of catch
}// end of while
return sb.toString();
}// end of status(Selector)
class Broadcaster extends Thread
private final String TF = Broadcaster.class.getName();
private int BUFFER_SIZE = 2048;
private Selector selector_;
private ConnectionList connections_;
private ByteBuffer buffer_;
public Broadcaster(Selector selector, ConnectionList connections)
super("Broadcaster");
selector_ = selector;
connections_ = connections;
buffer_ = ByteBuffer.allocateDirect(BUFFER_SIZE);
public void run()
while (true)
try
registerNewChannels();
System.out.println("BroadcasterThread: Before select() "+status(selector_));
System.out.println("BroadcasterThread: Selecting...");
int keysReady = selector_.select();
System.out.println("BroadcasterThread: After select() "+status(selector_));
System.out.println("BroadcasterThread: "+keysReady+" ready Key(s)");
if (keysReady > 0)
transmit();
}// end of if
}// end of try
catch (Exception ex)
ex.printStackTrace();
return;
}// end of catch
}// end of while
protected void registerNewChannels()
throws Exception
SocketChannel channel = null;
while (null != (channel = connections_.removeFirst()))
channel.configureBlocking(false);
channel.register(selector_, SelectionKey.OP_WRITE);
System.out.println("BroadcasterThread: Registered connection from " + channel.socket().getInetAddress());
}// end of while
}// end of registerNewChannels()
public void transmit()
throws Exception
Set readyKeys = selector_.selectedKeys();
System.out.println("BroadcasterThread: Selected Keys: "+readyKeys.size());
SelectionKey tempKey = null;
SocketChannel tempChannel = null;
fillBuffer();
for (Iterator i = readyKeys.iterator(); i.hasNext(); )
tempKey = (SelectionKey)i.next();
tempChannel = (SocketChannel)tempKey.channel();
if (tempKey.isWritable())
System.out.println("BroadcasterThread: Key selected is Writable");
try
tempChannel.write(buffer_);
System.out.println("BroadcasterThread: Sent message to "+tempChannel.socket().getInetAddress());
}// end of try
catch (IOException ioe)
System.err.println("BroadcasterThread: Lost Connection");
tempChannel.close();
}// end of catch
}// end of if
else
System.out.println("BroadcasterThread: Key selected is not Writable");
}// end of else
}// end of for
buffer_.clear();
}// end of transmit()
private void fillBuffer()
buffer_.clear();
/* Place Date in Buffer */
long time = System.currentTimeMillis();
Date d = new Date(time);
System.out.println("BroadcasterThread: Broadcasting "+d);
String date = d.toString()+"\n";
byte[] datebuff = date.getBytes();
buffer_.put(datebuff);
/* Prepare for read operations */
buffer_.flip();
}// end of fillBuffer()
}//end of inner class Broadcaster
class Acceptor extends Thread
private Selector selector_;
private ConnectionList connList_;
private final String TF = Acceptor.class.getName();
public Acceptor(Selector selector, InetSocketAddress address, ConnectionList connList)
super("Acceptor");
selector_ = selector;
connList_ = connList;
try
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(false);
ssc.socket().bind(address);
System.out.println("AcceptorThread: Bound to " + address);
ssc.register(selector_, SelectionKey.OP_ACCEPT);
}// end of try
catch (Exception ex)
ex.printStackTrace();
}// end of catch
public void run()
while (true)
try
System.out.println("AcceptorThread: Selecting...");
int keysReady = selector_.select();// block till a channel is ready
System.out.println("AcceptorThread: "+keysReady+" Keys Ready");
if (keysReady > 0)
acceptPendingConnections();
}// end of if
catch (Exception ex)
ex.printStackTrace();
protected void acceptPendingConnections()
throws Exception
Set readyKeys = selector_.selectedKeys();
System.out.println("AcceptorThread: Selected "+readyKeys.size()+" Keys");
for (Iterator i = readyKeys.iterator(); i.hasNext(); )
SelectionKey key = (SelectionKey)i.next();
i.remove();
ServerSocketChannel readyChannel = (ServerSocketChannel)key.channel();
SocketChannel incomingChannel = readyChannel.accept();
System.out.println("AcceptorThread: Connection from " + incomingChannel.socket().getInetAddress());
connList_.add(incomingChannel);
}// end of for
}// end of acceptPendingConnections()
}// end of inner class Acceptor
class ConnectionList
private LinkedList list_;
private Selector selectorToNotify_;
public ConnectionList(Selector toNotify)
list_ = new LinkedList();
selectorToNotify_ = toNotify;
}// end of ConnectionList(Selector)
public synchronized void add(SocketChannel newlyConnectedChannel)
list_.add(newlyConnectedChannel);
selectorToNotify_.wakeup();
}// end of add(SocketChannel)
public synchronized SocketChannel removeFirst()
SocketChannel first = null;
if (list_.size() > 0)
first = (SocketChannel)list_.removeFirst();
}//end of if
return first;
}// end of removeFirst()
}// end of inner class ConnectionList
}// end of class TestServer
// ********** CLIENT **********
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.nio.channels.WritableByteChannel;
import java.util.Iterator;
import java.util.Set;
public class TestClient
public static final String TF = TestClient.class.getName();
private static final String DEFAULT_SERVER_IP = "127.0.0.1";
private static final int DEFAULT_SERVER_PORT = 9999;
private InetSocketAddress serverAddr_;
private Selector connectSelector_;
private Selector readSelector_;
private WritableByteChannel outputChannel_;
private ByteBuffer receiveBuffer_;
private SocketChannel serverChannel_;
public static void main(String[] args)
TestClient c = new TestClient();
}// end of main(String[])
public TestClient()
this(DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT);
}// end of TestClient()
public TestClient(String ip, int port)
try
serverAddr_ = new InetSocketAddress(ip, port);
connectSelector_ = Selector.open();
readSelector_ = Selector.open();
outputChannel_ = Channels.newChannel(System.out);
receiveBuffer_ = ByteBuffer.allocateDirect(512);
connect();
run();
}// end of try
catch (Exception ex)
ex.printStackTrace();
}// end of catch
}// end of TestClient(String, int)
private void connect()
throws Exception
serverChannel_ = SocketChannel.open();
serverChannel_.configureBlocking(false);
serverChannel_.connect(serverAddr_);
serverChannel_.register(connectSelector_, SelectionKey.OP_CONNECT);
int numKeys = 0;
while (numKeys <= 0)
System.out.println("connect(): Selecting...");
numKeys = connectSelector_.select();
System.out.println("connect(): "+numKeys+" ready Key(s)");
Set readyKeys = connectSelector_.selectedKeys();
System.out.println("connect(): Selected Keys: "+readyKeys.size());
if (numKeys > 0)
SelectionKey tempKey = null;
SocketChannel tempChannel = null;
Iterator i = readyKeys.iterator();
while (i.hasNext())
tempKey = (SelectionKey)i.next();
i.remove();
tempChannel = (SocketChannel)tempKey.channel();
if (tempKey.isConnectable())
System.out.println("connect(): Key selected is Connectable");
if (tempChannel.isConnectionPending())
System.out.println("connect(): Connection Pending");
tempChannel.finishConnect();
System.out.println("connect(): Connection Completed");
}// end of if
}// end of if
else
System.out.println("connect(): Key selected is not Connectable");
}// end of else
}// end of while
}// end of if
}// end of while
}// end of connect()
private void run()
throws Exception
serverChannel_.register(readSelector_, SelectionKey.OP_READ);
while (true)
System.out.println("run(): Before select() "+status(readSelector_));
System.out.println("run(): Selecting...");
int numKeys = readSelector_.select();
System.out.println("run(): After select() "+status(readSelector_));
System.out.println("run(): "+numKeys+" Ready Key(s)");
if (numKeys > 0)
processKeys();
}// end of if
}// end of while
}// end of run()
private void processKeys()
throws Exception
Set readyKeys = readSelector_.selectedKeys();
System.out.println("processKeys(): Selected Keys: "+readyKeys.size());
SelectionKey tempKey = null;
SocketChannel tempChannel = null;
for (Iterator i = readyKeys.iterator(); i.hasNext(); )
tempKey = (SelectionKey)i.next();
tempChannel = (SocketChannel)tempKey.channel();
if (tempKey.isReadable())
System.out.println("processKeys(): Key selected is Readable");
try
tempChannel.read(receiveBuffer_);
receiveBuffer_.flip();
outputChannel_.write(receiveBuffer_);
receiveBuffer_.clear();
}// end of try
catch (IOException ioe)
System.out.println("processKeys(): Lost Connection");
tempKey.cancel();
}// end of catch
}// end of if
else
System.out.println("processKeys(): Key selected is not Readable");
}// end of else
}// end of for
}// end of processKeys()
private static String status(Selector s)
StringBuffer sb = new StringBuffer(100);
sb.append("Selector: ");
Set keys = s.keys();
sb.append("\n\tNum Keys: ");
sb.append(keys.size());
Iterator iter = keys.iterator();
int i = 0;
while (iter.hasNext())
try
sb.append("\n\t[");
sb.append(i++);
sb.append("]:");
SelectionKey key = (SelectionKey)iter.next();
sb.append(" acceptable=");
sb.append(key.isAcceptable());
sb.append(" connectable=");
sb.append(key.isConnectable());
sb.append(" readable=");
sb.append(key.isReadable());
sb.append(" writable=");
sb.append(key.isWritable());
}// end of try
catch (CancelledKeyException cke)
sb.append("*** CANCELLED KEY");
}// end of catch
}// end of while
return sb.toString();
}// end of status(Selector)
}// end of class TestClient
Maybe you are looking for
-
Is it still impossible to do bootcamp and VMWare or Parallels?
I use bootcamp extensively to run several windows programs, mostly MS Office 2010. I also need to use Office 2011 so being able to switch back and forth between OS X and Win 7 is essential (I do this because I'm a consultant and curriculum developer-
-
FB 4.7 Greyed out menus / Mac OS X 10.9 preview 6
Hey everyone, has any one ever seen this before? All toolbar menus are greyed out no matter what is in focus in the main application window. Any ideas?
-
IPhoto places are 1000 times the same
I have now 12600 Fotos in my mediathek. I added to every foto places manually. When I tried to correct some places with more details, I added the street and number, everything looked fine. Now I have lots of places with the same placeinformation. the
-
Rman Duplicate database synchronization problem
Hi I have the Oracle database 9.2.0.1.0 .I've created Duplicate database on another computer with the same structure and Oracle 9.2.0.1.0 too. Now, I want to synchronize my duplicate by primary database, and I copied backup of all datafiles & archive
-
It happens every now and again, not consistantly.