2012-09-12 4 views
0

내가 오류가 발생하고 대한하게 발음과 개미를 통합 할 수 있습니다. getFeeItemsByCapID() 메소드에 오류가 있습니다. 소스 코드에서 대답을 찾으려고 노력하지만 결과는 없습니다. 누가 오류에 대해 알 수 있습니까? 당신의 도움을 주셔서 감사합니다. 팁이 있으면.하게 발음과 CXF REST 서비스 API 프로젝트를위한 개미 통합시 REST API를 문서

:

<?xml version="1.0"?> 
<enunciate label="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd"> 
<namespaces> 
    <namespace id="api" uri="http://api.example.com/" /> 
    <namespace id="link" uri="http://api.example.com/link" /> 
    <namespace id="persona" uri="http://api.example.com/persona" /> 
</namespaces> 
<modules> 
    <!-- Docs --> 
    <docs splashPackage="org.codehaus.enunciate.api" title="test" copyright="test.com"/> 
    <java-client disabled="false"/> 
    <amf disabled="true"/> 
    <c disabled="true"/> 
    <obj-c disabled="true"/> 
    <csharp disabled="true"/> 
    <spring-app disabled="false"/> 
    <cxf disabled="false"/> 
    <gwt disabled="true"/> 
    <jaxws-ri disabled="true"/> 
    <jersey disabled="true"/> 
</modules> 

자바 코드

@GET 
@RecordDetailSecurity(RecordDetailSectionType.FEE) 
@Path("/{recordIds}/fees/") 
@Produces(MediaType.APPLICATION_JSON) 
@JsonView(Views.PublicView.class) 
public ResponseModel getFeeItemsByCapID(@PathParam("recordIds") String recordIds, 
     @QueryParam("fields") @DefaultValue("") String fields) throws Exception 
{ 

예외

개미 스크립트

<path id="enunciate.classpath"> 
    <fileset dir="${enunciate.home}/lib"> 
     <include name="*.jar"/> 
     </fileset> 
     <!--include (optional) spring module--> 
     <fileset dir="${enunciate.home}/lib/modules/cxf"> 
      <include name="*.jar"/> 
     </fileset> 
     <fileset dir="${java.home}"> 
      <include name="lib/tools.jar"/> 
     </fileset> 
    </path> 

    <taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask"> 
     <classpath refid="enunciate.classpath"/> 
    </taskdef> 

    <enunciate basedir="java/" configFile="enunciate.xml"> 
     <include name="**/*.java"/> 
     <classpath refid="enunciate.classpath"/> 
     <export artifactId="war.file" destination="d:/myapp.war"/> 
     <javacArgument argument="-g"/> 
    </enunciate> 

Enunciate.xml

java.lang.IllegalStateException: D:\AA7.2.0\main-dev\biz\modules\rest-apis\java\com\accela\restapis\jaxrs\agency\service\FeeWebService.java:76: the element 'value' must have a value specified. 
    at net.sf.jelly.apt.decorations.declaration.DecoratedAnnotationMirror.<init>(DecoratedAnnotationMirror.java:66) 
    at net.sf.jelly.apt.decorations.DeclarationDecorator.decorate(DeclarationDecorator.java:362) 
    at net.sf.jelly.apt.decorations.DeclarationDecorator.decorateAnnotationMirrors(DeclarationDecorator.java:113) 
    at net.sf.jelly.apt.decorations.declaration.DecoratedDeclaration.getAnnotationMirrors(DecoratedDeclaration.java:213) 
    at net.sf.jelly.apt.decorations.declaration.DecoratedDeclaration.getAnnotations(DecoratedDeclaration.java:195) 
    at net.sf.jelly.apt.decorations.declaration.DecoratedDeclaration.getAnnotation(DecoratedDeclaration.java:225) 
    at org.codehaus.enunciate.contract.jaxrs.ResourceMethod.<init>(ResourceMethod.java:130) 
    at org.codehaus.enunciate.contract.jaxrs.Resource.getResourceMethods(Resource.java:143) 
    at org.codehaus.enunciate.contract.jaxrs.Resource.<init>(Resource.java:69) 
    at org.codehaus.enunciate.contract.jaxrs.RootResource.<init>(RootResource.java:34) 
    at org.codehaus.enunciate.apt.EnunciateAnnotationProcessor.getRootModel(EnunciateAnnotationProcessor.java:214) 
    at org.codehaus.enunciate.apt.EnunciateAnnotationProcessor.process(EnunciateAnnotationProcessor.java:103) 
    at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60) 
    at com.sun.tools.apt.comp.Apt.main(Apt.java:454) 
    at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258) 
    at com.sun.tools.apt.main.Main.compile(Main.java:1102) 
    at com.sun.tools.apt.main.Main.compile(Main.java:964) 
    at com.sun.tools.apt.Main.processing(Main.java:95) 
    at com.sun.tools.apt.Main.process(Main.java:85) 
    at com.sun.tools.apt.Main.process(Main.java:67) 
    at org.codehaus.enunciate.main.Enunciate.invokeApt(Enunciate.java:777) 
    at org.codehaus.enunciate.main.Enunciate.doGenerate(Enunciate.java:366) 
    at org.codehaus.enunciate.main.Enunciate$Stepper.step(Enunciate.java:1735) 
    at org.codehaus.enunciate.main.Enunciate$Stepper.stepTo(Enunciate.java:1767) 
    at org.codehaus.enunciate.main.Enunciate.execute(Enunciate.java:174) 
    at org.codehaus.enunciate.main.EnunciateTask.execute(EnunciateTask.java:156) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:357) 
    at org.apache.tools.ant.Target.performTasks(Target.java:385) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
    at org.apache.tools.ant.Main.runBuild(Main.java:758) 
    at org.apache.tools.ant.Main.startAnt(Main.java:217) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) 

