- This topic has 9 replies, 2 voices, and was last updated 18 years, 2 months ago by Riyad Kalla.
-
AuthorPosts
-
Unnsse KhanMemberHello there,
I created a web project using MyEclipseIDE with JSTL 1.1 libraries (jstl.jar & standard.jar).
Am using OS X Tiger and Eclipse 3.2. I wrote a build.xml (Ant script) which would take care of making a war file.
Although, it works on OS X Tiger (when I manually run it from the command line & and when I run Tomcat from MyEclipse), it doesn’t work on WinXP.
My build.xml (which I used to manually create a war file):
Please take a look at the buildWebapp target…
<?xml version="1.0"?> <project name="petstore" default="webapp" basedir="."> <!-- =================== Initialize Property Values ===================== --> <property file="build.properties" /> <!-- =================== Convenient Synonyms ============================ --> <target name="clean" depends="cleanWebapp" /> <target name="all" depends="clean,webapp" /> <target name="help"> <echo> Build structure of the Web Application Toplevel targets: help -- this message all -- cleans and then builds/deploys this Web app. webapp -- (re)builds and deploys this Web app. to Tomcat clean -- cleans the deployment environment for this Web app. cleanTomcat -- removes all Tomcat Web apps (except ROOT and tomcat-docs) </echo> </target> <!-- =================== CLEAN: Webapp ================================== --> <target name="cleanWebapp"> <delete dir="${build.dir}" /> </target> <!-- =================== CLEAN: Tomcat ================================== --> <target name="cleanTomcat"> <delete includeEmptyDirs="true"> <fileset dir="${tomcat.deployment.dir}" excludes="${tomcat.webapps.toSave}" /> </delete> </target> <!-- =================== CLEAN: Backup Files ============================ --> <target name="cleanTmpFiles"> <delete> <fileset dir="." defaultExcludes="no" includes="**/*~"/> </delete> </target> <!-- =================== WEBAPP: All ==================================== --> <target name="webapp" depends="undeployWebapp,deployWebapp" /> <!-- =================== WEBAPP: Deploy to Tomcat ======================== --> <target name="deployWebapp" depends="undeployWebapp,buildWebapp" > <!-- Copy the newly built WAR file into the deployment directory --> <copy file="${build.dir}/${webapp.name}.war" todir="${tomcat.deployment.dir}" /> </target> <!-- =================== WEBAPP: Undeploy ======================== --> <target name="undeployWebapp" > <!-- Delete the deployment directory --> <delete dir="${tomcat.deployment.dir}/${webapp.name}" /> <delete file="${tomcat.deployment.dir}/${webapp.name}.war" /> <!-- Delete the webapp Tomcat configuration file --> <delete file="${tomcat.context.config.file}" /> </target> <!-- =================== WEBAPP: Copy Static Web Files ================== --> <target name="deployContent" description="This targets copies HTML and JSP files to the deployment directory." > <!-- Copy web files --> <copy todir="${tomcat.deployment.dir}/${webapp.name}/"> <fileset dir="web" /> </copy> <!-- Copy hidden web files --> <copy todir="${tomcat.deployment.dir}/${webapp.name}/WEB-INF/"> <fileset dir="etc/view" /> </copy> </target> <!-- =================== WEBAPP: Build WAR File ========================= --> <target name="buildWebapp" depends="compileWebapp"> <jar jarfile="${build.dir}/${webapp.name}.war" basedir="${webapp.build.dir}" /> </target> <!-- =================== WEBAPP: Compile Web Components ================= --> <target name="compileWebapp" depends="staticWebapp"> <javac srcdir="src" destdir="${webapp.build.dir}/WEB-INF/classes/" deprecation="off" debug="on" optimize="off"> <classpath> <!-- Include all JAR files in my local library --> <fileset dir="lib"> <include name="*.jar"/> </fileset> <!-- Include all common libraries in Tomcat --> <fileset dir="${tomcat.home}/common/lib"> <include name="*.jar"/> </fileset> </classpath> </javac> </target> <!-- =================== WEBAPP: Copy Static Web Files ================== --> <target name="staticWebapp" depends="prepareWebapp"> <!-- Copy web files --> <copy todir="${webapp.build.dir}/"> <fileset dir="WebRoot" /> </copy> <!-- Copy webapp configuration files --> <copy todir="${webapp.build.dir}/WEB-INF/"> <fileset dir="etc" /> </copy> <!-- Copy library files files --> <copy todir="${webapp.build.dir}/WEB-INF/lib/"> <fileset dir="lib" /> </copy> </target> <!-- =================== WEBAPP: Copy Jar files from etc into WEB-INF/lib ============== --> <target name="copyJars" depends="prepareWebapp"> <!-- Copy etc jar files to local WEB-INF lib--> <copy todir="${webapp.lib.dir}"> <fileset dir="lib"/> </copy> <!-- Copy etc jar files to build WEB-INF lib--> <copy todir="${webapp.build.dir}/WEB-INF/lib"> <fileset dir="lib"/> </copy> </target> <!-- =================== WEBAPP: Create WebApp Directories ============== --> <target name="prepareWebapp"> <mkdir dir="${webapp.build.dir}" /> <mkdir dir="${webapp.build.dir}/WEB-INF" /> <mkdir dir="${webapp.build.dir}/WEB-INF/lib" /> <mkdir dir="${webapp.build.dir}/WEB-INF/classes" /> </target> </project>
Now, when I deploy the war on my WinXP box’s Tomcat 5.5.9, the JSTL part has errors…
What is the best way to make war file using MyEclipseIDE?
Thank you,
Riyad KallaMemberThe best way to create a WAR file is to let MyEclipse handle it. That is what the Deployment Tool is for. You can ue the deployment tool by clicking the deployment button from the toolbar as outlined in our getting started guide here:
http://www.myeclipseide.com/images/tutorials/quickstarts/webprojects/
Unnsse KhanMemberRiyad,
Thanks for the link…
I still don’t see anywhere inside that URL where I can create a WAR file.
-Unnsse
Riyad KallaMemberI should have clarified that these steps are for Web Projects, ifyour project is a web project, check Section 7 out. You can also use the File > Export > WAR feature to create a war in addition to the more regular steps of creating one.
Unnsse KhanMemberRiyad,
I have two development machines… I have a Apple G4 PowerBook running OS X Tiger and WinXP.
Have the latest JDKs / JVMs and Eclipse 3.2 with MyEclipseIDE plug-in Pro.
I develop on OS X and deploy on WinXP and Linux.
What I did was a create a new web project, at the wizard dialog, I choose “Install JSTL 1.1” libraries.
Now, my web project had standard.jar and jstl.jar (which it stated that it would install in WEB-INF/lib, and which it rightfully did).
My entire web site (is purely static) except for getNews.jsp (which contains JSTL code).
When I run the web app within MyEclipse using hot deploy with Tomcat 5.5.9 on OS X Tiger, I can see the page perfectly.
When I place the war file (generated by MyEclipse’s deployment tool and Export-J2ee-War) inside my WinXP’s Tomcat 5.5.9/webapps directory,
everything works except for the getNews.jsp page (containing the JSTL code).It throws the following exceptions:
javax.servlet.ServletException: org/apache/xpath/XPathException org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) org.apache.jsp.experts_005fcorner_jsp._jspService(org.apache.jsp.get_005fNews_jsp:221) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NoClassDefFoundError: org/apache/xpath/XPathException java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:620) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1629) org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:850) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1299) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181) java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) org.apache.taglibs.standard.tag.common.xml.ExprSupport.doStartTag(ExprSupport.java:63) org.apache.jsp.experts_005fcorner_jsp._jspx_meth_x_out_0(org.apache.jsp.get_005fNews_jsp:280) org.apache.jsp.experts_005fcorner_jsp._jspService(org.apache.jsp.experts_005fcorner_jsp:160) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
The code for getNews.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <c:import var="news" url="http://rss.cnn.com/rss/cnn_tech.rss" /> <x:parse var="doc" xml="${news}" /> <strong> <x:out select="$doc/rss/channel/title" /> </strong> <x:out select="$doc/rss/channel/description" /> <x:forEach var="story" select="$doc/rss/channel/item"> <ul> <li> <a href="<x:out select="link"/>" target="_blank"> <x:out select="title"/> </a> </li> <br> </ul> </x:forEach> </html>
I don’t understand why this page works under OS X but not WinXP. I also placed all the tlds inside a directory called tlds under WEB-INF: WEB-INF/tld.
Would love to hear some help / assistance regarding this…
Many, many thanks!
Riyad KallaMemberWhat version of JDK do you have installed on your windows machine? Looks like you are missing the XPath JARs that are provided by Xalan.
Unnsse KhanMemberRiyad,
Thank you for responding, my JAVA_HOME on WinXP is:
F:\DevTools\Java\jdk1.5.0
and
when I go to MS-DOS and type: java -version
this is what I get:java version “1.5.0_06”
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112)
Java HotSpot(TM) Client VM (build 1.5.0_06-64, mixed mode, sharing)Where do I need to place the xalan.jar? Should it be in CATALINA_HOME/common/lib or my global CLASSPATH?
Does the particular JVM / JRE I run have this xalan.jar file?
Regards,
Unnsse
Riyad KallaMemberUnnsse,
Actually I think these things should run out of the box with no additional JARs, I’ve never used the x tags before, but it looks like the JDK does ship a XPath implementation that the taglib should be picking up.Are you sure you sure you configured Tomcat to launch with JDK 1.5?
Unnsse KhanMemberRiyad,
How would you suggest Tomcat to launch with JDK 1.5 when I have explicitly set the %CATALINA_HOME% & %JAVA_HOME% system global environmental variables.
Also, should I put the xalan.jar in TOMCAT/common/lib or TOMCAT/webapps/SampleApp/web-inf/lib ?
Thanks again!
-Unnsse
Riyad KallaMemberUnnsse,
I was assuming you were launching Tomcat from within MyEclipse using the Tomcat 5 connector from Window > Prefs > MyEclipse > Application Servers > Tomcat 5… then under the JDK preference node, you can set which JDK to launch Tomcat 5 with. -
AuthorPosts