Page tree
Skip to end of metadata
Go to start of metadata

Use the following information to help validate your analysis:

What you need to check

  • That there are no warnings for the analysis of the Java files
  • For JSP, you must interpret any remaining warnings. Some of them could be due to the J2EE Analyzer.

In CAST Enlighten

In order to produce correct unreferenced artifacts, function points and architecture quality rules, it is very important to carry out the following assessments:

  • JSP and JAVA links: you must check that images are linked to web pages and that there are links between JSP and JAVA. If this is not the case, this means that the web server root path is not correctly configured or that the source file paths are not the same as those used in production. To overcome this last issue, you must use the Text Replacement feature in the J2EE Analyzer.
  • JAVA and EJB links: you must verify that EJB and Java implementation classes are linked together.
  • EJB Entities and Database: you must verify that links between EJB Entities and database tables are made.
  • Hibernate and Java and Database: you must verify that links form Java Classes to Hibernate Entities and from Hibernate Entities to Database are made.
  • Spring Beans and Java classes: you must verify that links from Spring Beans to Java classes are made.

Log message FAQ

Issue #1: "No taglib declaration found that uses..."

This message may appear for JSP files that are included in other JSP files. The taglib declaration is in the file that includes the other file. If this is the case, you can ignore this warning. So, first verify that this file is not included in another JSP file via a grep search.

Issue #2: "Cannot resolve 'xxxx' as type in local variable 'list' ... in Java files generated from JSP"

"can not resolve 'xxxxx' as class in class 'cast_generated_jsp_package.yyyyyy_jsp' from class 'cast_generated_jsp_package.yyyyyy_jsp'"

JSP is a specific case because on some application servers, some packages are implicitly imported in addition to what has been specified in the JSP specification.
So first, you must be sure that the package, class or method is included in your Java source code or in your archives (see the next error issue to see how to do this).
If the Analysis Unit refers to the definition of this package, class or method, this means that the application server adds these imports implicitly in the JSP files.
According to your Servlet version:
If you are using a Servlet version 2.4 (the version is in the web.xml declaration, see below in bold)
To simulate this behavior, you will need to create a JSP file with these import declarations:

implicit declaration.jsp:

<%@ page import="package.classA, package.classB, other.package.*" %>

Then open the web.xml file and add the following bold lines:

<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
   version="*2.4*">
   ...
   <jsp-config>
       ...
       <jsp-property-group>
           <url-pattern>*.jsp</url-pattern>
           <include-prelude>/implicit declaration.jsp</include-prelude>
        </jsp-property-group>
      ...
   </jsp-config>
</web-app>

If you are using an older version of Servlet (<2.4):
Then you will have to include the implicit declaration of import (<%@ page import="package.classA, package.classB, other.package.*" %>) in all the JSP files that require it.

Issue #3: Cannot resolve... in Java source files

