一个JAVA类,用WebLogic9支持的标志语法写的WebService类,代码大概如下:
......
// Import the standard JWS annotation interfaces
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
// Import the WebLogic-specific JWS annotation interface
import weblogic.jws.WLHttpTransport;
// Standard JWS annotation that specifies that the portType nameof the Web
// Service is "BOLServicePortType", its public service name is"BOLService",
// and the targetNamespace used in the generated WSDL is "http://127.0.0.1"
@WebService(serviceName = "WebServiceDispatch", name ="WebServiceDispatchPortType", targetNamespace = "http://127.0.0.1")
// Standard JWS annotation that specifies this is adocument-literal-wrapped
// Web Service
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =SOAPBinding.Use.LITERAL, parameterStyle =SOAPBinding.ParameterStyle.WRAPPED)
// WebLogic-specific JWS annotation that specifies the context pathand service
// URI used to build the URI of the Web Service is"MOTOWebService/BOLService"
@WLHttpTransport(contextPath = "SinoairWS", serviceUri ="WebServiceDispatch", portName = "WebServiceDispatchPort")
public class WebServiceImpl {
private Logger logger =Logger.getLogger(WebServiceImpl.class.getName());
public WebServiceImpl() {
PropertyConfigurator
.configure("/bea/user_projects/domains/sinoair/properties/log4j.properties");
}
@WebMethod()
public String getCustomerName(String c_code){
String result =ControllerManager
.ServiceDispatch("<EMISService><ServiceURL>ExpressCorporationQueryService</ServiceURL><ServiceData><C_CODE>"
+c_code +"</C_CODE></ServiceData></EMISService>");
logger.debug(result);
return result;
}
......
@WebMethod()
public int checkUserInfo(String username, Stringpassword) throws Exception {
int result = 0;
try {
UserSessionInfo userData = AuthenticationMgr.getUserInfo(username,password);
result = userData!=null?0:1;
catch(Exception ex) {
result =1;
}
return result;
}
}
然后用ant编译时,出现如下异常:
BUILD FAILED
D:\EMISApp\deploy\ws\build.xml:55:com.bea.util.jam.internal.javadoc.JavadocClassloadingException: Anerror ha
s occurred while invoking javadoc to inspect your source
files. This may be due to the fact that$JAVA_HOME/lib/tools.jar does
not seem to be in your system classloader. Onecommon case in which
this happens is when using the 'ant' tool, which uses aspecial
context classloader to load classes from tools.jar.
This situation elicits what is believed to a javadoc bug in theinitial
release of JDK 1.5. Javadoc attempts to use itsown context classloader
tools.jar but ignores one that may have already been set, whichleads
to some classes being loaded into two differentclassloaders. The
telltale sign of this problem is a javadoc error message sayingthat
'languageVersion() must return LanguageVersion - you might seethis
message in your process' output.
This will hopefully be fixed in a later release of JDK 1.5; if anew
version of 1.5 has become available, you might be able to solvethis
by simply upgrading to the latest JDK.
Alternatively, you can work around it by simply including
$JAVA_HOME/lib/tools.jar in the java -classpath
parameter. If you are running ant, you will needto modify the standard
ant script to include tools.jar in the -classpath.
处理过程:
上网搜索,无果。有一些人遇到相同的问题,在网上发了贴子,无人回复;有回复,就是按照上述错误的说明,把$JAVA_HOME/lib/tools.jar加到classpath中,结果在这儿仍然还是编译不过的。
后来只能用排除法,一行行代码的删除,终于找到:原来是代码写的不正确,“catch(Exception ex){”这一行少一个“}”号,正确格式应该是“}catch(Exception ex){”但编译时它根本不报编译错,却报环境错,所以让人绕了一大圈。
希望有碰到相同问题的同学们反省一下,认真检查一下自己的代码是否写的正确。