Maven 2 WAS 8.5服务器的javax.validation兼容性问题
我正试图在WAS8.5服务器上部署我的应用程序,但我看到一些非常奇怪的事情发生了。 当我在构建时使用下面的jar时,应用程序将与我的wsdl一起构建,不会出现任何问题。但在WAS8.5服务器中部署时失败。 WAS8.5.5.3正在使用JDK1.6.0 使用的依赖项:Maven 2 WAS 8.5服务器的javax.validation兼容性问题,maven-2,websphere,wsgen,Maven 2,Websphere,Wsgen,我正试图在WAS8.5服务器上部署我的应用程序,但我看到一些非常奇怪的事情发生了。 当我在构建时使用下面的jar时,应用程序将与我的wsdl一起构建,不会出现任何问题。但在WAS8.5服务器中部署时失败。 WAS8.5.5.3正在使用JDK1.6.0 使用的依赖项: <dependency> <groupId>javax.validation</groupId> <artifactId>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>provided</scope>
</dependency>
端点在内部调用使用验证api的此类:
import javax.validation.ConstraintViolation;
import javax.xml.ws.WebFault;
@WebFault(faultBean = "com.hex.bam.core.exception.BusinessError", name = "searchRequestValidationException", targetNamespace = RDS_SERVICE_NAMESPACE)
public class SearchRequestValidationException extends BamBusinessException {
public SearchRequestValidationException(Set<ConstraintViolation<Criteria>> constraintViolations) {
super(constraintViolations);
}
import javax.validation.ConstraintViolation;
导入javax.xml.ws.WebFault;
@WebFault(faultBean=“com.hex.bam.core.exception.BusinessError”,name=“searchRequestValidationException”,targetNamespace=RDS\U服务\U命名空间)
公共类SearchRequestValidationException扩展了BamBusinessException{
public SearchRequestValidationException(设置constraintViolations){
超级(限制性暴力);
}
添加更多详细信息:
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
public abstract class BamBusinessException extends Exception {
private static final long serialVersionUID = 1L;
protected <C> BamBusinessException(Set<ConstraintViolation<C>> constraintViolations) {
error = ErrorFactory.buildBusinessError(this, constraintViolations);
}
}
public class ErrorFactory {
public static <T extends BamBusinessException, C> BusinessError buildBusinessError(
T exception, Set<ConstraintViolation<C>> constraintViolations) {
BusinessError error = buildBusinessError(exception);
List<BasicConstraintViolation> violations = new ArrayList<BasicConstraintViolation>();
if (constraintViolations != null) {
for (ConstraintViolation<C> violation : constraintViolations) {
violations.add(parse(violation));
}
}
error.setConstraintViolationList(violations);
return error;
}
}
import static com.hex.bam.core.dto.NamespaceConstants.CORE_DTO_NAMESPACE;
import javax.xml.bind.annotation.XmlType;
@XmlType(namespace = CORE_DTO_NAMESPACE)
public class BasicConstraintViolation {
private String propertyPath;
private String resourceKey;
public void setPropertyPath(String propertyPath) {
this.propertyPath = propertyPath;
}
public void setResourceKey(String resourceKey) {
this.resourceKey = resourceKey;
}
public String getResourceKey() {
return resourceKey;
}
public String getPropertyPath() {
return propertyPath;
}
@Override
public String toString() {
return "{" + getPropertyPath() + ":::" + getResourceKey() + "}";
}
import javax.jws.HandlerChain;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
@HandlerChain(file = "../../../../../../../handler-chain.xml")
@javax.jws.WebService(endpointInterface = ENDPOINT_INTERFACE, targetNamespace = RDS_SERVICE_NAMESPACE, serviceName = SERVICE_NAME, portName = PORT_NAME)
@XmlSeeAlso({ com.hex.bam.rds.domain.Organisation.class, com.hex.bam.rds.domain.Individual.class })
public class EntitySearchServiceEndpoint extends SpringBeanAutowiringSupport implements EntitySearchService {
@Autowired
private SearchService searchService;
@Autowired
private AuthenticationService authenticationService;
@Autowired
private ModelSupportService defaultModelSupportService;
@Autowired
private RegulatoryClassificationService regulatoryClassificationService;
@Override
public IndividualSearchResults findIndividuals(IndividualSearchCriteria individualSearchCriteria,
ClientIdentification clientIdentification) throws CobamSystemException, SearchRequestValidationException {
try {
authenticationService.authenticateOnBehalfOfUser(clientIdentification);
assertParameterSuppliedThrowsSearchRequestValidationException(individualSearchCriteria);
defaultModelSupportService.initialiseReferenceDatum(individualSearchCriteria, TreeWalker.MAX_DEPTH);
return searchService.findIndividuals(individualSearchCriteria);
} catch (RuntimeException runtimeException) {
throw ErrorFactory.buildAndLogCobamSystemException(runtimeException);
}
}
}
@WebService(name = "EntitySearchService", targetNamespace = RDS_SERVICE_NAMESPACE)
@SOAPBinding(parameterStyle = ParameterStyle.BARE)
@XmlSeeAlso({ Individual.class, Organisation.class })
public interface EntitySearchService {
@WebMethod(operationName = "findOrganisations", action = RDS_SERVICE_NAMESPACE + "findOrganisations")
@WebResult(name = "organisationSearchResults", targetNamespace = ERDS_SERVICE_NAMESPACE)
OrganisationSearchResults findOrganisations(
@WebParam(name = "organisationSearchCriteria") OrganisationSearchCriteria organisationSearchCriteria,
@WebParam(name = "findOrganisationsClientIdentification", header = true) ClientIdentification clientIdentification)
throws BamSystemException, SearchRequestValidationException;
}
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlType;
import com.hex.bam.core.dto.BasicConstraintViolation;
@XmlType(name = "businessError", namespace = EXCEPTION_NAMESPACE)
public class BusinessError extends Error {
private final List<BasicConstraintViolation> constraintViolationList;
public BusinessError(Date occuredAt, String resourceKey, String guid,
List<BasicConstraintViolation> constraintViolationList) {
super(occuredAt, resourceKey, guid);
this.constraintViolationList = constraintViolationList;
}
public List<BasicConstraintViolation> getConstraintViolationList() {
return constraintViolationList;
}
@Override
public String toString() {
String violations = constraintViolationList != null ? constraintViolationList.toString() : " none ";
return getGuid() + " - Business Error - " + getResourceKey() + " [" + violations + "]";
}
}
import javax.validation.ConstraintViolation;
导入javax.validation.ConstraintViolationException;
公共抽象类BamBusinessException扩展了异常{
私有静态最终长serialVersionUID=1L;
受保护的BamBusinessException(设置约束条件){
error=ErrorFactory.buildBusinessError(这是constraintViolations);
}
}
公共类错误工厂{
公共静态BusinessError buildBusinessError(
T异常,设置约束(异常){
BusinessError=buildBusinessError(异常);
列表冲突=新建ArrayList();
if(constraintViolations!=null){
for(ConstraintViolation冲突:constraintViolations){
添加(解析(违规));
}
}
错误。setConstraintViolationList(冲突);
返回误差;
}
}
导入静态com.hex.bam.core.dto.NamespaceConstants.core\u dto\u命名空间;
导入javax.xml.bind.annotation.XmlType;
@XmlType(名称空间=核心名称空间)
公共类基本约束{
私有字符串propertyPath;
私有字符串资源密钥;
公共void setPropertyPath(字符串propertyPath){
this.propertyPath=propertyPath;
}
public void setResourceKey(字符串resourceKey){
this.resourceKey=resourceKey;
}
公共字符串getResourceKey(){
返回resourceKey;
}
公共字符串getPropertyPath(){
返回属性路径;
}
@凌驾
公共字符串toString(){
返回“{”+getPropertyPath()+”:“+getResourceKey()+”}”;
}
导入javax.jws.HandlerChain;
导入javax.xml.bind.annotation.xmlsee;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.web.context.support.SpringBeanAutowiringSupport;
@HandlerChain(file=“../../../../../../../../../handler chain.xml”)
@javax.jws.WebService(endpointInterface=ENDPOINT\u INTERFACE,targetNamespace=RDS\u SERVICE\u命名空间,serviceName=SERVICE\u NAME,portName=PORT\u NAME)
@XMLSEEAL({com.hex.bam.rds.domain.organization.class,com.hex.bam.rds.domain.Individual.class})
公共类EntitySearchServiceEndpoint扩展了SpringBeanAutowiringSupport实现EntitySearchService{
@自动连线
私人搜索服务;
@自动连线
私人认证服务认证服务;
@自动连线
私有ModelSupportService defaultModelSupportService;
@自动连线
私人监管分类服务监管分类服务;
@凌驾
公共个人搜索结果查找个人(个人搜索标准个人搜索标准,
ClientIdentification(ClientIdentification)引发CobamSystemException、SearchRequestValidationException{
试一试{
authenticationService.AuthenticateOnBehalfourUser(客户端标识);
AssertParametersSuppliedHrowsSearchRequestValidationException(individualSearchCriteria);
defaultModelSupportService.InitializerReferenceDatum(individualSearchCriteria,TreeWalker.MAX_DEPTH);
返回searchService.findIndividuals(individualSearchCriteria);
}捕获(RuntimeException RuntimeException){
抛出ErrorFactory.buildAndLogCobamSystemException(运行时异常);
}
}
}
@WebService(name=“EntitySearchService”,targetNamespace=RDS\U服务\U命名空间)
@SOAPBinding(parameterStyle=parameterStyle.BARE)
@XMLSEEALSE({Individual.class,organization.class})
公共接口EntitySearchService{
@WebMethod(operationName=“FindOrganizations”,action=RDS\服务\命名空间+“FindOrganizations”)
@WebResult(name=“OrganizationSearchResults”,targetNamespace=ERDS\u服务\u命名空间)
组织搜索结果查找组织(
@WebParam(name=“OrganizationSearchCriteria”)OrganizationSearchCriteria OrganizationSearchCriteria,
@WebParam(name=“FindOrganizationClientIdentification”,header=true)ClientIdentification(ClientIdentification)
抛出BamSystemException、SearchRequestValidationException;
}
导入java.util.Date;
导入java.util.List;
导入javax.xml.bind.annotation.XmlType;
导入com.hex.bam.core.dto.BasicConstraintViolation;
@XmlType(name=“businessError”,namespace=EXCEPTION\u namespace)
公共类BusinessError扩展错误{
私人最终清单约束性清单;
public BusinessError(发生日期、字符串resourceKey、字符串guid、,
列表约束(事件列表){
超级(发生日期、资源密钥、guid);
this.constraintViolationList=constraintViolationList;
}
公共列表getConstraintViolationList(){
返回约束列表;
}
@凌驾
公共字符串toString(){
字符串冲突=constraintViolationList!=null?constraintViolationList.toString():“无”;
返回getGuid()+“-业务错误-“+getResourceKey()+”[“+violations+”]”;
}
}
看起来您正在对一种JAXB类型进行Bean验证。为什么不
import javax.validation.ConstraintViolation;
import javax.xml.ws.WebFault;
@WebFault(faultBean = "com.hex.bam.core.exception.BusinessError", name = "searchRequestValidationException", targetNamespace = RDS_SERVICE_NAMESPACE)
public class SearchRequestValidationException extends BamBusinessException {
public SearchRequestValidationException(Set<ConstraintViolation<Criteria>> constraintViolations) {
super(constraintViolations);
}
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
public abstract class BamBusinessException extends Exception {
private static final long serialVersionUID = 1L;
protected <C> BamBusinessException(Set<ConstraintViolation<C>> constraintViolations) {
error = ErrorFactory.buildBusinessError(this, constraintViolations);
}
}
public class ErrorFactory {
public static <T extends BamBusinessException, C> BusinessError buildBusinessError(
T exception, Set<ConstraintViolation<C>> constraintViolations) {
BusinessError error = buildBusinessError(exception);
List<BasicConstraintViolation> violations = new ArrayList<BasicConstraintViolation>();
if (constraintViolations != null) {
for (ConstraintViolation<C> violation : constraintViolations) {
violations.add(parse(violation));
}
}
error.setConstraintViolationList(violations);
return error;
}
}
import static com.hex.bam.core.dto.NamespaceConstants.CORE_DTO_NAMESPACE;
import javax.xml.bind.annotation.XmlType;
@XmlType(namespace = CORE_DTO_NAMESPACE)
public class BasicConstraintViolation {
private String propertyPath;
private String resourceKey;
public void setPropertyPath(String propertyPath) {
this.propertyPath = propertyPath;
}
public void setResourceKey(String resourceKey) {
this.resourceKey = resourceKey;
}
public String getResourceKey() {
return resourceKey;
}
public String getPropertyPath() {
return propertyPath;
}
@Override
public String toString() {
return "{" + getPropertyPath() + ":::" + getResourceKey() + "}";
}
import javax.jws.HandlerChain;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
@HandlerChain(file = "../../../../../../../handler-chain.xml")
@javax.jws.WebService(endpointInterface = ENDPOINT_INTERFACE, targetNamespace = RDS_SERVICE_NAMESPACE, serviceName = SERVICE_NAME, portName = PORT_NAME)
@XmlSeeAlso({ com.hex.bam.rds.domain.Organisation.class, com.hex.bam.rds.domain.Individual.class })
public class EntitySearchServiceEndpoint extends SpringBeanAutowiringSupport implements EntitySearchService {
@Autowired
private SearchService searchService;
@Autowired
private AuthenticationService authenticationService;
@Autowired
private ModelSupportService defaultModelSupportService;
@Autowired
private RegulatoryClassificationService regulatoryClassificationService;
@Override
public IndividualSearchResults findIndividuals(IndividualSearchCriteria individualSearchCriteria,
ClientIdentification clientIdentification) throws CobamSystemException, SearchRequestValidationException {
try {
authenticationService.authenticateOnBehalfOfUser(clientIdentification);
assertParameterSuppliedThrowsSearchRequestValidationException(individualSearchCriteria);
defaultModelSupportService.initialiseReferenceDatum(individualSearchCriteria, TreeWalker.MAX_DEPTH);
return searchService.findIndividuals(individualSearchCriteria);
} catch (RuntimeException runtimeException) {
throw ErrorFactory.buildAndLogCobamSystemException(runtimeException);
}
}
}
@WebService(name = "EntitySearchService", targetNamespace = RDS_SERVICE_NAMESPACE)
@SOAPBinding(parameterStyle = ParameterStyle.BARE)
@XmlSeeAlso({ Individual.class, Organisation.class })
public interface EntitySearchService {
@WebMethod(operationName = "findOrganisations", action = RDS_SERVICE_NAMESPACE + "findOrganisations")
@WebResult(name = "organisationSearchResults", targetNamespace = ERDS_SERVICE_NAMESPACE)
OrganisationSearchResults findOrganisations(
@WebParam(name = "organisationSearchCriteria") OrganisationSearchCriteria organisationSearchCriteria,
@WebParam(name = "findOrganisationsClientIdentification", header = true) ClientIdentification clientIdentification)
throws BamSystemException, SearchRequestValidationException;
}
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlType;
import com.hex.bam.core.dto.BasicConstraintViolation;
@XmlType(name = "businessError", namespace = EXCEPTION_NAMESPACE)
public class BusinessError extends Error {
private final List<BasicConstraintViolation> constraintViolationList;
public BusinessError(Date occuredAt, String resourceKey, String guid,
List<BasicConstraintViolation> constraintViolationList) {
super(occuredAt, resourceKey, guid);
this.constraintViolationList = constraintViolationList;
}
public List<BasicConstraintViolation> getConstraintViolationList() {
return constraintViolationList;
}
@Override
public String toString() {
String violations = constraintViolationList != null ? constraintViolationList.toString() : " none ";
return getGuid() + " - Business Error - " + getResourceKey() + " [" + violations + "]";
}
}