You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Sheldon Wosnick <sw...@hotmail.com> on 2000/07/22 18:12:56 UTC
RE: Visual Age config (some suggestions)
Sergei,
I have been looking a little more closer at your code and at the steps you
recommend to get the JSP page compiled code into VAJ for debugging. I have a
couple of suggestions that may streamline this for you and make it easier
for the user to install/get working.
1. You mention that you need to:
>
> Make sure to add "Tomcat Compiled JSP" after first successful JSP
>compilation -
> without it you can't debug JSPs;
Actually, you can preset the Extra classpath for
org.apache.tomcat.startup.Tomcat (from the properties on this class) to the
project_resources directory that WILL be created on the first page
compilation as part of your code. Since you are using a
project/project_resources name of "Tomcat Compiled JSP" all you need to do
(I think) is add the following DIRECTORY to the Extra classpath:
.\Tomcat Compiled JSP
That way the corrosponding project in the IDE is already on the classpath
for org.apache.tomcat.startup.Tomcat, once it actually gets created, and you
don't have to remember to add the classpath later which may lead to
confusion.
Since you seem to indicate in other posts that you are familiar with the
WebSphere Test Environment (WTE) :-) check out the Extra classpath setting
for com.ibm.servlet.SERunner to get an idea.
Since the project in the IDE has not been "created" yet, you of course can't
set the classpath at the project level. The way described works around that.
2. Consider using relative classpaths as I described in step 1. Since the
concept of "current directory" translates in our IDE to the path to the
project_resources directory, you can use the "." and ".." notation. This
becomes useful if you want to version this entire project and give to your
co-workers who may have a different path to VA/Java. No other configuring
would be required. That is why in my Tomcat articles I use relative paths
since it eliminates the need to know WHERE VA/Java actually lives.
3. Same goes for setting tomcat.dir or tomcat.home. You should be able to
get away with simply setting:
tomcat.home=.
tomcat.dir=.
since this accomplishes the same thing (in Tomcat 3.1) at runtime to:
"tomcat.dir=c:\IBMVJava2\ide\project_resources\Tomcat"
since, again, c:\IBMVJava2\ide\project_resources\Tomcat IS your current
directory in all cases relative to the placement of the start/stop classes.
It means the user need not set this but you can give them a .dat file with
the feature or project already configured.
4. You may want to consider what might happen if the user actually VERSIONS
the project "Tomcat Compiled JSP" (though no reason they should, but they
could). If so, I think your import may fail because you first need to create
a scatch edition at the project and package levels. You can easily build
this into your code as another step to do. Or if the code is imported as one
workspace owner but another workspace owner uses the environment the project
will fail to get created.
(I am not 100% certain of step 4 happening as I say, just a guess :-)
This would make it a bit more robust and again make it easier to use "out of
the box" no matter who the workspace owner is and what the state of these
projects/packages.
I knew it worked for me in the WTE :-)
Regards,
Sheldon
>From: Sergei Lilichenko <sl...@tradepayment.com>
>Reply-To: general@jakarta.apache.org
>To: "'James_Gu@ex.cv.hp.com'" <Ja...@ex.cv.hp.com>, Sergei Lilichenko
><sl...@tradepayment.com>, general@jakarta.apache.org
>CC: "'lilichen@ix.netcom.com'" <li...@ix.netcom.com>
>Subject: RE: Visual Age config
>Date: Thu, 20 Jul 2000 15:22:34 -0700
>
>Here is our internal document describing the setup. I didn't modify it so
>you might find some references to things you don't do in your environment.
>But the steps to install Tomcat should be correct.
>
>As I mentioned in my previous post, this might not work right away with
>the latest build of Tomcat. If you find what's the problem, please let me
>know.
>
>I hope this helps.
>
>- Sergei Lilichenko
>lilichen@ix.netcom.com
>------------------------------------------------------
> Configuring Apache Tomcat 3.1 Beta and VisualAge 3.02 on NT
>
> Authors: Sergei Lilichenko and Jarlath O'Carroll
> TradePayment Inc.
>
> Installing Tomcat (http://www.apache.org):
>
>1. Install Tomcat (3.1 Beta)
> a. First unzip the installer from the default location
> (c:\Jakarta-tomcat) to some local directory
> b. Run the Tomcat installer from that directory. Set everything
> to the default choices.
> c. Test your installation. From a command window, cd to the
> c:\jakarta-directory\bin\ directory and start Tomcat by running
> startup.bat.
> This window will remain open. Then open a browser and point it to
> your Tomcat server by typing http://localhost:8080/. If all
> goes well this should load the default Tomcat page. Verify that the
> servlet examples work.
>
> If you don't see this page please check your install instructions
> for Tomcat and the Tomcat Readme files for NT install and
>configuration.
> Often the problem is CLASSPATH related. You can take a look at
> tomcat.bat to see what are the environment variables required
> (i.e. JAVA_HOME).
> d. After a successful test exit Tomcat by typing shutdown in the command
> window.
>
>2. Intall VisualAge:
> a. Get the zip file from O:\Installers\vaj302-j20-upgrade.zip.
> Don't use 3.0 from CD.
> b. Unzip the file to a local directory and run setup to do a full
>install.
> If installation fails make sure you uninstall it completely and
> reboot the machine;
> During installation pick "local repository" option - you will be
> able to switch to "server repository" later on. Pick the defaults
> otherwise;
>
>3. Install Tomcat inside VisualAge:
> a. Start VAJ and choose go to workbench.
> Check that you are registered as a user for the server repository.
> Choose menu item workspace->"change workspace owner", then select
> your name from the dialog of choices.
> b. Create a project in VAJ called "Tomcat". Select any project, right
> click and choose "add Project" and create a new project called
>Tomcat.
> It will create a directory Tomcat under
>c:\IBMVJava2\ide\project_resources;
> c. Go to windows explorer, and copy (better - move) the whole Tomcat
>tree
> from where it was installed (c:\Jakarta-tomcat) to
> c:\IBMVJava2\ide\project_resources\Tomcat.
> e. Go back to VAJ, select Tomcat project, right click and select Import.
> Then select the jar files radio button.
> Navigate to the the /Tomcat/lib/ directory and import in the
> following order: servlet, xml, webserver and jasper.jar files.
> f. Under the projects tab in VAJ, select the class
> org.apache.tomcat.startup.Tomcat and bookmark it by clicking on the
> bookmark icon on the upper right corner of the window - you can use
> this bookmark whenever you wish to select the Tomcat class quickly.
> g. Select Tomcat project, right click and add Project. Select the
> "add project from repository" radio button, and click on projects
> that will be reference by your servlets/jsps.
>
>4. Install VAJ compiler class for Tomcat
> This is a step required to bypass a problem with Tomcat not knowing
> about specific features of VAJ (having .class part of the repository,
> not the file system).
>
> a. Add feature. Go to File -> Quick Start -> Features -> Add Feature
> and add IBM IDE Utility class library;
> b. Add compiler package com.tradepayment.vaj. Select the Tomcat project,
> RightClick -> Add -> Package, select "Add packages from the
>repository"
> and choose "com.tradepayment.vaj". Select the edition of that package
> labeled "GOOD AS OF ..." with the latest date.
> c. Add classpaths. Select Tomcat class (use the bookmark you made),
> Right Click -> Properties -> Class Path -> Edit Project Path, and
> add "IBM IDE Utility class library", "IBM IDE Utility local
> implementation", Tomcat, and all your projects to the list of
>projects.
>
> Make sure to add "Tomcat Compiled JSP" after first successful JSP
>compilation -
> without it you can't debug JSPs;
> d. Define a property variable. Select the Tomcat class,
> right click and select Properties, then select the Program tab,
> and type in the following property name definition in the Properties
> box: "tomcat.dir = c:\IBMVJava2\ide\project_resources\Tomcat".
> e. Edit web.xml file. Go to windows explorer and open
> c:\IBMVJava2\ide\project_resources\Tomcat\conf\web.xml for
> Find the lines saying "uncomment the following to use Jikes for JSP
> compilation" and uncomment them. Don't forget to uncomment the
> closing of comments (-->). Substitute
> "org.apache.tomcat.servlets.NoInvokerServlet" with
> "com.tradepayment.vaj.VAJJavaCompiler".
>
>5. Running Tomcat
> a. To run Tomcat select Tomcat class, right click and select run.
> (Use the bookmark for speedy access). A Console window will open to
> show that you have a Tomcat process running. Verify that there are
> no error messages on the screen.
> b. To stop Tomcat you can make a shortcut to the shutdown.bat file in
> Tomcat's bin directory and associate a hot key with that.
>
>6. Debugging JSPs
> This process should be pretty simple comparing to the one described
> in IBM's white page. Once you started seeing JSPs compiled and
> displayed there will be a project created called "Tomcat Compiled
>JSPs."
> If you open it you will see some packages and inside those classes
> with mangled names. For each JSP there is at least one class. Pick
> the one with the highest number at the end and put a break point
> where you would like to start debugging it
> (normally, inside _jspService() method). Next time you load this JSP
> a debugger should pop up and you can start debugging. Remember to
> put a breakpoint into the new class every time you change the JSP.
>
> You might want to periodically delete packages from
> "Tomcat Compiled JSPs" project and
> <TOMCAT_HOME>/work/localhost_8080 to give Tomcat a fresh start.
>
>7. Common problems and solutions
> Problem:
> - I just created a servlet and Tomcat returns error page saying
> "/servlet/MyServlet - null";
> Solution:
> - Check the scope of that class. If it doesn't have any, just has
> "class MyServlet extends..." then it won't be visible to Tomcat.
> You need to change it to "public class MyServlet extends ..."
>
> Problem:
> - I deleted all classes from Tomcat Compiled JSPs project, and
> now VAJ complains about not being able to find a JSP class.
>
> Solution:
> - Also delete files from under C:\IBMVJava2\ide\project_resources\
> Tomcat\work\localhost_8080 directory.
>--------------------------------------------------------------------------
>Here is the class you need to have to do the compilation:
>--------------------------------------------------------------------------
>package com.tradepayment.vaj;
>
>import java.io.*;
>import java.util.StringTokenizer;
>
>import com.ibm.ivj.util.base.*;
>
>/**
> * Insert the type's description here.
> * Creation date: (4/25/00 9:18:30 AM)
> * @author: Sergei Lilichenko
> */
>public class VAJJavaCompiler implements
>org.apache.jasper.compiler.JavaCompiler {
> private String outDir;
>
> private final static String TOMCAT_DIR_PROPERTY="tomcat.dir";
>
> private final static String TOMCAT_DIR;
> static
> {
> TOMCAT_DIR = System.getProperty(TOMCAT_DIR_PROPERTY);
> if( TOMCAT_DIR == null )
> {
> System.err.println( "Property '" +
>TOMCAT_DIR_PROPERTY + "' is not found." );
> }
> }
>
> private final static String PAGECOMPILE_PROJECT_NAME = "Tomcat
>Compiled JSP";
>
> private PrintWriter out;
> private Workspace ws;
>/**
> * VAJJavaCompiler constructor comment.
> */
>public VAJJavaCompiler() {
> super();
>}
>/**
> * This one actually does the work.
> */
>public boolean compile(String source)
>{
> //--- Different versions of Tomcat do different things here.
> String inFileName = source.indexOf(':') > 0 ?
> source : (TOMCAT_DIR + File.separator + source);
>
> if( ! connectToWorkspace() )
> {
> out.println("\nFailed to connect to workspace.");
> return false;
> }
>
> Type [] result = importFileInProject(inFileName,
>PAGECOMPILE_PROJECT_NAME);
> if( result == null )
> {
> return false;
> }
>
> ExportCodeSpec exportSpec = new ExportCodeSpec();
>
> for( int i=0; i < result.length; ++i )
> {
> result[i] = getTypeForType(ws, result[i]);
> }
>
> exportSpec.setExportDirectory( outDir );
> exportSpec.setTypes( result );
> exportSpec.includeClass(true);
> exportSpec.includeClassDebugInfo(true);
> exportSpec.includeJava(false);
> exportSpec.includeResources(false);
> exportSpec.overwriteFiles(true);
> exportSpec.useSubdirectories(true);
>
> try
> {
> ws.exportData(exportSpec);
> }
> catch( IvjException e )
> {
> reportErrors( out, e );
> try
> {
> result[0].openBrowser();
> }
> catch( IvjException openException ) {}
>
> return false;
> }
> catch( InternalError e )
> {
> //--- This is IBM's problem - usually we shouldn't
>catch this kind of error.
> out.println( e );
> return false;
> }
>
> return true;
>}
>/**
> * Connects to the workspace
> * Creation date: (4/25/00 10:02:07 AM)
> * @return boolean
> */
>private boolean connectToWorkspace() {
> ws = ToolEnv.connectToWorkspace();
> return ws != null;
>}
>/**
> * returns the class name (without package name)
> * Creation date: (4/25/00 12:00:44 PM)
> * @return java.lang.String
> * @param fileName java.lang.String
> */
>private String getClassNameFromFileName(String absoluteFileName)
>{
> File file = new File( absoluteFileName );
>
> String fileName = file.getName();
>
> int index = fileName.lastIndexOf(".java");
> if( index <= 0 )
> return "unknown";
>
> return fileName.substring(0, index);
>}
>/**
> * Internal function to get around a problem in VAJ
> * Creation date: (4/17/00 3:25:34 PM)
> * @return com.ibm.ivj.util.base.Type
> * @param type com.ibm.ivj.util.base.Type
> */
>private static Type getTypeForType( Workspace ws, Type type)
>{
> //--- This is done to bypass a bug in VAJ 3.02 1.2 which
> //--- causes InternalError to be thrown if you give the Type
>received
> //--- from Workspace.importData() to the exportSpec.
> Type result = null;
>
> String typeName = type.getQualifiedName();
> result = ws.loadedTypeNamed(typeName);
>
> if( result == null )
> {
> System.err.println( "Wasn't able to find type: " + typeName
>);
> result = type; //--- What else can we do?
> }
>
> return result;
>}
>/**
> * Imports files in the project, creating a new project if necessary.
> * Creation date: (4/25/00 10:00:21 AM)
> * @return boolean
> * @param file java.lang.String
> * @param projectName java.lang.String
> */
>private Type [] importFileInProject(String file, String projectName)
>{
> Project project = ws.loadedProjectNamed(projectName);
>
> if( project == null )
> try
> {
> project = ws.createProject( projectName, true);
> }
> catch( IvjException e )
> {
> out.println( e );
> return null;
> }
>
> ImportCodeSpec importSpec = new ImportCodeSpec();
>
> importSpec.setJavaFiles( new String [] { file } );
> importSpec.setDefaultProject( project );
>
> Type [] result = null;
> try
> {
> result = ws.importData(importSpec);
> if( result == null )
> {
> out.println( "Nothing was imported." );
> return null;
> }
> }
> catch( IvjException e )
> {
> reportErrors( out, e );
> return null;
> }
>
> return result;
>}
>/**
> * Report error
> * Creation date: (4/18/00 10:06:39 AM)
> * @param writer java.io.PrintWriter
> * @param e com.ibm.ivj.util.base.IvjException
> */
>private static void reportErrors(PrintWriter writer, IvjException e)
>{
> String[] errors = e.getErrors();
> for (int i = 0; i < errors.length; ++i)
> {
> System.err.println(errors[i]);
> writer.println( errors[i] );
> writer.flush();
> }
> return;
>}
>/**
> * setClasspath method comment.
> */
>public void setClasspath(String classpath) {}
>/**
> * setCompilerPath method comment.
> */
>public void setCompilerPath(String compilerPath)
>{
>}
>/**
> * setEncoding method comment.
> */
>public void setEncoding(String encoding) {}
>/**
> * setMsgOutput method comment.
> */
>public void setMsgOutput(OutputStream ostream)
>{
> this.out = new PrintWriter( new OutputStreamWriter(ostream));;
>}
>/**
> * setOutputDir method comment.
> */
>public void setOutputDir(String dir)
>{
> outDir = (dir.indexOf(':') > 0) ?
> dir : (TOMCAT_DIR + File.separator + dir + File.separator);
>}
>}
>--------------------------------------------------------------------------
>
>
>
>-----Original Message-----
>From: James_Gu@ex.cv.hp.com [mailto:James_Gu@ex.cv.hp.com]
>Sent: Thursday, July 20, 2000 2:41 PM
>To: slilichenko@tradepayment.com; general@jakarta.apache.org
>Subject: RE: Visual Age config
>
>
>Interesting work. Would you mind sharing with us how to do it or the
>VAJCompiler
>class?
>
>Thanks.
>
> > -----Original Message-----
> > From: Sergei Lilichenko [mailto:slilichenko@tradepayment.com]
> > Sent: Thursday, July 20, 2000 2:35 PM
> > To: 'general@jakarta.apache.org'
> > Subject: RE: Visual Age config
> >
> >
> > I was able to go a bit further than IBM folks did and made
> > VisualAge compile
> > JSPs and have them imported in Visual Age. It allows
> > debugging JSPs inside
> > VAJ, which helps immensely at times :). I have 6 developers
> > working in this
> > environment for 3 months and we haven't had any problems.
> >
> > I did it with Tomcat 3.1 released in early April. I tried to
> > upgrade my
> > Tomcat with a newer release about a month ago, and for some
> > reason it didn't
> > work. I spent about 20 minutes looking at that, so I believe
> > it is just the
> > matter of time to get it going again. Most likely the problem
> > is in how
> > Tomcat calls a compiler on a newly translated JSP. In April's
> > edition one
> > would uncomment one section of web.xml to enable Jikes. That's where I
> > introduced a replacement of the compiler to import JSP into
> > VAJ and export
> > .class on successful import. So I just need to see what is
> > going on in the
> > current version.
> >
> > If there is interest in how it is done I can publish the source of my
> > VAJCompiler class and a document which describes the steps
> > required to make
> > everything work.
> >
> > Sergei Lilichenko
> >
> > -----Original Message-----
> > From: Stephen [mailto:stephen@webreserve.com]
> > Sent: Wednesday, July 19, 2000 10:45 PM
> > To: general@jakarta.apache.org
> > Subject: Visual Age config
> >
> >
> > Has anyone in this mailing list successfully configured
> > Visual Age with
> > Tomcat 3.1. I read the article on IBM's web site and did
> > everything exactly
> > as written. The problem is StartTomcat.java does not invoke
> > Tomcat properly
> > and I don't get any error information I just get:
> >
> > Tomcat Web Server Version 3.1
> > Loaded configuration from:
>file:c:/ibmvjava2/ide/project_resources/Tomcat
>Version 3_1/conf/server.xml
>
>and then the it terminates.
>
>I would greatly appreciate any help or suggestions on this.
>Thanks in advance,
>Stephen.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: general-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: general-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: general-help@jakarta.apache.org
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com