소스 코드 :

public DecoratedAnnotationMirror(AnnotationMirror delegate) { 
if (delegate == null) { 
    throw new IllegalArgumentException("A delegate must be provided."); 
} 

this.delegate = delegate; 
AnnotationType annotationType = delegate.getAnnotationType(); 
Collection<AnnotationTypeElementDeclaration> allElements = annotationType.getDeclaration() != null? annotationType.getDeclaration().getMethods() : Collections.<AnnotationTypeElementDeclaration>emptyList(); 
Map<AnnotationTypeElementDeclaration, AnnotationValue> elementValues = getElementValues(); 

put("annotationType", annotationType); 
put("position", delegate.getPosition()); 
put("elementValues", elementValues); 
allElementValues = new HashMap<String, Object>(); 
for (AnnotationTypeElementDeclaration element : allElements) { 
    if (elementValues.containsKey(element)) { 
    Object value = elementValues.get(element).getValue(); 
    allElementValues.put(element.getSimpleName(), value); 
    put(element.getSimpleName(), value); 
    } 
    else { 
    AnnotationValue defaultValue = element.getDefaultValue(); 
    if (defaultValue == null) { 
     throw new IllegalStateException(delegate.getPosition() + ": the element '" + element.getSimpleName() + "' must have a value specified."); 
    } 

답변

0

주석 기본값에 대한 오류가 발생했습니다. 다시 시도 할 샘플 프로젝트를 만들었습니다. 잘 작동한다. 자, 원래 생각을 바꿔야합니다. 그것은 내 잘못이야. :) 첫째로, 나의 프로젝트 컴파일은 전에 ant 표적을 enunciate하지 않고 성공했다. 그러나 "RecordDetailSectionType"열거 형은 실제로 다른 jar에 속합니다. 나는 class path를 enunciate하기 위해 jar를 포함하지 않았기 때문에 enunciate가 사용자 정의 된 annotation type 값을 인식 할 수 없다. 오해를해서 죄송합니다.

0

내 사용자 지정 주석의 근본 원인을 발견했다. 주석이 기본값이 없기 때문에 나타납니다. 메소드의 커스터마이징 된 애노테이션을 제거하거나 애노테이션 정의에 디폴트 값을 추가 할 때. 예외는 사라질 것입니다. 그러나 주석은 비즈니스 로직에서 기본값이없는 주석을 열거 할 수 있습니다. 우리는 항상 enum 값을 사용하여 설정해야합니다. 그러나 주석에 항상 기본값이 필요한 이유는 무엇입니까? 그 이유를 아는 사람 있니?

@Target({ElementType.TYPE, ElementType.METHOD}) 
@Retention(RetentionPolicy.RUNTIME) 
public @interface RecordDetailSecurity 
{ 
    RecordDetailSectionType value(); //append default value such as "default RecordDetailSectionType.ADDITIONAL_INFORMATION;" 
} 

@RecordDetailSecurity(RecordDetailSectionType.FEE) 
public ResponseModel getFeeItemsByCapID(@PathParam("recordIds") String recordIds, 
    @QueryParam("fields") @DefaultValue("") String fields) throws Exception