----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Apache JServ 1.0
Apache 1.3.9
Linux/Redhat 6.0
(as requested, config and code is attached below)

I've got an applet that makes a URLConnection to a servlet that sits on an
apache web server using jserv. I then writeObjects() into an
ObjectOutputStream from my applet. The problem is that the servlet
(which is almost an exact copy of other servlets that do work) never get's
executed (never even initialized). I always restart the server after placing
the servlet in it's proper place and URL's are correct.

All my writes from the applet execute w/o errors, exceptions, etc... and
looks like it's working just fine and the web server never reports that the
servlet is missing or not found, so one would think, so far so good. But the
doGet & doPost, nor init() methods of ServletA never gets called and by
looking at the log files in apache and jserv, servletA doesn't even get
initialized when requested by the applet (like servletB does). jserv.log
usually reports as follows:

[28/02/2000 09:40:33:399 CST] DBQuery: init
... more of same for init and destroy

Although I do see the following in the java console of IE or Netscape when
exec'ing the applet:
Opening http://MyServer/servlets/ServletA

I have applets sitting on machineB that I access from machineA's browser,
then exec my serlvets on machineB that access a server through RMI on
machineC (which does more cool accessing stuff after that). If I run netstat
on my linux box, I can see connections being established so I know THAT part
of my applet is correct. If I call the servlet from an html file using a
post action method, the servlet works fine. But I don't understand why the
servlet won't init when I use them together. I can step through my code line
by line, and everything from my URL to openConnection and writeObjects throw
nothing. I'm 99.9% certain my code is correct (after 22 hours of staring at
it).

