JSP/JavaBeans/Websphere

Discussions

Web tier: servlets, JSP, Web frameworks: JSP/JavaBeans/Websphere

  1. JSP/JavaBeans/Websphere (4 messages)

    I am using a JavaBean in a JSP file. When running Allaire JRun 3.0, everything works fine. When I port the JSP files and class files to Websphere 3.5 (3.5.2 actually), I cannot get the bean to load. I suspect this has something to do with the "fully qualified pathnames" that must be used both in defining the package which the beans are in (i.e., the package statement in each bean) and in the CLASS property of the USEBEAN tag. When I inspect that actual class file of the compiled JSP, it contains the text "cannot load bean." and Jasper errors out saying it can't find any info about a specific property in the bean. (Websphere, you will recall, does not use the same "web-inf" subdirectory structure that many other app servers do.)

    I have tried putting the Jar files in the Servlets subdirectory directory in the Web App directory, at root level in the Web App directory, and many other places as well. Nothing works.

    Just in case I am losing my sanity here, if I have the files in a directory like c:\AppName\package_name.jar, what would be the "fully qualified pathname" for that? I presume the JavaBean syntax would be

    package package_name;

    While the USEBEAN syntax would be:

    <jsp:usebean id="TheBeanName" class="package_name.TheBeanClassName" scope="session"/>

    Now for a really dumb question: why do so many examples--but definitely NOT all of them--use fully qualified paths of the form "com.some_name.package" ? What kind of directory structure does that address?

    Thanks for your help!

    Threaded Messages (4)

  2. JSP/JavaBeans/Websphere[ Go to top ]

    Lets answer your questions going backwards. First off, the naming scheme for packages is quite arbitrary, but the standard naming principle is that you reverse your host name and append the package name. The naming helps resolve class naming conflict issues (i.e. in java.sql.Date vs. java.util.Date) so you can distinguish two classes with the same name by its package name. So even if this is for personal development, you should make up a host name for yourself (i.e. com.ronhodges.foo).

    For example, you can implement your own Date class and if people preferred your Date class over Sun's, they can import com.ronhodges.Date

    This means that you should create a directory structure off your classpath such that: %CLASSPATH%/com/ronhodges

    I assume you're working in a Windows environment. Suppose you have c:\java\classes in your classpath. If you put your own Date class with a pacakge statement com.ronhodges, then this file should be located in c:\java\classes\com\ronhodges\(Date.class)

    Even if you made a package file out of it, say mypackage.jar, the location of the class is still in com.ronhodges

    So if you wanted to import this date class like in your useBean tag, the syntax isn't:

    <jsp:useBean id="TheBeanName" class="mypackage.Date" scope="session"/>

    it's

    <jsp:useBean id="TheBeanName" class="com.ronhodges.Date" scope="session"/>
     
    Hopefully this will allow Websphere to find your bean. Hope this helps!
  3. JSP/JavaBeans/Websphere[ Go to top ]

    This is an excllent explanation. What I had done when I put together the Jar files was this:

    given c:/program files/allaire/jrun/servers/defaut/myapp/web-inf/classes/mydir/*.class

    I had at the /classes level created a Jar file with the following syntax:

    JAR cf0 myjarfile.jar mydir

    This supposedly pulls the whole subdirectory--the package--into the Jar file. It certainly works in Allaire JRun 3.0, I can delete mydir/*.class and remove mydir and just have the Jar file, restart the server, and everything is hunky dory. :-)

    To proceed with the example, instead of

    com.ronhodges.mydir.ASpecificClass.class

    I should be able to say

    com.ronhodges.myjarfile.jar

    However, this doesn't seem to work with Websphere. But I have not given up hope, and I have a few ideas based on your explanation that I can try. My one lesson out of all this is that Websphere really sucks. Supposedly it just got J2EE certified, but unless they changed a bunch of things, I don't see how.

    Thanks for your help!

    Ron
  4. JSP/JavaBeans/Websphere[ Go to top ]

    yeah, before this whole J2EE business, i liked JRun 2.2 when it wasn't owned by Allaire =P

    now i use Orion as my production level server because everything's so manual. it fits nicely using Tomcat as my development environment and Orion as my production environment. If it works in Tomcat, then hey, it should work in any other J2EE compliant (or at least claiming to be meeting J2EE specifications) server.

    anyway, since it looks like you are organizing your files in web application format, you can try moving the jar file to the myapp/lib directory. that's where all packages local (i believe) to the webapp should reside. you shouldn't have to put it explicitly in your classpath unless you need it at compile-time and not runtime (i haven't verified this myself but I think it may be the case)

    also, if you want the package to be global to the server and automatically loaded at runtime, then try looking for a lib directory underneath your server's main directory. I.e. Tomcat 3.2.1 is installed on my machine as c:\tomcat
    I put global packages in c:\tomcat\lib

    Orion 1.4.7 is installed on my machine as c:\orion
    I put global packages in c:\orion\lib

    So hopefully this is a J2EE specification and you'll find a place to put your jar files

    Hope this helps =P
  5. JSP/JavaBeans/Websphere[ Go to top ]

    Thanks! Yeah, my impression of Websphere is that it has alien DNA in it...