• Post Reply Bookmark Topic Watch Topic
  • New Topic

J2EE PleASE HELP ME  RSS feed

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using linux, and I can't get this to work. I have jdk1.3 in /usr/javav/jdk1.3.0_02 , and I have the j2ee in /usr/local/Java/j2sdkee1.3. I followed the instructions from sun's site, and I have the JAVA_HOME variable configured correctly, I'm not so sure about the classpath though. I don't know where the drivers are for the database, which is cloudscape. Do I need to use them? Every time I try to compile a program with a package from j2ee, the compiler can't find it. I will do anything if somebody can get this working correctly.
Thanks,
Sean
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean,
Could you post the error stack trace you are getting when you compile the program using J2EE.
I bet you donot have %J2EE_HOME%/lib/j2ee.jar in your classpath variable.Try adding the jar file and then compile it and see.It should work.
As regards Cloudscape DB, I think it is bundled with J2EE Installation.So you donot have to concerned about its driver. However, it you want to try different database like Oracle8i, you will need to download the driver and configure it for your installation.If you are keen to install Oracle8i for your J2EE reference implementation, please feel free to mail me or post your requirement here.
Hope this helps.
Regards,
Sandeep

  • Sun Certified Programmer for Java 2 Platform Scored 93 per cent
  • Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  • IBM Enterprise Connectivity with J2EE Scored 72 per cent
  • Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  • [This message has been edited by Desai Sandeep (edited May 12, 2001).]
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
Thanks for your help. I'll give it a try. The linux installaition instructions don't even mention the J2EE_Home variable. I noticed it when I was looking at the Windows instructions. All the linux version talks about is JAVA_HOME and J2EECLASSPATH_HOME which said it was for the drivers. I wondered how the compiler could find the appropriate classes. I'll give this a try and if it doesn't work, I'll give you the full trace, and all my settings. Thanks again for your help. I've got this book on Servlets that I want to start using, yet it's difficult to code without the environment setup.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
I'm afraid it doesn't work. I believe it's something to do with the path or classpath because when I try to right a test class that imports the javax.mail package, this is the error I get:
package javax.mail.* does not exist.
Once again I'm running linux. Under the /etc/profile, I have my path listed as follows:
PATH="$PATH:/usr/x11R6/bin:/usr/java/jdk1.3.0_02/bin:"
This is the only environmental variable I edited in order to get the j2se working. It works but perhaps not correctly becuase I can't use gui's due to a font missing problem, but everything else works fine, and all the awt, and swing classes compile fine.
In the same file, I added the following variables:
JAVA_HOME="/usr/java/jdk1.3.0_02/bin:"
J2EE_HOME="/usr/local/Java/j2sdkee1.3/bin:", and then I added the J2EE_Home to the path variable and that didn't work. I haven't touched my classpath, as I didn't need to with the j2se. Can I just add it to the /etc/profile like the regular Path? Thanks for your help.
Okay, here's a curveball. If I compile the test class with the following, it compiles,
javac -classpath /usr/local/Java/j2sdkee1.3/lib/j2ee.jar test.java
but if I add a main method and write a simple program to send an email, it says the
following:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message
I'm lost.
[This message has been edited by Sean Casey (edited May 12, 2001).]
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean,
From all the paths that you have mentioned, I couldn't see any any environmental variable pointing to the j2ee.jar file.
You have 2 options here:

  1. Set J2EE_HOME="/usr/local/Java/j2sdkee1.3"
  2. Edit the classpath and add j2ee.jar at the end - "/usr/local/Java/j2sdkee1.3/lib/j2ee.jar"


  3. Okay, here's a curveball. If I compile the test class with the following, it compiles,
    javac -classpath /usr/local/Java/j2sdkee1.3/lib/j2ee.jar Test.java

    This is working as you have provided the j2ee.jar file in the classpath.This is precisely what would need to do, by using one of the methods listed above.

    but if I add a main method and write a simple program to send an email, it says the following:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message

    This is happening because the j2ee.jar is not visible, while running the program.If you provide the classpath like the way you did using javac, it will run with success.
    I would recommend you use first option to set the classpath.
    Let me know, if you still face problems.
    -- Sandeep
    [This message has been edited by Desai Sandeep (edited May 12, 2001).]
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just forgot to mention J2EE_HOME environmental variable is on the Windows installation.From your earlier post, it looks like on Linux, the variable has to be J2EECLASSPATH_HOME.To know what it is doing and also to know about the relevant environmental variable in your system, look into the bin directory of your J2EE installation for the following files:

  • j2ee.bat
  • setenv.bat

  • (Hope the names are same in the Linux version )
    In my installation, j2ee.bat has the following code:

    Clearly it needs a J2EE_HOME variable to be defined.In my case it is J2EE_HOME = C:\j2sdkee1.2.1 -- Note it is not C:\j2sdkee1.2.1\bin!!
    Then it calls setenv.bat.This is what it does :

    It has set the j2ee.jar file in my classpath, and also included my system classpath that was present earlier - %CLASSPATH%.
    Hope this helps.
    -- Sandeep
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
Thank you so much for your help. I'm a long way away though. I found two files I think you were referring to: setenv.sh and userconfig.sh. I had put some J2EE_HOME variables in the /etc/profile and so after I edited the two files you told me too, I erased the stuff I put in the /etc/profile. I screwed something up because now the j2se doesn't work. I've rid my system of all java. I will go eat dinner, and then I will start fresh. I decided to start over because I've added so much to these configuration files, that I don't know what belongs and what doesn't. I'll keep you posted. Thanks.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
I'm back. I re-installed j2se successfully in /usr/java/jdk1.3.0_02/
Then, I installed the j2se in /usr/java/jdk1.3.0_02/j2sdkee1.3/
Following Sun's directions closely, and keeping your pointers in mind this is what happened. In the bin directory there is a setenv.sh and a userconfig.sh. The instructions say to edit the userconfig.sh. In there I edited the Classpath, and it said it didn't need the location of j2se, or the j2ee jars. It said all it needed was the db drivers. So I did that, and then put the JAVA_HOME=/usr/java/jdk1.3.0_02. That takes care of userconfig.sh. It didn't say to do anything to setenv.sh, but I looked in it and it was a long confusing script. By looking at it, it seemed that it configured the parameters that you mentioned above by getting info from the userconfig.sh. Since I still couldn't compile anything, at the top of setenv.sh I included the info you told me to: the J2EE_HOME, LIBDIR, and J2EEJARS. Program still won't compile. But I can start the j2ee server successfully. I'm stumped here. Does anyone know what I should do with setenv.sh??? Thanks for any help.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Help me. I'm getting really desperate over here.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean,
I think I have confused you too much with lots of details.I suppose, the first priority is to get this stuff working.
Add the following paths in your System classpath for J2SE and J2EE libraries respectively

  1. /usr/java/jdk1.3.0_02/lib/tools.jar
  2. /usr/java/jdk1.3.0_02/j2sdkee1.3/lib/j2ee.jar

  3. You may add these files at the end of your System classpath.
    I hope you have already set the PATH to the respective bin!!

    1. /usr/java/jdk1.3.0_02/bin
    2. /usr/java/jdk1.3.0_02/j2sdkee1.3/bin

    3. Hope this helps,
      -- Sandeep
      [This message has been edited by Desai Sandeep (edited May 13, 2001).]
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SANDEEP YOU ARE THE GREATEST!!!
I'm not sure if everything is working, but my program featuring the javax.mail package compiled and worked! In my /etc/profile I added a Classpath with what you told me to, and then I appended the system classpath to it, and everything seems to be working. No need to check everything else yet. Thank you so much!!! This has been frustrating me for the past few days. I'm still not sure about the setenv.sh, but why question it right now as things are starting to work. Thanks again!!!
-Sean
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean,
Nice to know that your program has worked.However, as I said earlier the method that we employed is very crude - manipulating System Classpath is not the best thing to do, especially when you have been provided with bat/sh files for setting the required jars.
Post the sh files here - or if it is too long mail me at my email address.We will pin it down
-- Sandeep
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
Thanks again!
Here are the userconfig.sh and setenv.sh of the bin directory in my j2ee. I'll put each one in a different post.
userconfig.sh:
#J2EE_CLASSPATH is appended to the classpath referenced by the ejb server.
#J2EE_CLASSPATH must include the location of the JDBC driver classes(except for the Cloudscape driver shipped with this release).
#Each directory is delimited by a colon.
J2EE_CLASSPATH=/opt/oracle/jdbc:/usr/local/db/driver.zip
export J2EE_CLASSPATH
#Sandeep, I placed the JAVA_HOME here because I wasn't sure what
#the script was doing
JAVA_HOME=/usr/java/jdk1.3.0_02
export JAVA_HOME
#JAVA_HOME refers to the directory where the Java(tm) 2 SDK
# Standard Edition software is installed.
if[-z "$JAVA_HOME"]
then
JAVA_HOME=/usr/java/jdk1.3.0_02
export JAVA_HOME
fi
#that's the end of the userconfig.sh
Sandeep, just for reference, when I installed j2se, the only thing I modified was the PATH in /etc/profile . So right now at the top of /etc/profile it reads as follows:
PATH="$PATH:/usr/X11R6/bin:/usr/java/jdk1.3.0_02/bin:/usr/java/jdk1.3.0_02/j2sdkee1.3/lib/j2ee.jar:/usr/java/jdk1.3.0_02/j2sdkee1.3/bin:"
export PATH
CLASSPATH="$CLASSPATH:/usr/java/jdk1.3.0_02/lib/tools.jar:/usr/java/jdk1.3.0_02/j2sdkee1.3/lib/j2ee.jar:"
export CLASSPATH
Sandeep, I had never touched the Classpath (even with j2se) until you mentioned it a couple of posts ago, so all that is new.
I'll follow this post with the setenv.sh just for brevity. Thanks again.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep, here is the setenv.sh of the /bin directory of j2ee.
setenv.sh:
#Enviroment variables needed to run....
#Sandeep, I added these first four in an attempt to help earlier
#problems. The real setenv.sh begins with BINDIR=
J2EE_HOME=/usr/java/jdk1.3.0_02/j2sdkee1.3
export J2EE_HOME
LIBDIR=$J2EE_HOME/lib
export J2EE_HOME #I just noticed this error!!!
J2EEJARS=$LIBDIR/j2ee.jar
export J2EEJARS
CPATH=$CLASSPATH:$J2EEJARS:
export CPATH
BINDIR='dirname $0'
. $BINDIR/userconfig.sh
HOSTNAME='uname -n'
if[ -n "$BINDIR" ]
then
J2EE_HOME='cd $BINDIR/..> /dev/null 2>&1 && pwd'
export J2EE_HOME
fi
if [ -z "$J2EE_HOME" ]
then
error "Can not set environment variable J2EE_HOME"
fi

