uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

14.2 apt command

The apt command is a JDK command that interprets annotations, generates additional Java code, and compiles by including the basic Java code. You use the apt command for the development of a Web Service starting from SEI. The apt command interprets the annotation (coded in compliance with the JAX-WS 2.2 specifications) coded in the Web Service Implementation Class, adds the required JavaBean class and generates the Java code.

For details about the format, argument, and options of the apt command, see JDK documentation. This subsection describes the contents that are not defined in the JDK documentation and the precautions for executing the command.

Organization of this section
(1) Web Service Implementation Class and SEI specified in the argument
(2) Required options
(3) Generated files
(4) Operations when a negligible error that allows processing to continue is detected
(5) Action for abnormal termination

(1) Web Service Implementation Class and SEI specified in the argument

In the argument of the apt command, specify a Web Service Implementation Class and SEI (if SEI is referenced) respectively. If you specify two or more Web Service Implementation Classes, an error message will output in the log and an error message is returned to the apt command (KDJW61002-E). However, when only SEI is specified and the Web Service Implementation Class does not exist, a warning message is output in the standard error output and log and the processing continues (KDJW61001-W). In this case, the JavaBean class is not generated.

For details about the notes related to SEIs and Web Service Implementation Classes other than the above, see the 16.1 Default mapping of Java to WSDL and 16.2 Customized mapping of Java to WSDL sections.

The following warning is displayed in the apt command if EJB Web Service Implementation Class with the javax.ejb.Stateless annotation is specified in the argument.

Warning: annotation type without processor: javax.ejb.Stateless

(2) Required options

To execute the apt command, specifying the -classpath option, -J-Dcosminexus.home option and -factory option is mandatory. The values of each option are as follows:

The -classpath option
  • Cosminexus-installation-directory/jaxws/lib/cjjaxws.jar
  • Cosminexus-installation-directory/jaxp/lib/csmjaxb.jar
  • Cosminexus-installation-directory/jaxp/lib/csmjaxp.jar
  • Cosminexus-installation-directory/jaxp/lib/csmstax.jar
  • Cosminexus-installation-directory/CC/client/lib/j2ee-javax.jar
  • Cosminexus-installation-directory/CC/client/lib/HiEJBClientStatic.jar
For Windows x86
  • HNTRLib2-installation-directory#1/classes/hntrlib2j.jar
  • HNTRLib2-installation-directory#1/classes/hntrlibMj.jar
For Windows x64
  • HNTRLib2-installation-directory#1/classes/hntrlib2j64.jar
  • HNTRLib2-installation-directory#1/classes/hntrlibMj64.jar

The -J-Dcosminexus.home option
Cosminexus-installation-directory

The -factory option#2
com.cosminexus.istack.ws.AnnotationProcessorFactoryImpl

#1
HNTRLib2-installation-directory specifies the execution results of the following command:
  • For Windows x86
    > "%COSMINEXUS_HOME%\common\bin\gethntr2conf.exe" HNTR2INSTDIR
  • For Windows x64
    > "%COSMINEXUS_HOME%\common\bin\gethntr2conf64.exe" HNTR2INSTDIR

#2
If you execute the apt command without specifying the -factory option, the JavaBean class is generated by the JDK and not by the JAX-WS functionality of Cosminexus.

(3) Generated files

The following table describes the files generated when the apt command is executed:

Table 14-5 List of files generated for the apt command

No. Java code Contents
1 Request bean class This is the JavaBean class for the request message. Output for the wrapper style.
2 Response bean class This is the JavaBean class for the response message. Output for the wrapper style.
3 Fault bean class This is the JavaBean class corresponding to the fault. Output when the wrapper exception class is defined in the specified Java code and when the fault bean does not exist.

Creating a directory for generating a file
When you execute the apt command, a directory corresponding to the package name of the generated file is created in the specified output destination directory and the file is output in that directory.
The following is an example of specification and output destination:
  • Example of command specification
    apt -d ./output -s ./output/ -sourcepath . com/example/test.java
  • Output destination
    The source files other than the JavaBean class and the compiled class file are output in the following directory:
    ./output/com/example/
    However, if the Java code specified in the command has the JavaBean class, the source file of the JavaBean class and its compiled class file are output in the jaxws sub-package of SEI package (excluding the case when the package name is customized using annotations).
    ./output/com/example/jaxws/
In the annotation processor provided by the Cosminexus JAX-WS functionality, if the output destination directory of the Java code does not exist or is not a directory and is invalid, an error message is output in the log and an error is notified to the apt command (KDJW61003-E).
The output destination directory of the compiled class file is the value of the -d option specified in the argument of the apt command. When you do not specify the -d option, the output destination directory is the value specified in the -s option. When you do not specify both the -d option and -s option, the current directory serves as the output destination directory.
The output directory of the source file is the value of the -s option specified in the apt command argument. When the -s option is not specified, the current directory is the output directory.
The apt command processes the generated source file by recursive interpretation, and hence the output destination directory of a source file might be treated as the input directory of the source file. Therefore, note that when a source file is scheduled to the output destination directory, the file might be treated as an input of the apt command. We recommend that you do not schedule a source file to the output destination directory.

Output of the Javadoc header information
In the generated file, the Cosminexus-related information is output in the header information as Javadoc.

(4) Operations when a negligible error that allows processing to continue is detected

If a negligible error that allows processing to continue is detected in the middle of the processing, a warning message is output and the processing continues.

Note that sometimes log is not output depending on the specified output level (importance). For details on the settings for the output level of a log, see 10.1.2 Settings for the common definition file.

(5) Action for abnormal termination

If an error occurs during the execution of the apt command, an error message is output and the processing ends.

If an error message is output, remove the cause of the error that is output and re-execute the apt command. Remove the causes of each of the displayed errors and repeatedly execute the apt command until the command terminates normally. If the file is already generated, delete the files generated before the apt command is executed.

Note that sometimes log is not output depending on the specified output level (importance). For details on the settings for the output level of a log, see 10.1.2 Settings for the common definition file.