Perhaps I know absolutely NOTHING about how to properly JAR a file,
but here were my steps:
1) I have a class called ChatGlobals.class whose source code is
configured as so:
[CODE]
package ppowell.val.chat;
public class ChatGlobals {
public static final String chatBrandName = "VÄL CHAT OP";
// DISPLAY VARS
public static final String font = "<font face=\"Georgia, Verdana,
Arial, Helvetica, sans-serif\" size=2>";
public static final String smFont = "<font face=\"Georgia, Verdana,
Arial, Helvetica, sans-serif\" size=1><b>";
public static final String req = "<font
color=cc0000><b>*</b></font>";
// BRANDING
public static final String brand = "Välsignalandet";
public static final String brandHTML = "Välsignalandet";
// HOST VARS
public static final String homeDomain = "http://valsignalandet.com";
public static final String cgiDomain =
"http://valsignalandet.com/cgi-bin/cgiwrap/ppowell";
public static final String menubarDomain =
"http://valsignalandet.com/cgi-bin/cgiwrap/ppowell/menubar.cgi";
public ChatGlobals() {}
}
[/CODE}
2) I next "jarred" the clases up into one .jar file using
command-line:
[code]jar cvf chat.jar *.class[/code]
3) I uploaded the newly-created JAR file into /ppowell/val/chat on the
remote server as /ppowell/val/chat/chat.jar
4) I added page imports to chat.jsp:
[code]
<%@ page import="java.io.*, java.net.*, java.util.*,
java.util.regex.*" %>
<%@ page import="javax.servlet.*, javax.servlet.http.*" %>
<%@ page import="ppowell.net.*, ppowell.util.*, ppowell.val.chat.*" %>
[/code]
5) I uploaded chat.jsp to /ppowell/val/chat to become
/ppowell/val/chat/chat.jsp
When I call http://www.mycgiserver.com/~ppowell/val/chat/chat.jsp I
get this:
[code]
500 Servlet Exception
Note: sun.tools.javac.Main has been deprecated.
/~ppowell/val/chat/chat.jsp:16: Undefined variable or class name:
ChatGlobals
errorMsg = "<li>" + ChatGlobals.font + "<font color=cc0000>Please
enter a nickname</font></font><p>";
[/code]
Perhaps I just plain don't understand how to do this JAR/JSP thing,
but I thought I got it right. You zip it up, put it in the right
directory, you reference by page imports and it works unless you have
class-related exceptions.
What could I have missed that perhaps someone more astute in Java than
I, which at this point is about 90% of the known universe, can find?
Phil
Andrew Thompson - 18 Feb 2004 10:06 GMT
> ...how to properly JAR a file,
..
> 1) I have a class called ChatGlobals.class whose source code is
> configured as so:
>
> [CODE]
> package ppowell.val.chat;
....
> 3) I uploaded the newly-created JAR file into /ppowell/val/chat on the
> remote server as /ppowell/val/chat/chat.jar
You do not load the jar to the same directory
structure as the class, put it at '/', rather than
'/ppowell/val/chat/'. Also, I _think_ they
need to be inside WEB-INF to be accessible
to .jsp's.
> 5) I uploaded chat.jsp to /ppowell/val/chat to become
> /ppowell/val/chat/chat.jsp
And then the .jsp can go anywhere.
If I have undestood the problem correctly,
attending to those points should fix it.
--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
Phil Powell - 18 Feb 2004 17:04 GMT
> > ...how to properly JAR a file,
> ..
[quoted text clipped - 12 lines]
> need to be inside WEB-INF to be accessible
> to .jsp's.
I originally put the JAR file into /WEB-INF/lib and was informed by
the remote hosting provider that you cannot put JAR files in there for
them to be used by JSP's within the existing MCS framework; you have
to put them in your "/" directory (which is an alias for
/WEB-INF/classes/ppowell in my case). So that's why the JAR file is in
"/" along with the JSP script now.
> > 5) I uploaded chat.jsp to /ppowell/val/chat to become
> > /ppowell/val/chat/chat.jsp
[quoted text clipped - 3 lines]
> If I have undestood the problem correctly,
> attending to those points should fix it.
Actually it halfway fixed it. Initial running of
http://www.mycgiserver.com/~ppowell/chat.jsp will run fine including
usages of static properties in the ChatGlobals class found in the JAR
file (otherwise it would throw ClassNotFoundException errors on things
like "ChatGlobals.font" and "ChatGlobals.myDomain"). However, upon
submitted a nickname it will then instantiate a NicknameBin class
object, which is a Singleton Vector class found also in the same JAR
file. THAT throws the NoClassDefFoundError this time.
So while it's one step forward it's five steps back now.
Phil
Phil Powell - 10 Mar 2004 14:48 GMT
Found out the problem all along was that my remote hosting provider
does not allow for any JAR files, so all classes have to be separate
and in the same root directory.
Phil
> > > ...how to properly JAR a file,
> ..
[quoted text clipped - 40 lines]
>
> Phil
Raj - 30 Mar 2004 15:00 GMT
Simply move to a different host
-> www.thebeancontainer.com - your java host