----------------------------------------------------------------
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!!!
----------------------------------------------------------------

Basically a resend of the same prob I posted a week ago w/ minor changes,
thought I'd give it another shot here.

Apache JServ 1.0
Apache 1.3.9
Linux/Redhat 6.0
(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 (from the applet). 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
days 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.

An explanation of the attached files.

The SubmitKit class get's called from an actionPerformed method of the
applet. The Submit class is ServletA explained as above (it never inits) and
gets called from the SubmitKit class. DBQuery is one that I call before
Submit and it works (and is almost an exact copy). But forget the order I
call them in. I've tried all, so I doubt it's not because something is being
closed properly.

DBQuery class (servlet) which does work gets called from the SQLQuery class
from withing the applet. This one works fine and is pretty much the same as
what I'm trying with this one.


----------------- 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 class ConfigSys extends JApplet implements ActionListener
{
        Kit kit = new Kit();
        SubmitKit toServl = null;

        public void init() {
                toServl = new SubmitKit();

                createGUI();
        }

//    ... snip snip

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

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

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

----------- This is the class that calls the Submit servlet ---------------
public class SubmitKit
{
        Kit kit = new Kit();

        public SubmitKit() {
        }

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

                try {
                        String location = "http://morpheus/servlets/Submit";
                        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/x-java-serialized-object");
                        //              "application/octet-stream");
                
                        toServlet = new ObjectOutputStream(
                                servletConnection.getOutputStream());

                        toServlet.writeObject(kit);
                        
                        toServlet.flush();
                        toServlet.close();
                }
                catch (MalformedURLException e) {
                        System.err.println("MalformedURLException: " + e);
                        return 1;
                }
                catch (IOException e) {
                        System.err.println("IOException: " + e);
                        return 1;
                }
                catch (Exception e) {
                        System.err.println("Exception: " + e);
                        return 1;
                }
                
                System.out.println("<< [send] - 0");
                return 0;
        }
}

------- here's the servlet that works from an html file but doesn't get
called --------

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 {

                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/x-java-serialized-object");
                //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);
/* not needed at this point ...
                try {
                        toApplet = new
ObjectOutputStream(response.getOutputStream());
                        toApplet.writeObject(status);

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

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

--------- and of course the serializable object being passed into my
SubmitKit class -----

public class Kit implements Serializable
{
        int type = 0;
        int status = 0;

        boolean debug = false;

        String name = null;
        String version = null;
        String build = null;

        // ----

        String label = null;
        String database = null;
        String component = null;
        String platform[] = new String[8];

        String buildDate = null;
        String buildTime = null;
        String prodVersion = null;
        String compVersion = null;

        String appBuildPath = null;
        String compBuildPath = null;

        public Kit() {
        }

        public void setName(String str) {
                name = str;
        }

        public String getName() {
                return name;
        }

        public void setVersion(String str) {
                version = str;
        }

        public String getVersion() {
                return version;
        }

        public void setBuild(String str) {
                build = str;
        }

        public String getBuild() {
                return build;
        }

        public void setType(int val) {
                type = val;
        }

        public int getType() {
                return type;
        }

        public void setStatus(int val) {
                status = val;
        }

        public int getStatus() {
                return status;
        }

        public void setDebug(boolean val) {
                debug = val;
        }

        public boolean getDebug() {
                return debug;
        }
}


---
Gary Grobe <[EMAIL PROTECTED]>


--
--------------------------------------------------------------
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