1. Diese Seite verwendet Cookies. Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies. Weitere Informationen

Jax-RS Client ProcessingException

Dieses Thema im Forum "Support & Discussion" wurde erstellt von masterholdy, 26. Juni 2018.

  1. masterholdy

    masterholdy New Member

    Registriert seit:
    4. Juli 2017
    Beiträge:
    26
    Zustimmungen:
    8
    Punkte für Erfolge:
    3
    Hi Leute,

    ich habe folgendes Problem. Ich habe einen Client geschrieben der auf meinen Microservices (Jax RS - Jersey) zugreift, und es hat alles funktioniert. Danach habe ich den Client innerhalb meines JSF Projektes gezogen und auf einmal werfen die Post-Requests des Clients folgende Exception:

    ( https://pastebin.com/raw/kqnTQ0XL )

    Code (Text):
    Schwerwiegend:   SUBMIT
    Schwerwiegend:   Generating incomplete JSON
    Warnung:   /issueCreate.xhtml @36,186 actionListener="#{issueCreateBoundary.submitIssue()}": javax.ws.rs.ProcessingException: wrong number of arguments
    javax.el.ELException: /issueCreate.xhtml @36,186 actionListener="#{issueCreateBoundary.submitIssue()}": javax.ws.rs.ProcessingException: wrong number of arguments
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:71)
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:124)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:72)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:490)
        at javax.faces.component.UICommand.broadcast(UICommand.java:211)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:847)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1395)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:58)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
        at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:463)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:168)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: javax.ws.rs.ProcessingException: wrong number of arguments
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:287)
        at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:765)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
        at de.hsos.kbse.agilboard.DAL.Services.Superclass.GenericClient.create(GenericClient.java:78)
        at de.hsos.kbse.agilboard.DAL.Services.UserStoryClient$Proxy$_$$_WeldClientProxy.create(Unknown Source)
        at de.hsos.kbse.agilboard.Boundary.IssueCreateBoundary.submitIssue(IssueCreateBoundary.java:26)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at javax.el.ELUtil.invokeMethod(ELUtil.java:263)
        at javax.el.BeanELResolver.invoke(BeanELResolver.java:494)
        at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:215)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:285)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
        at org.jboss.weld.module.web.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
        at org.jboss.weld.module.web.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:65)
        ... 39 more
    Caused by: java.lang.IllegalArgumentException: wrong number of arguments
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.yasson.internal.model.GetFromGetter.internalGetValue(GetFromGetter.java:28)
        at org.eclipse.yasson.internal.model.GetValueCommand.getValue(GetValueCommand.java:34)
        at org.eclipse.yasson.internal.model.ReflectionPropagation.getValue(ReflectionPropagation.java:72)
        at org.eclipse.yasson.internal.model.PropertyModel.getValue(PropertyModel.java:257)
        at org.eclipse.yasson.internal.serializer.ObjectSerializer.marshallProperty(ObjectSerializer.java:76)
        at org.eclipse.yasson.internal.serializer.ObjectSerializer.serializeInternal(ObjectSerializer.java:59)
        at org.eclipse.yasson.internal.serializer.AbstractContainerSerializer.serialize(AbstractContainerSerializer.java:60)
        at org.eclipse.yasson.internal.Marshaller.serializeRoot(Marshaller.java:118)
        at org.eclipse.yasson.internal.Marshaller.marshall(Marshaller.java:76)
        at org.eclipse.yasson.internal.JsonBinding.toJson(JsonBinding.java:98)
        at org.glassfish.jersey.jsonb.internal.JsonBindingProvider.writeTo(JsonBindingProvider.java:118)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:266)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:251)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:163)
        at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1135)
        at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:516)
        at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:498)
        at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:384)
        at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:282)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
        ... 62 more

    Schwerwiegend:   javax.ws.rs.ProcessingException: wrong number of arguments
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:287)
        at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:765)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
        at de.hsos.kbse.agilboard.DAL.Services.Superclass.GenericClient.create(GenericClient.java:78)
        at de.hsos.kbse.agilboard.DAL.Services.UserStoryClient$Proxy$_$$_WeldClientProxy.create(Unknown Source)
        at de.hsos.kbse.agilboard.Boundary.IssueCreateBoundary.submitIssue(IssueCreateBoundary.java:26)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at javax.el.ELUtil.invokeMethod(ELUtil.java:263)
        at javax.el.BeanELResolver.invoke(BeanELResolver.java:494)
        at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:215)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:285)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
        at org.jboss.weld.module.web.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
        at org.jboss.weld.module.web.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:65)
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:124)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:72)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:490)
        at javax.faces.component.UICommand.broadcast(UICommand.java:211)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:847)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1395)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:58)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
        at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:463)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:168)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.IllegalArgumentException: wrong number of arguments
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.yasson.internal.model.GetFromGetter.internalGetValue(GetFromGetter.java:28)
        at org.eclipse.yasson.internal.model.GetValueCommand.getValue(GetValueCommand.java:34)
        at org.eclipse.yasson.internal.model.ReflectionPropagation.getValue(ReflectionPropagation.java:72)
        at org.eclipse.yasson.internal.model.PropertyModel.getValue(PropertyModel.java:257)
        at org.eclipse.yasson.internal.serializer.ObjectSerializer.marshallProperty(ObjectSerializer.java:76)
        at org.eclipse.yasson.internal.serializer.ObjectSerializer.serializeInternal(ObjectSerializer.java:59)
        at org.eclipse.yasson.internal.serializer.AbstractContainerSerializer.serialize(AbstractContainerSerializer.java:60)
        at org.eclipse.yasson.internal.Marshaller.serializeRoot(Marshaller.java:118)
        at org.eclipse.yasson.internal.Marshaller.marshall(Marshaller.java:76)
        at org.eclipse.yasson.internal.JsonBinding.toJson(JsonBinding.java:98)
        at org.glassfish.jersey.jsonb.internal.JsonBindingProvider.writeTo(JsonBindingProvider.java:118)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:266)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:251)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:163)
        at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1135)
        at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:516)
        at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:498)
        at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:384)
        at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:282)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
        ... 62 more
    Wenn ich probiere einen Post-Request an den Microservices zu schicken über meine Test-Datein (Test Packages) geht dieses auch fehlerfrei. Innerhalb meines Projektes (Source Packages) erhalte ich die o.g. Exception wenn ich Post-Request über meine Boundary ausführe.

    Test-Method (geht Problemlos):
    Code (Java):
        @Test
        public void testCRUDUserStory() {
            UserStory userstory = new UserStory();    
            Optional<UserStory> response = this.userStoryClient.create(userstory);
            assertTrue(response.isPresent());
         
            userstory = response.get();
            userstory.setName("bla");    
            response = this.userStoryClient.update(userstory);
            assertTrue(response.isPresent());
            userstory = response.get();
            assertTrue(userstory.getName().equals("bla"));
         
            Integer id = userstory.getId();
            response = this.userStoryClient.getByID(id);
            assertTrue(response.isPresent());
         
            userstory = response.get();
            assertTrue(this.userStoryClient.delete(userstory));
        }
    Mein GenericClient ( https://pastebin.com/MwUjTyx5 ):

    Code (Java):
    package de.hsos.kbse.agilboard.DAL.Services.Superclass;

    import de.hsos.kbse.agilboard.DAL.DAOs.Superclass.EntityWithID;
    import de.hsos.kbse.agilboard.DAL.Services.Consts;
    import java.io.Serializable;
    import java.util.List;
    import java.util.Optional;
    import javax.ejb.Stateless;
    import javax.ws.rs.client.Client;
    import javax.ws.rs.client.ClientBuilder;
    import javax.ws.rs.client.Entity;
    import javax.ws.rs.client.WebTarget;
    import javax.ws.rs.core.GenericType;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.Response;

    public abstract class GenericClient<T extends EntityWithID> implements Serializable{
        protected Client client;
        protected WebTarget webTarget; //TODO: WebTarget muss geclosed werden wo machen wir das am besten!?
        protected String entityResourceName;
        protected GenericType<T> genericTypeEntity;
        protected GenericType<List<T>> genericTypeList;

        public GenericClient(String entityResourceName, GenericType<T> genericTypeEntity, GenericType<List<T>> genericTypeList) {
            this.client             = ClientBuilder.newClient();
            this.webTarget          = client.target(Consts.BASEURI);    
            this.entityResourceName = entityResourceName;
            this.genericTypeEntity = genericTypeEntity;
            this.genericTypeList = genericTypeList;
        }
     
        public GenericClient(){
            this.client             = ClientBuilder.newClient();
            this.webTarget          = client.target(Consts.BASEURI);
        };
     
        protected WebTarget getResourceWebTarget(){
            return client
                    .target(Consts.BASEURI)
                    .path(entityResourceName);
        }
     
        protected Optional<List<T>> retrieveEntityList(Response response){
            if(response.getStatus() == 200){
                return Optional.of(response.readEntity(this.genericTypeList));
            }else{
                return Optional.empty();
            }
        }
     
        protected Optional<T> retrieveEntity(Response response){
            if(response.getStatus() == 200){
                return Optional.of(response.readEntity(this.genericTypeEntity));
            }else{
                return Optional.empty();
            }
        }
     
        public Optional<List<T>> getAll(){
            Response response = this.getResourceWebTarget()
                    .request(MediaType.APPLICATION_JSON)
                    .get(Response.class);
            return this.retrieveEntityList(response);
        }
     
        public Optional<T> getByID(int id){
            Response response = this.getResourceWebTarget()
                                    .path(String.valueOf(id))
                                    .request(MediaType.APPLICATION_JSON)
                                    .get(Response.class);
            return this.retrieveEntity(response);
         
        }
     
        public Optional<T> create(T entity){
            Response response = this.getResourceWebTarget()
                    .request(MediaType.APPLICATION_JSON)
                    .post(Entity.entity(entity, MediaType.APPLICATION_JSON),
                        Response.class);    
            return this.retrieveEntity(response);
        }
     
        public Optional<T> update(T entity){            
            Response response = this.getResourceWebTarget()
                    .request(MediaType.APPLICATION_JSON)
                    .put(Entity.entity(entity, MediaType.APPLICATION_JSON), Response.class);
            return this.retrieveEntity(response);
        }
     
        public boolean delete(T entity){
            if(entity == null || entity.getId() == null) return false;
            return this.deleteById(entity.getId());
        }
     
        public boolean deleteById(int id){
            int status = this.getResourceWebTarget()
                    .path(String.valueOf(id))
                    .request(MediaType.APPLICATION_JSON)
                    .delete().getStatus();
            return status == 200;
        }
    }
    Mein UserStoryClient (extends GenericClient):
    Code (Java):
    @RequestScoped
    @Named
    public class UserStoryClient extends GenericClient<UserStory>{
        public UserStoryClient() {
            super(Consts.USERSTORY_RESOURCEURI, new GenericType<UserStory>(){}, new GenericType<List<UserStory>>(){});
        }

        public Optional<List<UserStory>> getByUserId(int id) {
            Response response = this.getResourceWebTarget()
                    .path(Consts.USER_RESOURCEURI)
                    .path(String.valueOf(id))
                    .request(MediaType.APPLICATION_JSON)
                    .get(Response.class);
            return this.retrieveEntityList(response);
        }
    }
    Meine Boundary die den Client aufruft und den Fehler auslöst:
    Code (Java):
    @RequestScoped
    @Named
    @Getter @Setter
    public class IssueCreateBoundary implements Serializable {
        UserStory userStory = new UserStory();
        @Inject UserStoryClient userStoryGroup;
        private Integer priorityRating;
        private Integer riskRating;

        public void submitIssue(){
            if(priorityRating != null)   userStory.setPriority(priorityRating.byteValue());
            if(riskRating != null) userStory.setRisk(riskRating.byteValue());
         
            Optional<UserStory> resp = this.userStoryGroup.create(userStory);
        }
    }
    Meine Pom XML:
    https://pastebin.com/1kZxNCKQ


    Andere Funktionen des Clients (getAll, getByID, ..) kann ich auch innerhalb der Boundary fehlerfrei aufrufen.

    Das ist gerade mein erstes 'richtiges' Java EE Projekt, ich nehme alle Vorschläge dankend an!
     
  2. SilverHazard

    SilverHazard Moderator Mitarbeiter Moderator

    Registriert seit:
    2. Juli 2017
    Beiträge:
    68
    Zustimmungen:
    51
    Punkte für Erfolge:
    18
    Geschlecht:
    männlich
    Meiner Erfahrung nach kann Java manchmal recht streng sein, was JSON angeht. Meistens ist es notwendig, alle Parameter einzeln als optional zu markieren oder eben tatsächlich sicher zu gehen, dass alle Parameter und Attribute vorhanden sind...

    Kannst du den JSON-Text und die zugehörige Klasse mal posten?
     
    krusty und masterholdy gefällt das.
  3. masterholdy

    masterholdy New Member

    Registriert seit:
    4. Juli 2017
    Beiträge:
    26
    Zustimmungen:
    8
    Punkte für Erfolge:
    3
    JSON-Text!?

    UserStory-Entity (UI)
    Code (Java):
    package de.hsos.kbse.agilboard.DAL.DAOs;


    import de.hsos.kbse.agilboard.DAL.DAOs.Superclass.EntityWithID;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.List;
    import java.util.Date;
    import java.util.Locale;
    import java.util.Locale;
    import lombok.Getter;
    import lombok.Setter;
    import lombok.ToString;


    @Getter @Setter @ToString(callSuper=true, includeFieldNames=true)
    public class UserStory extends EntityWithID{
        User initialerExperte;
        Developer initialDeveloper;
        String name;
        String descrption; //(<Benutzerrolle> will ich <eine Aktivität ausführen> , so dass <ein bestimmtes Ziel erreicht wird>) //Pattern-Validation
        /* //TODO: sollten wir das in 3 strings (benutzerrolle / eine aktivität ausführen / ein bestimmtes ziel erreich wird) aufteilen? bzw. vllt sogar dafür ne neue klasse machen? */

        byte priority; // prio 1-5 also reicht byte
        byte risk;     // ^^
        byte storyPoints; // 0-100

        //TODO: - storyPoints(POST)???? WAS IST DAS
       
        List<AcceptanceCriteria> acceptanceCriteria;
        List<Developer> participants; //beteiligte Entwickler
       
        int timeSpend;
        int estimatedTime;  
       
        Date created;
        Date dueDate;
       
        List<Comment> comments;
       
       
        public String getDueDateAsString(){
            if(dueDate != null)return  new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(dueDate);
            return "";
        }
       
     
        public String getCalculatedUntilNow(){
            Date now = new Date();
         
            Calendar cal1 = Calendar.getInstance();
            Calendar cal2 = Calendar.getInstance();

         
            cal1.setTime(this.created);
            cal2.setTime(now);

           
            long millis1 = cal1.getTimeInMillis();
            long millis2 = cal2.getTimeInMillis();

            //Differenz + Umrechnung
            long diff = millis2 - millis1;
            long diffSeconds = diff / 1000;
            long diffMinutes = diff / (60 * 1000);
            long diffHours = diff / (60 * 60 * 1000);
            long diffDays = diff / (24 * 60 * 60 * 1000);

           
            if(diffDays > 0 ) return diffDays + " d";
            if(diffHours > 0 ) return diffHours + " h";
            if(diffMinutes > 0 ) return diffMinutes + " m";
            if(diffSeconds > 0 ) return diffSeconds + " s";
           
            return "a few seconds ";
           
           
        }
        public String getParticipantsToString(){
            StringBuilder str = new StringBuilder();
            this.participants.forEach((d) -> {
                str.append(d.getName()).append(" ");
            });
            return str.toString();
        }
    }
     
    userstory im MS

    Code (Java):
    package de.hsos.kbse.agilboard.microservice.entity;


    import de.hsos.kbse.agilboard.microservice.entity.Superclass.EntityWithID;
    import java.util.List;
    import java.util.Date;
    import javax.enterprise.context.Dependent;
    import javax.persistence.CascadeType;
    import javax.persistence.Entity;
    import javax.persistence.ManyToMany;
    import javax.persistence.ManyToOne;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
    import javax.transaction.Transactional;
    import lombok.Getter;
    import lombok.Setter;
    import lombok.ToString;

    @Entity
    @Dependent
    @Transactional//(Transactional.TxType.MANDATORY)
    @Getter @Setter @ToString(callSuper=true, includeFieldNames=true)
    public class UserStory extends EntityWithID{
       
        @ManyToOne(cascade = CascadeType.MERGE)
        User initialerExperte;
        @ManyToOne(cascade = CascadeType.MERGE)
        Developer initialDeveloper;
        String name;
        String descrption; //(<Benutzerrolle> will ich <eine Aktivität ausführen> , so dass <ein bestimmtes Ziel erreicht wird>) //Pattern-Validation
        /* //TODO: sollten wir das in 3 strings (benutzerrolle / eine aktivität ausführen / ein bestimmtes ziel erreich wird) aufteilen? bzw. vllt sogar dafür ne neue klasse machen? */
       
        byte priority; // prio 1-5 also reicht byte
        byte risk;     // ^^
        byte storyPoints; // 0-100
       
        //TODO: - storyPoints(POST)???? WAS IST DAS
       
        List<AcceptanceCriteria> acceptanceCriteria;
        @ManyToMany(cascade = CascadeType.MERGE)
        List<Developer> participants; //beteiligte Entwickler
       
        int timeSpend;
        int estimatedTime;
        @Temporal(TemporalType.TIMESTAMP)
        Date created;
        @Temporal(TemporalType.DATE)
        Date dueDate;
       
        List<Comment> comments;

        public UserStory() {
            this.created = new Date();
        }
       
       
    }
     
    EntityWithID ist in MS und UI eig. gleich bis auf die JPA annotationen
    Code (Java):
    @Getter @Setter
    @EqualsAndHashCode
    public class EntityWithID implements Serializable {
        Integer id;
        long version;
        List<Link> links = new ArrayList<>();
        //TODO: injecten!?
       
        public EntityWithID addLink(String link, String rel){
            this.links.add(new Link(link, rel));
            return this;
        }
       
        public String getLink(String key){      
            Optional<Link> link = this.links.stream()
                    .filter(x -> x.rel.equals(key))
                    .findFirst();
            String result = ((link.isPresent())? link.get().link : "-na-");      
            return result;
        }
    }
     
     
  4. SilverHazard

    SilverHazard Moderator Mitarbeiter Moderator

    Registriert seit:
    2. Juli 2017
    Beiträge:
    68
    Zustimmungen:
    51
    Punkte für Erfolge:
    18
    Geschlecht:
    männlich
    Hi, sorry, dass es so lange dauert im Moment, hab jetzt aber immerhin mal alle Prüfungen für das Semester rum...

    Ich bin mit dem Framework leider nicht vertraut und steige noch nicht zu 100% durch die Code-Teile durch...

    Meine Interpretation des StackTrace:
    Scheinbar wird in einer xhtml-Datei submitIssue als ActionListener gesetzt. Diese Methode wird dann per Reflection aufgerufen, was allerdings schief geht, da nicht genügend Parameter vorhanden sind. Kann es sein, dass submitIssue eigentlich mit einer anderen Signatur erwartet wird?

    Ich könnte mir was in die Richtung vorstellen:
    Code (Java):
    public void submitIssue(Event e){
    ...
    }
     
  5. masterholdy

    masterholdy New Member

    Registriert seit:
    4. Juli 2017
    Beiträge:
    26
    Zustimmungen:
    8
    Punkte für Erfolge:
    3
    hi,

    das problem ist mittlerweile gelöst, es lag am json parser und einem konflikt mit einer entity die ein date hält
    lösung => gson als default parser registrieren und über das date ein json format hinzufügen

    danke trotzdem für die antwort :)

    ich habe ganze vergessen den thread zu closen, da ich auch in der klausurenphase bin und sehr viele sachen gleichzeitig mache..
     
    krusty und SilverHazard gefällt das.

Diese Seite empfehlen

Die Seite wird geladen...