Apache Tomcat fails to start from Netbeans

starting-of-tomcat-failed-netbeans

Log Message:

‘127.0.0.1’ is not recognized as an internal or external command,
operable program or batch file.

The solution is taken from Stack Overflow with thanks to Sudeepta

I have faced the exact problem in apache-tomcat-7.0.56 and apache-tomcat-8.0.14 with netbeans7.4 and netbeans8. I installed tomcat from zip file. I fixed it by changing catalina.bat file in tomcat bin directory.

Find the bellow configuration in your catalina.bat file.

:noJuliConfig
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"

:noJuliManager
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"

Just remove the double quotes

:noJuliConfig
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%

:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%

Now save and start your tomcat from NetBeans. It works for me in apache-tomcat-7.0.56 and apache-tomcat-8.0.14.

Advertisements

Hello World RMI using Netbeans

While working on my assignment for the Sun Certified Developer for the Java 2 Platform certification, I discovered that little documentation exists for setting up a simple Remote Method Invocation (RMI) hello world application using Netbeans.

Hopefully this post saves others time that I had to invest. The code here heavily leverage’s that available on Rose India, however, the code on Rose India did not work without modification.

1. Create an Interface named HelloInterface that extends Remote:

import java.rmi.*;

public interface HelloInterface extends Remote {

        public String say() throws RemoteException;
}

2. Create a class Hello which implements HelloInterface:

import java.rmi.*;
import java.rmi.server.*;

public class Hello extends UnicastRemoteObject
           implements HelloInterface {

           private String message;

           public Hello(String msg) throws RemoteException {
                     message = msg;
           }

           public String say() throws RemoteException {
           return message;
}
}

3. Create a class named HelloServer which, believe it or not, acts as the server. This class creates an entry in the servers RMI registry which is available for the client.

import java.rmi.Naming;
import java.rmi.registry.Registry;

public class HelloServer {

        public static void main(String[] args) {
                try {
                        Registry r = java.rmi.registry.LocateRegistry.createRegistry(1099);//1099 is the port number
                        r.rebind("Hello", new Hello("Arsenal Football Club, THFC forever in our shadow."));
                        System.out.println("Server is connected and ready for operation.");
                } catch (Exception e) {
                        System.out.println("Server not connected: " + e);
                }
        }
}

4. Write your client class, HelloClient, which invokes the remote methods on your server:

import java.rmi.Naming;

public class HelloClient {

        public static void main(String[] argv) {
                try {
                        HelloInterface hello = (HelloInterface) Naming.lookup("//localhost/Hello");
                        System.out.println(hello.say());
                } catch (Exception e) {
                        System.out.println("HelloClient exception: " + e);
                }
        }
}

That is all your coding coded. Now run the server, then run the client. There lies the foundation for you to take over the world using RMI. As a special bonus, enjoy a picture of  Tony Adams.

tony adams arsenal legend

Tony Adams, no respect for RMI.

Also, as a little link juice to another site of mine, here is a reminder a a great web developer for low cost web development in Nottingham.