This is very frustrating as I can't possibly think of what I'm doing wrong
(probably something stupid, but I've been over and over the code) and can't
figure out a proper way to debug this thing to see what's going on from the
eyes of apache.

Any help much appreciated, else if anyone needs a job, mine will be vacant
by the end of the week if I can't figure this out.

TIA, 
Gary

P.S. - An explanation of the attached files.

The ExecServlet class get's called from an actionPerformed method of the
applet (which is sort of a utility class which I'd change up after I get it
working for calling several servlets, a break down of read and write's). The
Submit class is ServletA explained as above (it never inits) and gets called
from the ExecServlet class. DBQuery is one that I call before Submit and it
works. But forget the order I call them in. I've tried all, so I dounbt it's
not because something is being closed properly.

DBQuery class (servlet) which does work gets called from the SQLQuery from
withing the applet. This one works fine.

----------------- httpd.conf -----------------------
ServerType standalone
ServerRoot "/usr/local/apache"
PidFile /usr/local/apache/logs/httpd.pid
ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
Port 80
User nobody
Group nobody
ServerAdmin [EMAIL PROTECTED]
DocumentRoot "/u/Build/Build_System"
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory "/u/Build/Build_System">
    Options Indexes FollowSymLinks
   AllowOverride None
</Directory>
UserDir public_html
DirectoryIndex index.html
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
UseCanonicalName On
TypesConfig /usr/local/apache/conf/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile /usr/local/apache/conf/magic
</IfModule>
HostnameLookups Off
ErrorLog /usr/local/apache/logs/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /usr/local/apache/logs/access_log common
ServerSignature On
Alias /icons/ "/usr/local/apache/icons/"

<Directory "/usr/local/apache/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
<Directory "/usr/local/apache/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README
HeaderName HEADER
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de
AddLanguage da .da
AddLanguage el .el
AddLanguage it .it

LanguagePriority en fr de
AddType application/x-tar .tgz

BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

Include /usr/local/jserv/etc/jserv.conf

------------------------ jserv.conf ------------------------
<IfModule mod_jserv.c>
ApJServManual off
ApJServProperties /usr/local/jserv/etc/jserv.properties
ApJServLogFile /usr/local/jserv/logs/mod_jserv.log
ApJServLogLevel notice
ApJServDefaultProtocol ajpv12
ApJServDefaultPort 8007
ApJServSecretKey DISABLED
ApJServMount /servlets /root
ApJServMount /servlet /root
ApJServMountCopy on
<Location /jserv/>
  SetHandler jserv-status
  
  order deny,allow
  deny from all
  allow from localhost
</Location>
</IfModule>

-------------- From within my applet, I call this method to start the next
class below ------------

public void actionPerformed(ActionEvent ev) {
      String cmd = ev.getActionCommand();

      System.out.println("cmd = " + cmd);

      try {
         if (cmd.equals("Submit Task")) {
            toServl = new ExecServlet("Submit");

            if (toServl.send(kit) != 0) {
               System.out.println("Error: toServl.send()");
            }
         }
      }
      catch (Exception e) {
         System.out.println("ConfigSys Exception: " + e.getMessage());
      }
   }


------------- I can actually step through is class in my applet and see that
it established connections on my webserver -------------

public class ExecServlet
{
        String location = "http://morpheus/servlets/";
        URL servlet = null;
        URLConnection servletConnection = null;
        Kit kit = null;

        public ExecServlet(String servl) {
                try {
                        System.out.println("location = " + location +
servl);
                        servlet = new URL(location + servl);
                }
                catch (MalformedURLException e) {
                        System.out.println("MalformedURLException: " + e);
                }
                catch (Exception e) {
                        System.out.println("Exception: " + e);
                }
        }

        public int send(Kit k) {
                ObjectOutputStream toServlet = null;
                System.out.println(">> [send]");

                kit = k;

                System.out.println("kit.name = " + kit.name);
                System.out.println("kit.version = " + kit.version);
                System.out.println("kit.build = " + kit.build);
                
                try {
                        servletConnection = servlet.openConnection();
                        servletConnection.setDoInput(true);
                        servletConnection.setDoOutput(true);

                        servletConnection.setUseCaches(false);
                        servletConnection.setDefaultUseCaches(false);
                        servletConnection.setRequestProperty("Content-Type",

                                "application/octet-stream");
                
                        toServlet = new ObjectOutputStream(
                                servletConnection.getOutputStream());

                        /*
                        if (servletConnection.connected) 
                                System.out.println("CONNECTED");
                        else
                                System.out.println("NOT CONNECTED");
                        */

                        toServlet.writeObject(kit);

                        toServlet.flush();
                        toServlet.close();
                }
                catch (MalformedURLException e) {
                        System.out.println("MalformedURLException: " + e);
                        return 1;
                }
                catch (IOException e) {
                        System.out.println("IOException: " + e);
                        return 1;
                }
                catch (Exception e) {
                        System.out.println("Exception: " + e);
                        return 1;
                }

                System.out.println("<< [send] - 0");
                return 0;
        }

        public Vector receive() {
                ObjectInputStream fromServlet = null;
                Vector results = null;

                try {
                        fromServlet = new ObjectInputStream(
                                servletConnection.getInputStream());

                        results = (Vector)fromServlet.readObject();

                        fromServlet.close();
                }
                catch (MalformedURLException e) {
                        System.out.println("MalformedURLException: " + e);
                }
                catch (IOException e) {
                        System.out.println("IOException: " + e);
                }
                catch (Exception e) {
                        System.out.println("Exception: " + e);
                }

                return results;
        }
}

--------------- This is the class that never inits -------------------------

public class Submit extends HttpServlet 
{
        private IBuild builder = null;

        public void init(ServletConfig config) throws ServletException {
                super.init(config);
                        
                try {
                        builder =
(IBuild)Naming.lookup("rmi://grobe/buildAgent");
                }
                catch (Exception e) {
                        System.out.println("Caught exception = " + e);
                        e.printStackTrace();
                }
        }

        public void doGet(HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException {

                doPost(req, res);
                System.out.println("Submit: doGet");
        }

        public void doPost(HttpServletRequest request, 
                        HttpServletResponse response) throws
ServletException, IOException {

                String status = null;
                ObjectInputStream servletIn = null;
                ObjectOutputStream toApplet = null;
                Kit kit = new Kit();

                System.out.println("Submit: doPost");

                response.setContentType("application/octet-stream");

                try {
                        servletIn = new
ObjectInputStream(request.getInputStream());
                        kit = (Kit)servletIn.readObject();
                        servletIn.close();
                }
                catch (Exception e) {
                        System.out.println("doPost Exception: " +
e.getMessage());
                }

                System.out.println("calling submitBuild");
                status = builder.submitBuild(kit);
                System.out.println("status = " + status);
/*
                try {
                        toApplet = new
ObjectOutputStream(response.getOutputStream());
                        toApplet.writeObject(status);

                        toApplet.flush();
                        toApplet.close();

                }
                catch (IOException e) {
                        e.printStackTrace();
                }
*/
        }
}

------------- here's an example of another servlet (explained as ServletB
way up top) that works ------------
public class DBQuery extends HttpServlet 
{
        private IBuild builder = null;

        public void init(ServletConfig config) throws ServletException {
                super.init(config);

                try {
                        builder =
(IBuild)Naming.lookup("rmi://grobe/buildAgent");
                }
                catch (Exception e) {
                        System.out.println("Caught exception = " + e);
                        e.printStackTrace();
                }
        }

        public void doGet(HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException {
        
        }

        public void doPost(HttpServletRequest request, 
                        HttpServletResponse response) throws
ServletException, IOException {

                ObjectInputStream servletIn = null;
                ObjectOutputStream toApplet = null;
                String cmd = new String();
                Vector results = new Vector();

                response.setContentType("application/octet-stream");

                try {
                        servletIn = new
ObjectInputStream(request.getInputStream());
                        cmd = (String)servletIn.readObject();
                        servletIn.close();
                }
                catch (Exception e) {
                        System.out.println("doPost Exception: " +
e.getMessage());
                }

                results = (Vector)builder.doQueries(cmd);

                try {
                        toApplet = new
ObjectOutputStream(response.getOutputStream());
                        toApplet.writeObject(results);

                        toApplet.flush();
                        toApplet.close();

                }
                catch (IOException e) {
                        e.printStackTrace();
                }
        }
}

----------- and it get's called from this type of call from within my applet
----------------

public class SQLQuery
{
        String qryString = null;

        public SQLQuery() {
        }

        public Vector executeQuery(String str) {
                ObjectInputStream fromServlet = null;
                ObjectOutputStream toServlet = null;
                Vector results = new Vector();
                String qryString = new String(str);

                try {
                        String location =
"http://morpheus/servlets/DBQuery";
                        URL servlet = new URL(location);
                        URLConnection servletConnection =
servlet.openConnection();

                        servletConnection.setDoInput(true);
                        servletConnection.setDoOutput(true);

                        servletConnection.setUseCaches(false);
                        servletConnection.setDefaultUseCaches(false);

                        servletConnection.setRequestProperty("Content-Type",

                                "application/octet-stream");

                        toServlet = new ObjectOutputStream(
                                servletConnection.getOutputStream());

                        toServlet.writeObject(qryString);
                        toServlet.flush();
                        toServlet.close();

                        fromServlet = new ObjectInputStream(
                                servletConnection.getInputStream());

                        results = (Vector)fromServlet.readObject();

                        fromServlet.close();
                }
                catch (MalformedURLException e) {
                        System.err.println("Applet MalformedException: " +
e.toString());
                }
                catch (IOException e) {
                        System.err.println("Applet IOException: " +
e.toString());
                }
                catch (Exception e) {
                        System.err.println("Applet Exception: " +
e.toString());
                }

                return results;
        }
}











--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to