Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:57:55+00:00 2026-06-12T07:57:55+00:00

Okay, so the issue I’m being stuck at for few days already is that

  • 0

Okay, so the issue I’m being stuck at for few days already is that Tomcat doesn’t run my applications. This is my first encounter with Tomcat and server programming overall, so its most likely purely my fault. But in few days I couldn’t beat it myself, so I decided to post a question here.

I have tried running quite a lot of different setups, but now I am at the easiest one and still can’t figure it out. So, I’ve got installed: Eclipse IDE 1.5.0 (Eclipse platform 4.2.0), WST 3.4.1, Tomcat 7.0.12 installed through Eclipse (tried 7.0.30 also).

I’ve got tomcat server configured in eclipse fine, so when I run it – it does work as intended.

But then I’ve got this easy piece of code which I’ve got from oracle’s guide on server sockets:

import java.net.*;
import java.io.*;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;


public class KnockKnockServer {
    private static final Logger logger = Logger.getRootLogger();

    public static void main(String[] args) throws IOException {
        BasicConfigurator.configure();
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(4444);
            logger.debug("Socket opened");
            System.err.println("Port opened");
        } catch (IOException e) {
            logger.debug("Could not listen on port: 4444.");
            System.err.println("Port not opened");
            System.exit(1);
        }

        Socket clientSocket = null;
        try {
            clientSocket = serverSocket.accept();
            logger.info("socket accepted");
        } catch (IOException e) {
            logger.info("Accept failed.");
            System.exit(1);
        }

        PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
        BufferedReader in = new BufferedReader(
                new InputStreamReader(
                clientSocket.getInputStream()));
        String inputLine, outputLine;
        KnockKnockProtocol kkp = new KnockKnockProtocol();

        outputLine = kkp.processInput(null);
        out.println(outputLine);

        while ((inputLine = in.readLine()) != null) {
             outputLine = kkp.processInput(inputLine);
             out.println(outputLine);
             if (outputLine.equals("Bye."))
                break;
        }
        out.close();
        in.close();
        clientSocket.close();
        serverSocket.close();
    }
}

which doesn’t work when I do the “Run As -> Run on server” launch. I tried adding it to WAR and deploying, but it yields the same result – none. Meaning that niether I can connect to it using another client app (from another eclipse instance) nor it produces ANY messages showing it works (only accesss logs produced by tomcat). As you can see I added log4j to the code to see any message that proves the code actually RUNS on server (initially there were just System.err’s and System.out’s), which I tried configuring both for console output and file output.

And again, the server itself runs as intended – I can access it through browser, open manager app, deploy/undeploy apps, etc.

So the question is: what am I doing wrong? I assume there might be some primitive mistake/undone step/whatsoever made by me, but I couldn’t figure it out in 2 days of fighting with help of google.

Help will be greatly appreciated.

UPDATE: Thanks a lot guys! As I suspected – stupid me 🙂 Don’t know why I started this mess with Tomcat, but yeah, Run as Application works fine. Those instant answers saved me a lot of time. Thanks a lot again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:57:56+00:00Added an answer on June 12, 2026 at 7:57 am

    I think there is a misunderstaning here. Tomcat is a servlet container – it’s intended to run web applications that consist of servlets.

    Your KnockKnockServer is a regular Java application, therefore running it “on Tomcat” makes absolutely no sense. You should run it as a standalone application instead.

    Actually, sometimes it makes sense to start a server for some specific protocol inside a web application that runs on Tomcat. In this case you need to control lifecycle of the custom server from ServletContextListener. But I don’t think that it’s your case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I think I might be over-complicating this issue but I truly am stuck.
Okay So heres the issue, using an api (lyris hq) i am being returned
Okay people, I'm sure someone has had this issue and can help me out.
Okay, of course it is possible, that's no issue. In my code I have
First off, I'm using XCode 4.0.2. Okay, here is my issue. I can build
Okay, so I have an issue with an AJAX request. I currently have this
Okay, here's my issue (and my first question on SO!), and no, as much
Okay, allow me to say first off that I am working on developing my
Okay so I'm having an issue with a current assignment (trust me this is
I ran some searches but found no available answer to this issue. Okay, my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.