- This topic has 19 replies, 3 voices, and was last updated 20 years, 9 months ago by Riyad Kalla.
-
AuthorPosts
-
Oleg KonovalovMemberHi,
Tried to import my large Web project to MyEclipse3.7RC2
from Tomcat 4.1 [where it runs just fine, no errors].Having problems:
1) some JSPs don’t see TLDs:
<%@ taglib uri=”/WEB-INF/util.tld” prefix=”util” %>
Although JSPs are in WebRoot and TLDs in
WebRoot/WEB-INF2) Some JSPs would not compile, having errors like:
myVar cannot be resolved. These JSPs are included in main
JSPs and all are in the same WebRoot dir.3) Can not deploy to Tomcat4.1. It is enabled and configured,
but MyEclipse complains that it’s not configured properly.
The only part nto filled in is Optional Program Arguments,
but I assume that it’s optional.Please help.
Thank you in advance,
Oleg.
Riyad KallaMemberOleg,
1) Do you have taglib entries in your web.xml for these? Are these TLDs from a particular JAR that you have in your WEB-INF/lib folder?2) JSP segments, or pages that are intended to be included in pages, should be named (according to JSP spec) ending in “jspf”. Used to be called JSP-fragments, but JSP-segments seems to be the preferred term now.
3) To deploy successfully you need to configure a JDK for your application server, not the default JRE from Eclipse. You can do this from the Tomcat 4.1->JDK node, and clikc the “Add” button. We are going to make this more intuitive in the next release 😉
Also if you want full debugging support, consider upgrading to Tomcat 5 as it supports the JSR 45 spec which is required for full debugging support (as well as a 1.4 Java VM)
Oleg KonovalovMemberRiyad,
Thank you for your help.
1) TLDs are not in a JAR, just separate files.
And they are described in web.xmlDo I place files correctly in MyEclipse project:
JSP in WebRoot, JAVA in Src, TLDs in WebRoot/WEB-INF ?2) I will try to make JSPF.
3) Will try Tomcat5 later. Project is in production for us in Tomcat4.1.
And will configure JDK for Tomcat in Eclipse.Thank you again,
Oleg.
Riyad KallaMemberOleg,
I would suggest the following project structure to you:/<project root> +/src <-- Java source code for web project (servlets, actions, forms, beans, etc.) +/docs <-- license files, readme's, etc +/api <-- Target for your Javadoc source generation +/lib <-- extra libs that the web app doesn't need while running +/webroot <-- this is the base of the webroot, this will be the root when deployed to Tomcat, etc. +index.jsp <-- example jsp file in root +/images <-- images for the website +/WEB-INF <-- very important :) +/classes <-- build output directory +/lib <-- libs required for your webapp to run (i.e. struts.jar, etc.) +/conf <-- your custom conf files that you need for your app +/tld <-- taglibs (just a FYI, it didn't seem you had any)
So yes, it sounds like you hvae the correct layout.
Oleg KonovalovMemberJSP->JSPF worked.
> +/tld <– taglibs (just a FYI, it didn’t seem you had any)
What do you mean I don’t have any (TLDs) ?
Do you absolutely have to have TLDs in a special directory?So now I have many errors like:
“Cannot load class” coming from line: <%@ taglib uri=”/WEB-INF/util.tld” prefix=”util” %>That is how I have it in web.xml :
<taglib> <taglib-uri>/WEB-INF/util.tld</taglib-uri>
<taglib-location>/WEB-INF/util.tld</taglib-location>
</taglib>
Does it have to be MyProject/WEB-INF/util.tld ?
Or maybe /WEB-INF/tld/util.tld ?Regarding Tomcat configuration in MyEclipse,
I added another JRE and configured directories,
but still get the same error (see Q3 in original e-mail).Thank you,
Oleg.
Riyad KallaMemberHi Oleg,
> +/tld <– taglibs (just a FYI, it didn’t seem you had any)
What do you mean I don’t have any (TLDs) ?
Do you absolutely have to have TLDs in a special directory?I’m sorry, this was from a previous post I had made, and that sentence was meant for another user. The /WEB-INF/tld directory IS NOT mandatory, it is optional just for cleaner organization. If you DO decide to put your TLD’s in that directory, then you need to adjust all of your <taglib> entries in your web.xml file to point to the new location, for example:
<taglib> <taglib-uri>/WEB-INF/tld/util.tld</taglib-uri> <taglib-location>/WEB-INF/tld/util.tld</taglib-location> </taglib>
and naturally change your @taglib entries in the top of your JSP pages. I would suggest to use a more ‘generic’ URI, so in the future if you move your taglibs, you don’t need to adjust the URI in your JSP pages, something like:
<taglib> <taglib-uri>/tags/util.tld</taglib-uri> <taglib-location>/WEB-INF/tld/util.tld</taglib-location> </taglib>
or something like that.
Regarding Tomcat configuration in MyEclipse,
I added another JRE and configured directories,
but still get the same error (see Q3 in original e-mail).You need to setup a JDK (point to an intalled JDK, i.e. C:\j2sdk1.4.2_03), if you point to a JRE, it will not work. The application servers need to use a JDK because of the tools.jar library included with the JDK that has the Java Compiler in it. This allows the application server to compile the translated JSP pages on the fly.
Oleg KonovalovMemberRiyad,
MyEclipse still gives me “Cannot load class” for every reference to
tag libraries (details in previous msg).
It doesn’t complain about Struts taglibs, although they
are in the same folder. Maybe because it’s a standard TLD ?I have another project in MyEclipse, it also doesn’t see tag libs,
but the error is a bit different:
Could not load TLD for URI…, URL…
<%@ taglib uri=”/include/rptsvrjsp-taglib.tld” prefix=”rptsvr” %>
JSP is in WebRoot/admin, TLD in WebRoot/include folder.Both projects (including JSPs) run just fine under Tomcat4.1.
I have inherited them from another guy who is no longer here.
So I need to fix a few bugs, so wanted to do it from MyEclipse.Please help.
Thank you,
Oleg.
Scott AndersonParticipantOleg,
Can you post your full web.xml file? It’s very peculiar that there’s no problem finding the Struts libs but yours are problematic. It’s most likely a mapping issue. What’s different between the way your struts libraries are used and referenced and the way your custom ones are?
Oleg KonovalovMemberHere is web.xml of the 1st project [uses Struts, originally util.tld wasn’t there]:
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN” “http://java.sun.com/j2ee/dtds/web-app_2_2.dtd”>
<web-app>
<!– PET Servlet declarations { –>
<!– Database Initialization Servlet Configuration –>
<!–
<servlet>
<servlet-name>database</servlet-name>
<servlet-class>org.apache.struts.webapp.example.DatabaseServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
–>
<!– Database Servlet Configuration –>
<servlet>
<servlet-name>oracle-xsql-servlet</servlet-name>
<servlet-class>oracle.xml.xsql.XSQLServlet</servlet-class>
</servlet><!– Action Servlet Configuration –>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>com.doublebridge.pet.ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet><!– PET Servlet declarations } –>
<!– PET Servlet mappings { –>
<!– Action Servlet Mapping –>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping><servlet-mapping>
<servlet-name>oracle-xsql-servlet</servlet-name>
<url-pattern>*.xsql</url-pattern>
</servlet-mapping><!– PET Servlet mappings } –>
<!– The Welcome File List –>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list><!– Application Tag Library Descriptor –>
<taglib>
<taglib-uri>/WEB-INF/app.tld</taglib-uri>
<taglib-location>/WEB-INF/app.tld</taglib-location>
</taglib><!– Struts Tag Library Descriptors –>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib><taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib><taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib><!– Reference to a DataSource resource bound in JNDI { –>
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/PET</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!– Reference to a DataSource resource bound in JNDI } –></web-app>
Second project [not using Struts, I haven’t added those TLDs yet]:
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN” “http://java.sun.com/dtd/web-app_2_3.dtd”>
<web-app>
<servlet>
<servlet-name>LoginOut</servlet-name>
<servlet-class>com.doublebridge.servlet.LoginOut</servlet-class>
<load-on-startup>110</load-on-startup>
</servlet>
<servlet>
<servlet-name>LoginService</servlet-name>
<servlet-class>com.doublebridge.servlet.LoginService</servlet-class>
<load-on-startup>109</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>LoginOut</servlet-name>
<url-pattern>/servlet/LoginOut</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>LoginService</servlet-name>
<url-pattern>/servlet/LoginService</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>role1, tomcat</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/jsp/security/protected/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>tomcat</role-name>
<role-name>role1</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/jsp/security/login/login.jsp</form-login-page>
<form-error-page>/jsp/security/login/error.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
Scott AndersonParticipantHere is web.xml of the 1st project [uses Struts, originally util.tld wasn’t there]
Did you add a mapping to util.tld? Did that fix the referencing problem once you rebuilt the project? If the JSP editor picks up your struts libs but not your custom ones, can you tell how they are different? Can you construct an example project that exhibits the same behavior that you can send to us for internal testing?
Second project [not using Struts, I haven’t added those TLDs yet]:
OK, but you really need to add the taglib entries to web.xml and then test again.
Oleg KonovalovMemberSorry, it’s not in the text of those web.xml files.
But I tried it and it didn’t help.
Example:
<taglib>
<taglib-uri>/WEB-INF/util.tld</taglib-uri>
<taglib-location>/WEB-INF/util.tld</taglib-location>
</taglib>
Still getting “Cannot load class” from: <%@ taglib uri=”/WEB-INF/util.tld” prefix=”util” %>As I said, JSP is in WebRoot, TLD in WebRoot/WEB-INFO
Any other advice ?
Thank you,
Oleg.
Scott AndersonParticipantOleg,
Again, what’s the difference between the way the Struts taglibs are configured and your own? If there isn’t any, I think the problem might be in the taglib implementation. For example, are your classes all public, conform to the spec for a taglib, etc? Are all utility jars your taglibs use in the WEB-INF/lib directory?
Riyad KallaMemberOleg,
Are the tags Util.tld references part of the current project you are working on, or is it part of a JAR file that is in the project? You need to have the JAR file added to your build path.For example, if you wanted to add JSTL to your project, you would add the jstl.jar and standard.jar to your build path (it isn’t even necessary to edit the web.xml OR add the TLD, Michael has explained why in the past).
Oleg KonovalovMemberScott, Riyad,
>Again, what’s the difference between the way the Struts taglibs are configured and your own?
There is no difference between them AFAIK.I do not have util.tld in any JAR, it is in WebRoot/WEB-INF.
>For example, are your classes all public, conform to the spec for a taglib, etc?
Looks like all classes are public and seem to conform to taglib.>Are all utility jars your taglibs use in the WEB-INF/lib directory?
I added all necessary JARs to the classpath of the project,
but TLDs do no use any of them.Actually, I also tried to import these both projects into JBuilderX
and it didn’t show me any problems either (as well as running fine on Tomcat4.1)What do you think?
Thank you,
Oleg.
Scott AndersonParticipantOleg,
I added all necessary JARs to the classpath of the project,
but TLDs do no use any of them.What about the java code that actually implements your custom tags? Where are those classes? They should be in a jar in the WEB-INF/lib directory.
-
AuthorPosts