Problem Crontab vs Java 1 4 2 & Socket

I've created a shell script that calls the java program :
PATH=/usr/lib/java:/usr/lib/java/bin:/usr/java142:/usr/java142/bin:$PATH ; export PATH
cd /usr/dconn
java -cp DConnection.jar DPackage/DConnection
The jar en script file are in the same directory.
In the java program a socket connection is made and communication is started with the remote system.
When executing this script at the prompt, there is no problem. I can send data and receive.
The following step is to schedule this script :
SHELL=/bin/sh
MAILTO=root
# check scripts every minute
*/10 * * * * /usr/dexxconn/startdexx.sh
At first there was java 131 installed on the linux system. And there was no problem with the program. When I began using java 140 (on windows) because I needed some new String methods, the scheduler mycron didn't properly executed my program.
The output of the program is normally seen in the mail of the root. But nothing gets in the mail. So I killed the process for that java program and I got output in the mail from the root.
I can derrive from that mail that the java program makes a socket connection, but does not communicate with the remote system. I can't send data or receive.
Has anyone any idea to solve this problem, is it because of crontab,java 140, java 142?

Forgot to mention. When I had these problems with java 131 on linux I installed java 142 and then I got the earlier described problem.

Similar Messages

  • Problems with a Java socket client

    Hi,
    I'm using the following piece of code to recieve from a C++ server a string of chars:
    TcpCli = new Socket(m_HostIP, m_HostPorta);
    String msg="";
    int lenSocketBuffer=0;
    BufferedInputStream in = new BufferedInputStream(TcpCli.getInputStream());
    lenSocketBuffer=in.available();
    if (lenSocketBuffer > 0)
    saveBuff = new byte[lenSocketBuffer];
    in.read(saveBuff,0,lenSocketBuffer);
    msg = saveBuff.toString();
    I have verified that the creation of the Socket is OK (using debug on the Server side) and that the Server sends to the Client what I expect to receive. The length of the buffer read in lenSocketBuffer is OK but when I receive the buffer using in.read I find a string that is something like this: "[B@7b6889" which is a completely different buffer from what the server sends and much more shorter then the value of lenSocketBuffer.
    Where is the problem? Please, help me.
    Thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    replace...
    msg = saveBuff.toString();
    with...
    msg = new String(saveBuff);
    saveBuff.toString() returns the string-representation of the object saveBuff. new String(saveBuff) creates a new String-Object with the bytes of the given array.

  • Problem while reading data on java socket

    Hi All,
    I am in big problem based on java socket programming. I run my application and start a ServerSocket on 10000(suppose) port no.As soon as request is coming i create a new thread with Socket assigned to it and process the request. Now i got the response and written on same Socket(Listen to ServerSocket on 10000 port). Now what i want to read the response written earlier on Socket.The written response i print on SOP it is visible. But when i establish InputStream and try to read the data it gives me -1 means no data is available. But i have seen the SOP and data is written to socket. How can solve the problem. I have tried after close the Socket as well as not close the socket.
    Please help me out on this.see below code
    <CODE>
    void upperClassMethod() {
    istener = new ServerSocket(port);
    while(true) {
    clientSocket = listener.accept();
    doComms conn_c= new doComms(clientSocket);
    Thread t = new Thread(conn_c);
    t.start();
    //doComms is a inner class of upper level class
    class doComms implements Runnable {
              private Socket server;
              doComms(Socket server) {
                   //pp = server;
                   this.server=server;
                   //server=server1;
    void processResponse() {
              try {
                   BufferedInputStream in = new BufferedInputStream (clientSocket.getInputStream());
                   byte [] inBuff = new byte [4096] ;
                   int len = in.read (inBuff, 0, inBuff.length) ;
                   String output = new String (inBuff) ;
                   System.out.println("the output is :::: "+output);
              } catch(Exception e) {
                   e.printStackTrace();
    </CODE>
    in processResponse() method i am not able to get output. Plz help me guys.....
    Thanks in advance for ant assistance
    Regards,
    Pradeep

    please see mu rum nethos of doComms class
    <CODE>
    public void run () {
                   input="";
                   boolean done = false ;
                   try {
                        BufferedInputStream in = new BufferedInputStream (server.getInputStream());
                        out = new PrintStream(server.getOutputStream());
                        while (!done) {
                             byte [] inBuff = new byte [4096] ;
                             try {
                                  int len = in.read (inBuff, 0, inBuff.length) ;
                                  if (len > 0) {
                                       input = new String (inBuff) ;
                                       Runnable r = new RequestProcessThread();
                                       Thread t = new Thread(r);
                                       t.start();
                                  } else if (len == -1) {
                                       done = true ;
                                       //server.close () ;
                             catch (InterruptedIOException iioe) {
                   } catch (IOException ioe) {
                        System.out.println("IOException " + ioe + " on socket in thread: " + Thread.currentThread().getName());
                        ioe.printStackTrace();
                        done = true ;
    </CODE>

  • Performance problems with java sockets

    Hi ,
    I written a server class that simply writes the numbers and the client simply reads those numbers and prints them. When I run the both client and server on tha same machine there is no data loss found. But when I run the server on different machine than client I found heavy dataloss.(while theserver written numbers from 1-9000 the client is able read only 6000 plus). The data loss is increased when the data read from the server socket created by the VB application. Here with i am pasting the code snippet for the Server and the Client java files . Please help me in solving this problem.
    Client.java
    import java.net.*;
    import java.io.*;
    public class Client
         static Socket client = null;
         ObjectInputStream is = null;
         public Client() throws Exception
              client = new Socket("rajsekhar",3333);
              is = new ObjectInputStream (client.getInputStream());
              while(true){
                   Integer in = (Integer)is.readObject();
                   System.out.println(in.toString());
         public static void main(String[] args) throws Exception
              new Client();
    Server.java
    import java.net.*;
    import java.io.*;
    public class Server
         public static void main(String[] args) throws Exception
              ServerSocket server = null;
              server = new ServerSocket(3333);
              Socket s = server.accept();
              ObjectOutputStream os = new ObjectOutputStream(s.getOutputStream());
              int i =1;
              while(true)
                   os.writeObject(new Integer(i));
                   System.out.println(i);
                   i++;
    please help me .
    thanks in advance,
    Sridhar Reddy .R

    Hi,
    Try putting os.flush() after doing the writting... I mean:
    os.writeObject(new Integer(i));
    os.flush();
    Good Luck!

  • Using plain Java Sockets(not RMI) how..?

    hi!
    1. Using plain Java Sockets(not RMI) how can the client detect when its server
    goes down?
    There is a long time interval between client requests and the client wants
    to retain a live connection rather than disconnect after every reqest.
    Please also cc your reply to [email protected]
    Thanks,
    \Raghu

    If you try to send data when the host is gone, it throws an exception. I don'thow to check if it is alive though. I'm having the same problem right now.

  • Socket AS3 ( Receive File .TXT ) + Java Socket

    Hi,
    I have Java Socket sending .TXT file ( 10 MB ) . But the AS3 only gets 63 Kb . I do not understand the loss of bytes ...
    Souce Java :
    public void sendFile(String fileName) {
            try {
                //handle file read
                File myFile = new File(fileName);
                byte[] mybytearray = new byte[(int) myFile.length()];
                FileInputStream fis = new FileInputStream(myFile);
                BufferedInputStream bis = new BufferedInputStream(fis);
                DataInputStream dis = new DataInputStream(bis);
                dis.readFully(mybytearray, 0, mybytearray.length);
                OutputStream os = clientSocket.getOutputStream();
                byte[] fileSize = intToByte(mybytearray.length);
                byte[] clientData = new byte[(int) myFile.length() + mybytearray.length];
                System.arraycopy(fileSize, 0, clientData, 0, fileSize.length); // Copy to the file size byte array to the sending array (clientData) beginning the in the 0 index
                System.arraycopy(mybytearray, 0, clientData, 4, mybytearray.length); // Copy to the file data byte array to the sending array (clientData) beginning the in the 4 index
                DataOutputStream dos = new DataOutputStream(os);
                //dos.writeUTF(myFile.getName());
                //dos.writeInt(mybytearray.length);
                dos.write(clientData, 0, clientData.length);
                dos.flush();
    AS3 Source..
    private function onResponse(e:ProgressEvent):void {
      var file:File;
      var fs:FileStream;
      var fileData:ByteArray = new ByteArray();
      file = File.documentsDirectory.resolvePath("tmpReceive.txt");
      fs = new FileStream();
      fs.addEventListener(Event.CLOSE,onCloseFileReceive);
    if(_socket.bytesAvailable > 0) {
      while(_socket.bytesAvailable) {
      // read the socket data into the fileData
      _socket.readBytes(fileData,0,0);
      fs.open(file, FileMode.WRITE);
      // Writing the file
      fs.writeBytes(fileData);
      fs.close();

    Crypto streams, like CipherInputStream andCipherOutputStream, do not behave properly until you
    issue a close() call. So if you are going to do
    crypto, you will need to trap the close() before it
    reaches the underlying socket streams. This is
    because the close() method finalizes the cryptographic
    operation. (Flush() would make more sense, no idea
    why they did it this way). You do want to finalize
    the crypto for any given message, but you need to trap
    the close() before it hits the socket and ends the
    whole affair.
    I don't see anything about that in the bug database.
    No matter what streams you are using, if you aregoing to keep the socket open for multiple
    request-response round-trips, you need to very closely
    pay attention to how much data is being sent on each
    trip. Normally, you can fudge this a bit on a
    request-response because the close() call on the
    output stream will cause the receiving input stream to
    behave more or less properly. However, a flush() will
    not.Why not? I use that all the time with no problem.
    A good practice is to send the content-length of
    the message first, so the receiving input stream
    "knows" when to stop reading, does not block, and then
    can send its own bytes back the other direction.
    (Where the process is repeated).
    An alternative is to use two threads: read and write.
    The read recieves, parses, validates and then pushes complete messages to a queue.
    The write pulls messages from the queue, processes and send a result.
    A variation to the above is what happens when an invalid message is received. The server can ignore it, the read can send a error response, or the read can push a message to the queue which causes the write to send a error response.

  • JAVA SOCKET TIMEOUT WHEN GENERATING PDF TO ADS SERVER

    We are currently getting the error when attempting to generate the PDF from the thin portal BI Reports and recieved the JAVA SOCKET READ TIME OUT error and
    applied adjustments to the notes
    934725 and 826419 by changing the timeout sessions to 300, but still get the same timeout errors:
    Note: We changed ADUSER user type and password, passed rpcData test, RFC HTTP external connections to ADS server...so we've came a long ways and here we are now with the timeout errors...
    Any ideals???

    Hi
    when you reset password please select checkbox for password never expires.
    see the following notes :
    1.Note 944221 - Troubleshooting if problems occur in forms processing
    2.Note 811342 - Time Out exception when rendering to Adobe document service
    thanks
    Gopal

  • The service bit "write enable" in Java Socket

    Hello,
    I am trying to communicate with a third party application and I am having some problems. I use a standard Socket connection, were my application is the Server (ServerSocket). The connection is established, but no data is transmitted.
    I talked with the guys behind this third party application, and they said that perhaps their application does not receive a "write enable" service bit of the tcp/ip protocol. I'm not a network wiz, so this is an unknown territory for me.
    So I ask you. What is this "write enable" tcp/ip service bit? Is this per default on in java socket connections? If no, how can I change this?
    Perhaps this is very basic knowledge, but I've googled a bit and have not found this "service bit".

    This could refer to something in their
    protocol which you aren't implementing correctly.Probably, but I believe they have "forgotten" to mention that it is required in our implementation.
    OTOH if you are the server the transaction would
    normally begin with a request from the client, not a
    write-enablement from the server.The defined protocol smelled fishy when reading the "whitepaper", but we had to accept it (politics).

  • How can C socket talk to Java Socket?

    Hello, all
    I am writing a gateway program (written in Java) that accepts request from clients (written in C)
    My problem is that "Java end" cannot receive an EOF from "C end", thus it is always waiting for it.....
    C End
    error = 0;
    while (error < strlen(request))
             error += write(fd, request, strlen(request));
             if (error < 0)
                     perror("write");
                     return -1;
    } /* write */Java End
    int c;
    while ((c = input.read()) != -1)
             System.out.printf("%c", (char)c);
             request.append((char)c);
    System.out.println(request);Could anybody tell me solve this problem?
    Thanks!!

    The receiver will get an EOF after the sender closes the socket. (Or half closes it; see the shutdown() system call.)
    If you want to keep the connection open, you need to use some other end-of-request terminator. Such as \n if the request never has embedded newlines.
    Btw, the "while(error < ...)" loop in the sender isn't right. It will make more sense if you add "request += error;" to the loop.

  • Java socket run on localhost against outside server

    Hi everyone,
    I am newbie to Java socket and networking. By spending this weekend over the internet reading and researching I have made my first Server-Client java socket program run sucessfully on my localhost 127.0.0.1. They can be connected and ok to communicate.
    However, when I put my server program to the LIVE server outside the network the client side says cannot connect to the server because: Connection Error, Connection refused: connect. So I read some stuff about firewall and NAT on the web but i was shamed that I don't understand there is any solution to this.
    It is great appreciated if someone can point me out how can I resolve this or make a step out because I am running out of time to give out the program against the deadline. But I really thank you anyone has been reading this.
    The server code:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package instantmessenger;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
        public class Server extends JFrame implements ActionListener {
            JTextArea textreceive   =new JTextArea();
            JTextArea textsend      =new JTextArea();
            JButton button          =new JButton("Send");
            BufferedReader in;
            PrintWriter out;
            public Server () {
                    //init   controls
                    setTitle("Server");
                    setBounds(50,50,500,400);
                    getContentPane().setLayout(null);
                    getContentPane().add(textreceive);
                    getContentPane().add(textsend);
                    getContentPane().add(button);
                    textreceive.setBounds(10,10,450,300);
                    textsend.setBounds(10,320,350,30);
                    button.setBounds(370,320,70,30);
                    button.addActionListener(this);
            public void listenClient() throws IOException {
                    ServerSocket   server=new   ServerSocket(9999);
                    System.out.println("start:"+server);
                    textreceive.append("start"+server+"\n");
                    try {
                            Socket s = server.accept();
                            try {
                                    System.out.println("connecting   :"+s);
                                    textreceive.append("connecting   :"+s+"\n");
                                    in = new BufferedReader(new InputStreamReader(s.getInputStream()));
                                        out=new   PrintWriter(
                                        new   BufferedWriter(
                                        new   OutputStreamWriter(s.getOutputStream())));
                                    out = new PrintWriter(s.getOutputStream());
                                    String str=null;
                                    while(true) {
                                            str = in.readLine();
                                            System.out.println(str);
                                            textreceive.append(str+"\n");
                            finally {
                                s.close();
                    finally {
                        server.close();
            } // end function
            public void actionPerformed(ActionEvent event) {
                    String str = textsend.getText();
                    if( !str.equals("")) {
                            out.println(textsend.getText());
                            //out.println(textsend.getText());
                            out.flush();
                            textreceive.append(textsend.getText()+"\n");
                            textsend.setText("");
            } // end function
            public   static   void   main(String   args[])   throws   IOException {
                Server   s=new   Server();
                s.show();
                s.listenClient();
            } // end function
        } // end classThe client source code:
    package instantmessenger;
        import   java.net.*;
        import   java.io.*;
        import   javax.swing.*;
        import   java.awt.*;
        import   java.awt.event.*;
        public   class   Client   extends   JFrame implements   ActionListener {
            JTextArea   textreceive=new   JTextArea();
            JTextArea   textsend   =new   JTextArea();
            JButton     button   =new   JButton   ("Send");
            BufferedReader  in;
            PrintWriter     out;
            public Client(){
                    //init   controls
                    setTitle("Client");
                    setBounds(50,50,500,400);
                    getContentPane().setLayout(null);
                    getContentPane().add(textreceive);
                    getContentPane().add(textsend);
                    getContentPane().add(button);
                    button.addActionListener(this);
                    textreceive.setBounds(10,10,450,300);
                    textsend.setBounds(10,320,350,30);
                    button.setBounds(370,320,70,30);
           } // init
            public void startNet() throws IOException {
                  //Socket client=new Socket("localhost",9999);
                  Socket client=new Socket("222.33.444.5555",9999);  // NOT REAL SERVER IP
                  try {
                          System.out.println("Socket="   +client);
                          in    =   new BufferedReader(new InputStreamReader(client.getInputStream()));
                          out   =   new PrintWriter(new BufferedWriter(new OutputStreamWriter(client.getOutputStream())),true);
                          String str=null;
                          while(true) {
                              str   =   in.readLine();
                              System.out.println(str);
                              textreceive.append(str+"\n");
                  finally {
                        client.close();
            } // end function
            public void actionPerformed(ActionEvent   event) {
                String str=textsend.getText();
                if(!str.equals("")) {
                    out.println(textsend.getText());
                    //out.println(textsend.getText());
                    out.flush();
                    textreceive.append(textsend.getText()+"\n");
                    textsend.setText("");
            } // function
            public static void main(String args[]) throws IOException {
                Client c=new Client();
                c.show();
                c.startNet();
            } // function
    } // end classThank you
    Morris Lee

    However, when I put my server program to the LIVE server outside the network the client side says cannot connect to the server because: Connection Error, Connection refused: connect. So I read some stuff about firewall and NAT on the web but i was shamed that I don't understand there is any solution to this.What do you want us to do? You already know that the problem probably is that you need to open port 9999 in the firewall, and you probably also need to configure it for port forwarding.
    Most clients will be able to connect after that, but some might still have problems. E.g. some companies don't allow clients to connect to other ports than a few well known ones (e.g. 21, 80 and 443)

  • Connecting to http web site using java socket

    Hi,
    Sockets in Java I believe are reusable. Once created, it can be used to send a request using its input stream and get back a response using the output stream. My problem is I am trying to connect to a website using java socket but I am unable to get a response (though the same works fine I use URL and URLConnection). Can anyone tell me whats wrong? Below is the client program:
    public class HttpAdapterTest {
         public static void main(String[] args) {
              try {
                   Socket socket = new Socket("www.google.com", 80);
                   BufferedWriter out = new BufferedWriter(
                                  new OutputStreamWriter(socket.getOutputStream()));
                   out.write("GET /help/basics.html HTTP/1.1");
                   out.flush();
                   BufferedReader in = new BufferedReader(
                                            new InputStreamReader(ucon.getInputStream()));
                   String line = null;
                   while((line = in.readLine()) != null) {
                        System.out.println(line);
                   in.close();
              } catch (Exception e) {
                   e.printStackTrace();
    }

    Look at the JSSE examples. You need to setup a key store, add the jsse jars to your classpath, yadda, yadda, yadda....

  • Problems with a java bean in Weblogic 5.1

    Hello,
              I am having a problem deploying a java bean in Weblogic 5.1:
              I have been given a .class and a .jar file for a java bean (not an EJB). I
              placed the .class file into e:\temp\WEB-INF\classes and added the following
              line to my weblogic.properties file:
              weblogic.httpd.webApp.testApp=e:/temp/
              I have also updated the web.xml file in the WEB-INF directory as follows:
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
              Application 1.2//EN"
              "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
              <web-app>
              <servlet>
              <servlet-name>EdIface</servlet-name>
              <jsp-file>test.jsp</jsp-file>
              </servlet>
              <servlet-mapping>
              <servlet-name>EdIface</servlet-name>
              <url-pattern>EdIface</url-pattern>
              </servlet-mapping>
              </web-app>
              When I try to access my http:\\server:port\testApp\test I get an "Error
              500 - internal server error".
              Has anyone had experice with deploying a java bean with jsut the .class and
              .jar file? Where should I put the .jar file?
              I appreciate any advice!
              

    Bump

  • Java socket - unsure road to take!

    Hi all,
    We have an application requiring data transfer from a JSP Web application (socket client) and a stand-alone java application (socket server).
    This java stand-alone app communicates to an industrial microcontroller connected to the RS-232 serial port.
    When this java apps received a command from the JSP web app, it cannot service any other command from other uses, since there is just one RS-232 serial port on the computer. We would like to rely on the java & network environment to buffer additional commands receive simultaneously, as opposed to write code on the java socket server to handle this. In other works, our java stand-alone operates in an assynchronous, single-task mode.
    We are unsure which approach to take as far as java socket goes:
    1) simple socket server/client;
    2) multithread socket
    3) pooled
    Can anyone advise us.
    Thank you
    Trajano

    Hi Pete,
    1) Yes, we can have more than one user trying to access the micro-controllers, because we have in reality a network of micro-controllers connected to the single RS-232 computer port via a RS-485 to RS-232 converter;
    2) If a second user tries to issue a command to micro-controller, I would prefer for the java socket/environment to take care of the buffering, by just delaying the response, until the first user gets its command serviced
    3) If there is 1 user, him/her might issue several commands at the same time, by opening several JSP pages;
    4) No the controllers can service any instruction coming up at any time. The protocol is master/slave. The java app issues a request and the micro-controlle replies back and ready to accept any other request.
    ISSUE: My preference is for the system to take care of commands arriving at the socket server.
    This java app has two threads:
    1) Thread1 is the java socket server and upon receiving a command it will update three (3) properties:
    micro-controller address, command and product code
    2) Thread32 will be responsible for polling the 3 properties to check if they've changed. Upon detecting a change, it will build the data string and send to the RS-232 serial port.
    Any ideas/suggestions.
    Thanks in advance for any assistance.
    Regards

  • Java socket streams messing up

    iv wrote a games server and it uses java socket streams to send the messages back and forth between the game clients and the game server it self
    this all works great but when running and over about 5min its send over 1000 packets BUT
    it will crash iv found the reason is down to when reading the packets my parser is reading wrong part and grabbing a String part when it should be a INT
    now it should NEVER be reading this part of the packet so i put a trace on the packets coming in and ran it every packet was been read in perfect THEN just befor the crash TWO packets were merged together stright out from the socket stream this is y my packet reader was getting confused
    what im asking is can this happen in java sockets ? i thought they were bufferered so no matter how fast you send data it would always read it out in the same order ?? not sure how its merging these to packets
    is this possible of is my reader got an error in it altho works 95% of the time ??

    or do you have multiple buffered streams created from the same socket?

  • Getting Problem while publishing Problem while publishing java.lang.IllegalArgumentExcep

    getting Problem while publishing Problem while publishing java.lang.IllegalArgumentExcep while deploying persistance with ejb sample application into cloud. can any one please tell me why i am getting this?

    Hi Goutham,
    I am facing the same issue. Please let me know how you have resolved it.

Maybe you are looking for