application server, just without the "web" part...

Discussion in 'Java' started by Andreas Leitgeb, May 14, 2014.

  1. Essentially my application is a couple of separate command-line
    utilities, called from users with shell-access (or from unix
    shell scripts).

    Startup-time still isn't exactly Java's strong point, and often
    enough in my situation the startup time is by far the "longest
    pole in the tent".
    Adding option -Xshareclasses improved things, but not enough.

    I'd like to consider some kind of application server, that would
    run the actual java-code of any number of jobs (of one user) in one
    jvm, and with an "interface", that would only allow that one user to
    start new jobs.

    Does something like this already exist?

    PS: the actual jobs need to be in Java, because they need certain
    Java-libraries for their work. The server would know all relevant
    classes beforehand.
    Andreas Leitgeb, May 14, 2014
    1. Advertisements

  2. Andreas Leitgeb

    markspace Guest

    ClassName.main( "arguments" );


    After you add the Jar file to your app server's classpath, of course.

    Output could be a little weird, depending on how your sever handles
    stdout. Most of the output will likely end up in the log file.

    Not sure what else...
    markspace, May 14, 2014
    1. Advertisements

  3. Andreas Leitgeb

    Stefan Ram Guest

    I don't know the meaning of »user« in Java. Maybe you want:

    java.lang.System.getProperty( "" ).equals( "user0" )

    ? Otherwise, you could use a normal Web/REST-server and a local
    socket ( with appropriate IP checks/firewalls.
    Stefan Ram, May 14, 2014
  4. Andreas Leitgeb

    Stefan Ram Guest

    Oh, I now see that this does not work across server boundaries!

    To grant server access only to user user0, create a file
    that is writeable only by the server process and readable
    only by that user user0. The server writes a text to that
    file and then the user must pass this text to the server
    API. As soon as such a call is received, a new text can be
    written to that file.
    Stefan Ram, May 14, 2014
  5. Andreas Leitgeb

    Arne Vajhøj Guest

    Why not run beanshell and run the classes from that.

    $ java -cp wherebshis:whereyourstuffis bsh.Interpreter
    bsh% somepackage.SomeClass.main(null);
    bsh% somepackage.SomeOtherClass.main(null);

    Arne Vajhøj, May 15, 2014
  6. Andreas Leitgeb

    Joerg Meier Guest

    It seems to me that would break the vast majority of Java applications,
    which tend to start with something like "if (args.length > 0) ...".

    Liebe Gruesse,
    Joerg Meier, May 15, 2014
  7. Ok, I noticed from the replies that my posting was apparently
    unclear in ways I didn't anticipate...

    First of all, the "server" was meant as a process on the same
    host, not as a separate machine.

    Second, The server is supposed to handle multiple processes in
    parallel (as threads), separating them (and each's static fields)
    by use of separate classloaders. (I thought that would be implicit
    by referring to "application server", but obviously it wasn't)

    Thanks anyway for the answers so far.

    PS: I already caught the drift, though, that what I need is a
    bit further off mainstream than I feared it would be.
    Andreas Leitgeb, May 15, 2014
  8. I hoped for unix domain sockets or named pipes, if the server can
    handle those.
    I'll probably need to multiplex it into the communication channel...

    I hoped I wouldn't need to start from zero, though.

    Thanks, anyway.
    Andreas Leitgeb, May 15, 2014
  9. I googled and found
    I'm not yet sure if this will help me with separating multiple
    jobs running at the same time, but it might help me in my process
    of incrementally implementing what I need.


    PS: for the other F'up: of course I would not pass null for args...
    I'd definititely have something sensible to pass instead.
    Andreas Leitgeb, May 15, 2014
  10. Andreas Leitgeb

    Arne Vajhøj Guest

    Yeah. new String[0] would be a bit nicer than null.

    Arne Vajhøj, May 17, 2014
  11. Now I am confused.

    You worry about the JVM startup time - implying that it is
    somewhat significant compared to job run time.

    But you want to run multiple jobs in parallel - implying that
    jobs run for a long time.

    Am I missing something?

    Arne Vajhøj, May 17, 2014
  12. There are short jobs, long jobs eventually spawning short
    jobs while running.

    In principle I could distinguish them beforehand and only
    use bean-shell for the short ones (running them serialized).

    However, I'm not sure if I can correctly predict it in
    all cases, so I'm looking for a general solution that
    won't require me to distinguish.
    Andreas Leitgeb, May 17, 2014
  13. Andreas Leitgeb

    Jeff Higgins Guest

    It's starting to sound like OSGI to me.
    OSGI Standard Services

    Or even a Business Process Management platform | framework
    Jeff Higgins, May 17, 2014
  14. Andreas Leitgeb

    Jeff Higgins Guest

    Jeff Higgins, May 17, 2014
  15. Andreas Leitgeb

    Jeff Higgins Guest

    Jeff Higgins, May 17, 2014
  16. Andreas Leitgeb

    Jeff Higgins Guest

  17. Andreas Leitgeb

    Luuk Guest

    Luuk, May 17, 2014
  18. Thanks for the cascade of Karaf links :)

    It's not quite what I was looking for, and I saw, that I have to
    refine my requirements until I really know what I need. As it seems,
    an "application server" is much more than what I need, as it also
    has the concept of deploying and undeploying code dynamically.

    I'll probably only need to deal with unix domain sockets (not
    internet sockets) for starting applications and interacting with
    them, and I'll need to learn how to deal with classloaders, taking
    care not to accidentally load certain classes too early (thus into
    the system classloader). I could probably learn that from karaf
    but I expect to learn it easier somewhere else.
    Andreas Leitgeb, Jun 16, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.