*"cannot resolve 'xxxx' as package or type in package..."
"cannot resolve 'xxxx' as type in method/local variable..."
"cannot resolve 'xxxx' as class in...""cannot resolve 'xxxx' as method..."
"cannot resolve xxx as variable"*

  • Cause: These messages appear when an archive is missing or when the JDK version selected is not the correct one (this is the case if you selected JDK 1.4 and there are annotations in the source files). To fix this, you must find which library contains the 'xxxx' component and add it in a new Environment Profile (when it is shared by several Application) or through the classpath in the archive list.
  • Effect: missing artifact in the Knowledge Base, metrics based on the presence of these artifacts will not work.
  • Remediation: If it is due to an incorrect version of the JDK, you will receive messages like: "can not resolve 'Override' as type in method..." where 'Override' is an annotation that appears in your Java file (@Override). In the other cases, to find the missing component use the grep (http://unxutils.sourceforge.net/) tool against the source path tree with the name of the unresolved class (not the method or the field: always the name of the class). The grep tool is more advanced than the Windows search tool and can carry out a binary search and thus also functions with .jar files. You then need to open the .jar files that are identified by the grep search with winzip and look for the missing class so that you can include the correct archive.

Note that for the error, cannot resolve 'xxxx' as type in method/local variable, you will have to open the file and identify the missing class definition. Most of the time this message is preceded by a message cannot resolve 'xxxx' as package or type in package. Solving the first one will solve this one. The only case where it is not preceded by this message is when the full class name is used in the code without any import declaration.

Issue #4: "The uri 'xxxxxx' could not be resolved within the file web.xml or among the jar files deployed with your application."

  • Cause: This error message appears when the TLD that contains the uri 'xxxxxxx' can't be found.
  • Consequences: when a TLD is not managed, all the strings declared as attributes in the tag declaration will be searched from all objects that are selected through the Object Manager panel of the wizard and also in the objects created by this analysis without knowing the object type. So if an attribute value with the same name as a database table is identified and this value also represents the name of a JSP Bean, a link will be created with the table and the JSP bean.
  • Remediation: to fix this problem, you must first locate which TLD is related to the message, i.e. you need to open the web.xml file and look for this uri. You will have three cases:
  • A uri associated to a file (here is an example with the TLD struts-logic):

    <taglib>
        <taglib-uri>*/tags/struts-logic*</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>
    

    This means that the /WEB-INF/struts-logic.tld file is missing. Ask the customer to provide it.

  • A uri associated to a JAR:

    <taglib>
        <taglib-uri>*/tags/struts-logic*</taglib-uri>
        <taglib-location>/WEB-INF/lib/struts-1.2.7.jar</taglib-location>
    </taglib>
    

    This means that the JAR file is missing (see below: How to find the JAR that contains a specific TLD)

  • Nothing in the web.xml file about this uri: In this case, the analyzer will try to find the TLD through all the .jar files included in the classpath or in the WEB-INF subfolders. So, to fix this issue, you need to find the right .jar that is missing (see below: How to find the JAR that contains a specific TLD).

How to find the JAR that contains a specific TLD:
Usually the .jar name contains part of the TLD name.
For example:

  • struts-bean.tld is contained in struts.jar
  • taglib.tld is contained in taglibs-request.jar

To verify that the JAR contains the specific TLD, open it using WinZip and go to the directory META-INF or META-INF\tld. Then open the TLD with an editor and check that the specified URI is the same as the URI specified within the tag <uri>:

<!DOCTYPE taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
  "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
   <tlibversion>1.0.1</tlibversion>
   <jspversion>1.1</jspversion>
   <shortname>request</shortname>
   <uri>http://jakarta.apache.org/taglibs/request-1.0</uri>
   ...
</taglib>

Fix the issue:
To fix this problem, you need to customize the file cast-tag-extension.xml (see chapter Customize the cast-tag.extensions.xml)

Issue #5: Ambiguous references between Java classes

  • Cause: this message appears when there are several files that have the same class definition.
  • Consequences: one of the definitions will be taken as the reference and not the other one. The risk, therefore, is to analyze the wrong definition.
  • Remediation: to find the files related to this error message
    • First, you must search the directory selected for the analysis (through Java Configuration > Java Files) to check if there are two Java files that contain this class. The best method is to search (with a grep tool) for the class name (not the fullname) against the java source files and then ensure that it is the same package. If there is duplication, then you will have to select the right directory or file to choose the right definition.
    • If there is no duplication, then you must look at the directory selected via the AddPath option and determine if there are .class or .java files that have the same name and are not in the same directory. If this is the case, however, you will have to make a decision between these two definitions. Note that where .class and .java files are in the same directory, the analyzer will not warn you because it will take the most recent file and this is not a problem since the .class must be a direct compilation of the .java, so they will have the same definition.

Issue #6: Cannot find file whose path is '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤/..."

  • Cause: a file is unfound.
  • Consequences: The file object and the links to it will not be created. The file will appear as an unreferenced file in the ADG Dashboard.
  • Remediation: To manage these situations, you need to identify if the file name after the "¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤" series is a real filename or not, via a search in the source files. If it is a file, then open the JSP file that produces this error (the JSP file is in the log message). If you have a line like:

    <link href="<%=request.getContextPath()%>/file.css"
                 type="text/css"
                 rel="stylesheet"/>
    
    Or
    
    <link rel="stylesheet"
          type="text/css"
          href="@CONTEXT_APACHE@@CONTEXT_FRAMEWORK@/file.css">
    

This means that the analyzer can't work out how to interpret the string before the file. In the previous examples, it can't interpret request.getContextPath() and  (CONTEXT_APACHE) (CONTEXT_FRAMEWORK)

To solve this issue, you need to use the Application > J2EE > Analysis > Text Replacements tab or Analysis Unit > Analysis > Text Replacements tab in CAST-MS to replace <%=request.getContextPath()%> with the real directory path.

Issue #7: You should configure the tld file with uri 'http://xxxxx' so that tag attribute values can be properly resolved...

  • Cause: a TLD is not taken into account by the analyzer resolution mechanism.
  • Consequences: tag attributes from JSP files will be the source of many incorrect links to any objects with same name that are selected through the Object Manager. For example:<jsp:useBean id="ADM" type="com.cast.Adm" scope="request"/> will create links to any object type that has the name "ADM" or "request". Incorrect quality rules will also be produced: with the previous example, if ADM is a table name selected in the Object Manager, you will have a link from the JSP page to the database and this will be interpreted as poorly designed architecture.
  • Remediation: you will need to update the file cast-tag.extensions.xml as explained in paragraph Customize the cast-tag.extensions.xml.

Issue #8: Tag library descriptor xxxx/WEB-INF/yyyy.tld' cannot be processed (file not found)

This is exactly the same issue as the previous one except that the taglib has not been found. In this case, you must search for this file in your source directory and move it to the location indicated in the message.

Issue #9: Annotation 'xxxxxxxx' is not managed in Environment Profiles

  • Cause: an annotation 'xxxxxx' has been found by the analyzer in Java code specified in your Analysis Unit and no Environment Profile selected in this Analysis Unit or Application manages it.
  • Consequences: if it is an annotation that is managed by an Environment Profile delivered by CAST, then it can impact quality rules results. This is the case for annotations managed by CAST - Hibernate 3.2 Environment Profile. In other cases, if you haven't configured a specific management of this annotation, then it depends on the semantic of this annotation. For example, if this annotation is used to inject SQL queries in a method, and if you don't manage it, no SQL quality rules will be executed on these SQL queries. Also, if this annotation defines dependencies between modules (java and database for example) it would be useful to manage it to get accurate architecture based quality rules results.
  • Remediation: If this annotation is referenced in an existing Environment Profile, then you need to select it. In other cases, when this annotation is meaningless, you can ignore it in an Environment Profile or if it has a meaning, you will need to update an Environment Profile and customize an XML Query File. Refer to Manage annotations.

Issue #10: File 'xxxxxxx.x' has been selected for analysis but is not handled by any of the environment profiles you selected

  • Cause: a XML file 'xxxxxxx.x' has been found by the analyzer in the selected directory or files specified in Configuration Files > XML Files and no Environment Profile selected in this Analysis Unit or Application manages it.
  • Consequences: it depends on the XML file and what meaning it has. If it defines dependencies between components (Java and database for example), or references SQL queries then it would be useful to manage it to get accurate quality rules results.
  • Remediation: If this XML file is referenced in an existing Environment Profile through Filename matching patterns, XPath, XSD, DTD or filenames, then you need to select it. In other cases, when this XML is meaningless, you can ignore it in an Environment Profile or if it has a meaning, you will need to update an Environment Profile and customize an XML Query File. Refer to Manage XML files.
  • No labels