if[- z "$JAVA_HOME]
then
error "Please set JAVA_HOME to the installation directory of
Java2, SDK version 1.3"
fi
if[ -z "$JMS_HOME"]
then
JMS_HOME=${J2EE_HOME}
fi
LIBDIR=$J2EE_HOME/lib
LOCALEDIR=$J2EE_HOME/lib/locale
CLOUDSCAPE_INSTALL=$LIBDIR/cloudscape
CLASSESDIR=$LIBDIR/classes
JMS_CLASSESDIR=$JMS_HOME/classes
JAVART=$JAVA_HOME/jre/lib/rt.jar
JAVATOOLS=$JAVA_HOME/lib/tools.jar
SYSTEMJARS=$JAVART:$JAVATOOLS
J2EEJARS=$LIBDIR/j2ee.jar
JAVAHELPJARS=$LIBDIR/jhall.jar
# JMS DB PATH must end in slash to specify a directory
JMS_DB_PATH=${J2EE_HOME}/repository/${HOSTNAME}/db/
SYSTEM_LIB_DIR=${LIBDIR}/system
JMS_RI_JDBC=${SYSTEM_LIB_DIR}/cloudscape.jar:${SYSTEM_LIB_DIR}/tools.jar
CLOUDJARS=$JMS_RI_JDBC:$CLOUDSCAPE_INSTALL/RmiJdbc.jar:$CLOUDSCAPE_INSTALL/client.jar
CPATH=$CLOUDJARS:$CLASSESDIR:$JMS_CLASSESDIR:$J2EEJARS:$LOCALEDIR:$J2EE_CLASSPATH:$JAVATOOLS:$JAVAHELPJARS
export CPATH
WEll, Sandeep that is it. I've noticed I've never set any JAVA_HOME variable when i set up j2se. THIS may be one of my problems. Let me know what you think. Thanks again.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean,
was facing access problems with Javaranch.com yesterday- Apologies for the delay.
This is what you need to do with userconfig.sh and setenv.sh.

  1. Remove the j2ee.jar and tools.jar from your System classpath to test if this method is working
  2. Let the System PATH point to

    • /usr/java/jdk1.3.0_02/bin
    • /usr/java/jdk1.3.0_02/j2sdkee1.3/bin
    • [list]Edit userconfig.sh and set JAVA_HOME variable:

      You may not edit J2EE_CLASSPATH, if you have decided to use Cloudscape - It is bundled with the J2EE Reference Implementation
      [/list][list][OPTIONAL]Edit setenv.sh and set J2EE_HOME variable:

      [/list]
    • Run setenv.sh and userconfig.sh, everytime before using J2EE or JSDK.

    • Let me know, if it works.
      -- Sandeep

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
I'll give it a try and let you know how I made out. Don't worry about not getting back to me promptly. I really do appreciate all your help. I'd be back at square one if not for you. Thanks.
Sean
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
it didn't work. I commented out the classpath I added earlier, and then everything was already set as you had pointed out. That classpath was the only one that pointed to the /lib/tools.jar of j2se and j2ee.jar. So I think that I need to include that somewhere. Thanks for your help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!