When you add a new Java™ project
to the application, you specify the project name, browse to the working
directory, and then specify the source roots and project dependencies.
About this task
The steps in this topic direct you
to complete all pages in the New Project Wizard (or New Application
Wizard, if you are creating the project in it). However, some of the
pages in the wizard are optional (required settings are complete when
the Finish button is activated). Settings made
in the wizard can be modified after project creation in the Properties view for
a selected project. If you complete the New Project Wizard
without completing optional pages, you can change the settings from
those pages later on in the Properties view.
Procedure
- In the Explorer view, select the
application that you want to add the project to (if you have not already
added an application, see Configuring applications).
- Complete one of these actions to
open the New Project Wizard:
- Select from
the main workbench menu.
- Right-click the selected application and choose from the context menu.
- In the Select Project Type page of the wizard, select Java/JSP as
the project type and then click Next to advance
to the next wizard page.
- In the Project Sources wizard page:
- Identify the project sources, which consist of the directories
in which you find the project files and any additional individual
files to include in the project.
Name the project and
specify the working directory. The Working Directory is
the location of the AppScan®
Source project
file (.ppf) and the base for all relative paths.
- Add the source roots manually or allow AppScan Source
for
Analysis to
find all valid source roots automatically.
Important:
- To analyze Java class files,
they must be compiled with
javac
using the -g
option.
The AppScan
Source analysis
relies on the debugging information generated by this option.
- If your project contains Java source
files that contain national language characters and you are running
in a locale other than the native locale (for example, UTF-8), the
scan will fail with errors and/or warnings in the console.
- To find the source roots automatically:
- Click Find Source Roots and browse to the
root directory of the source code.
- From the list of all found source roots, select the source roots
to add to the project.
- Click OK. The sources to include in the
scan appear in the Project Sources dialog box.
- To find the source roots manually:
- Click Add Source Root.
- Select the source code root directory or file.
- Click OK. After adding the source root,
you can exclude certain directories or files from it. To do this,
select the directory or file (or multiselect these items), right-click
the selection, and then choose Exclude from
the menu. If you include or exclude files, the icon to the left of
the file name changes.
Click Finish to add the project without
setting project dependencies - or click Next to
identify project dependencies.
- In the JSP Project Dependencies page:
- Identify JavaServer Page (JSP) project dependencies:
For Java projects that contain
JavaServer Pages, identify the JSP project dependencies. Select the Contains
web (JSP) content check box if the project is a web application
that contains JavaServer Pages.
- Manually select the Web Context Root,
or click Find to locate it. The Web
Context Root is a WAR file or a directory
that contains the WEB-INF directory. The web
context root must be the root of a valid web application.
-
Select the JSP Compiler for the project. Out-of-the-box, Tomcat 7 is the default JSP compiler setting (the default JSP compiler can be changed in the
Java and JSP preference page). To learn about
the compilers that are supported by AppScan
Source, see HCL AppScan Source system requirements.
Apache Tomcat Versions 7 and
8 are
included in the installation of AppScan
Source. If the
Tomcat
7 and Tomcat
8 preference pages are not
configured, AppScan
Source will compile JSP files using
the supplied Tomcat JSP compiler that is currently marked as default. If you want to employ an
external supported Tomcat compiler, use the Tomcat preference pages to point to your local Tomcat
installation.
If you are using Oracle WebLogic Server or WebSphere® Application
Server, you must configure the applicable preference page to point to your local
installation of the application server so that it can be used for JSP compilation
during analysis. If you have not already completed this configuration, you will be
prompted by a message to do so when you select the JSP compiler. If you click
Yes in the message, you will be taken to the appropriate
preference page. If you click No, a warning link will display
next to the JSP compiler selection (following the link will open the preference
page).
Click Finish to add the project with
JSP project dependencies - or click Next to
identify Java project dependencies.
- In the Java Project
Dependencies page, identify the dependencies required to build this Java project:
- Add the JAR files manually or click Find for AppScan Source
for
Analysis to
search the directories that contain the dependent JAR and
class files.
The Class Path list
displays the relative path to the project. The class path must specify
the required JAR files and the directories containing
class files that the project requires.
- Add, Remove, Move
Up, and Move Down: Add or remove
files from the class path, or move them up or down in order.
- Find: Find JAR and
class path entries based on the source files in the project.
Important: If the Java project
contains JavaServer Pages, you must also add JSP Project Dependencies.
- To find project dependencies manually:
- Click Add in the Class Path section toolbar
and then select the JAR and class file directories
necessary to compile the Java project.
- Click OK. The JAR files
and directories appear in the class path. Change the order as necessary.
- To find dependencies automatically:
- Click Find in the Class Path section toolbar.
- Specify the directories in which to look for the JAR and
class files necessary to compile the Java project.
- Select the Look inside the source and JAR files check
box if you want AppScan Source
for
Analysis to
find the required project dependencies based on sources and by using
the provided search path.
- Click Next to find the project dependencies
and identify conflicts.
- To resolve conflicts:
- If conflicts exist, in the Resolve Conflicts dialog box, select
the entry to resolve and click Resolve (or
click Next to auto-resolve conflicts). A conflict
occurs when AppScan Source
for
Analysis finds
more than one JAR or class in a directory that
satisfies the dependency.
A red icon appears to the left of unresolved
conflicts. Once resolved, the red icon changes to green and the item
is Resolved. You may also Remove a
conflict.
- After you resolve or remove a conflict, you may want to verify,
reorder, or remove the class path entries. Note the list of imports
that could not be found. Any unresolved imports result in compilation
errors when AppScan Source
for
Analysis scans.
- Options: Specify any additional
required compiler parameters for the project.
Compilation
options are the options that are passed to the compiler so that source
files can compile. For example, -source 1.5
specifies
the source level of the project.
- Use JDK: Specify the Java Development Kit (JDK) to use when scanning
this code. By default, IBM JDK 1.8 is used. AppScan
Source also
provides IBM JDK 1.7 for selection. To define
additional JDKs, or to set a different default JDK, use the Java
and JSP Preferences.
Note: Out-of-the-box, the default compiler
for JSP projects is Tomcat 7,
which requires Java Version
1.6 or higher. If Tomcat
7 is
kept as default, using an earlier JDK will result in compilation errors
during scans.
- The Validate action assures that
project dependencies are correctly configured. It checks Java projects for configuration conflicts between
sources and the class path, and it also checks for compilation errors.
A conflict exists if a class in the class path is duplicated in the
source root.
If a conflict exists, the validation text
area displays the JAR or location where the class
is defined on the class path and whether the duplicate exists in the
sources. Remove the conflict from the class path, and rerun the check.
After
checking for conflicts, Validate determines
if the project compiles and reports any compilation errors.
- Precompiled classes: This field
allows you to use precompiled Java or JSP class files instead of compiling
during a scan.
- Stage source files to minimize effects of
compile errors: Clear the check box if your source code
compiles correctly and is arranged accurately in directories, matching
the packages.
- Correct for packages not matching directory
structure: Select if the packages do not match the directory
structure.
- Clean staging area between each scan:
Optimization option.
- Click Finish.
Results
Tip:
If you are scanning Java and there are missing dependencies in your Java project,
AppScan
Source
will create traces by synthesizing the pieces that the dependencies would have provided. This
synthesis may not accurately reflect the information in
.jar files. To limit
synthesis and thereby improve the accuracy of findings, you can specify the missing dependencies, as follows:
- After scanning, open <data_dir>\logs\scanner_exceptions.log (where <data_dir> is the location of your
AppScan
Source program data, as described in Installation and user data file locations)
to see if AppScan
Source
has reported missing dependencies.
- Modify the project properties to include the dependencies. To do this, follow the instructions
in Modifying application and project properties and then specify and save the dependencies in
the JSP Project Dependencies or Project Dependencies
tab.
- Re-scan the project.
Note:
By default,
AppScan
Source
scans Java files and Java byte code with missing dependencies or compilation errors. These settings
can be changed as follows:
- Open <data_dir>\config\scan.ozsettings in a text editor.
- To change the compilation error setting, locate
compile_java_sources_with_errors
in the file. This setting will look similar
to:<Setting
name="compile_java_sources_with_errors"
value="true"
default_value="true"
type="bool"
hidden="true"
display_name="compile_java_sources_with_errors"
description="Attempt to scan java code with compilation errors."
/>
- To change the missing dependency setting, locate
scan_java_bytecode_without_dependencies
in the file. This setting will look similar
to:<Setting
name="scan_java_bytecode_without_dependencies"
value="true"
default_value="true"
type="bool"
hidden="true"
display_name="scan_java_bytecode_without_dependencies"
description="Scans Java bytecode even when some of
the dependencies are missing by artificially
synthesizing the unresolved symbols."
/>
- In the setting, modify the
value
attribute. If the attribute is set to
true
, this setting will be on. If the compilation error setting is set to
false
, AppScan
Source
will skip Java code with compilation errors during scans. If the missing dependency setting is set
to false
, AppScan
Source
will not scan Java bytecode if there are missing dependencies.
- Save the file after you have modified this setting and start or restart AppScan
Source.