I think you should try annotating your RESTclientTest class with
@DomainService(nature = NatureOfService.VIEW) grtz Johan ----- Original Message ---- From: Marianne Hagaseth To: "[email protected]" Sent: Don, 21 Mei 2015 16:49 Subject: RE: JAX-RS client from ISIS: What is missing/wrong? Yes, I get a response. Thank you for the link, I will have a look at it! Best, Marianne. Med vennlig hilsen / Best regards, Marianne Hagaseth Forsker – Maritime transportsystemer Research Scientist – Maritime Transport Systems -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: 21. mai 2015 16:23 To: [email protected] Subject: Re: JAX-RS client from ISIS: What is missing/wrong? Hi Marianne, Maube dumb question but: are you sure you're getting a response? I would check with something like System.out.println(value) You can find similar code on an app I work on [1] grzt Johan [1] https://github.com/johandoornenbal/matching/blob/master/dom/src/main/java/org/isisaddons/services/remoteprofiles/FacebookProfileService.java ----- Original Message ---- From: Marianne Hagaseth To: "[email protected]" Sent: Don, 21 Mei 2015 16:08 Subject: JAX-RS client from ISIS: What is missing/wrong? Get this error messing (see at the end of the mail) when running this code (in RegulationRule.java): //Start region REST client TEST //region > showRestTest (property), setShowRestTest (action) // Call Consolidation Web Service private String showRestTest; //private BigDecimal cost; @javax.jdo.annotations.Column(allowsNull="true", length=1000) @Property(editing= Editing.DISABLED,editingDisabledReason="Use action to update Finalized") @MemberOrder(name="RegulationRule", sequence="28") @PropertyLayout(typicalLength=1000, multiLine=4) public String getShowRestTest() { //public BigDecimal getCost() { // return restClientTest.getTest(); return showRestTest; } public void setShowRestTest(final String showRestTest) { // Does not work!!this.showRestTest = restClientTest.getTest(); this.showRestTest = showRestTest; } public void modifyShowRestTest(final String showRestTest) { setShowRestTest(showRestTest); } public void clearShowRestTest() { setShowRestTest(null); } //region > RestTest (action) @Action(semantics=SemanticsOf.NON_IDEMPOTENT) public String testRestClient() { // public ToDoItem updateCost( String returnValue= restClientTest.getTest() ; setShowRestTest(returnValue); return returnValue; } //endregion REST client TEST It fails when calling the REST client: String returnValue= restClientTest.getTest() ; The REST client is like this (in RESTclientTest.java): public class RESTclientTest { // From https://docs.jboss.org/resteasy/docs/3.0-beta-3/userguide/html/RESTEasy_Client_Framework.html @Action public String getTest() { Client client = ClientBuilder.newClient(); // Create a WebTarget: WebTarget target = client.target("myURL"); // Build a request: Response response = target.request().get(); String value = response.readEntity(String.class); response.close(); // You should close connections! return value; } } What else have I done: 1) Using jboss-jaxrs-api_2.0_spec-1.0.0.Final as the REST client implementation. Updated the classpath in eclipse. 2) Added to the pom.xml: org.jboss.spec.javax.ws.rs jboss-jaxrs-api_2.0_spec 1.0.0.Final 3) Injected the REST client code in RegulationRule.java: @javax.inject.Inject private RESTclientTest restClientTest; When calling the REST client (restClientTest.getTest()) it fails here: public InvocationTargetException(Throwable target) { super((Throwable)null); // Disallow initCause this.target = target; } Are there anything missing in the Client-code or in the ISIS-part, I wonder? 15:47:17,850 [RequestCycleExtra 370520891@qtp-764920241-1 WARN ] Handling the following exception org.apache.wicket.WicketRuntimeException: Method onRequest of interface org.apache.wicket.behavior.IBehaviorListener targeted at org.apache.wicket.ajax.markup.html.AjaxLink$1@3b12e011 on component [AjaxLink [Component id = additionalLink]] threw an exception at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:268) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241) at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:250) at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236) at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862) at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289) at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) at org.apache.isis.core.webapp.diagnostics.IsisLogOnExceptionFilter.doFilter(IsisLogOnExceptionFilter.java:52) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258) ... 36 more Caused by: java.lang.NullPointerException at dom.regulation.RegulationRule.testRestClient(RegulationRule.java:230) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.internalInvoke(ActionInvocationFacetForDomainEventAbstract.java:337) at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.invoke(ActionInvocationFacetForDomainEventAbstract.java:191) at org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:57) at org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:54) at org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:205) at org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction.invoke(ActionInvocationFacetWrapTransaction.java:54) at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl.execute(ObjectActionImpl.java:367) at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl.executeWithRuleChecking(ObjectActionImpl.java:358) at org.apache.isis.viewer.wicket.model.models.ActionModel.executeAction(ActionModel.java:465) at org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionModel.java:445) at org.apache.isis.viewer.wicket.model.models.ActionModel.load(ActionModel.java:78) at org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetachableModel.java:121) at org.apache.isis.viewer.wicket.model.models.ActionModel.executeHandlingApplicationExceptions(ActionModel.java:541) at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionOnTargetAndProcessResults(ActionPanel.java:245) at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.executeActionAndProcessResults(ActionPanel.java:193) at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.buildGui(ActionPanel.java:104) at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanel.(ActionPanel.java:82) at org.apache.isis.viewer.wicket.ui.components.actions.ActionPanelFactory.createComponent(ActionPanelFactory.java:49) at org.apache.isis.viewer.wicket.viewer.registries.components.ComponentFactoryRegistryDefault.createComponent(ComponentFactoryRegistryDefault.java:128) at org.apache.isis.viewer.wicket.ui.components.widgets.linkandlabel.ActionLinkFactoryAbstract$1.onClick(ActionLinkFactoryAbstract.java:77) at org.apache.wicket.ajax.markup.html.AjaxLink$1.onEvent(AjaxLink.java:86) at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:124) at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:633) ... 40 more 15:47:17,852 [RequestCycleExtra 370520891@qtp-764920241-1 WARN ] ******************************** 15:47:17,861 [IsisTransaction 370520891@qtp-764920241-1 INFO ] abort transaction IsisTransaction@73e9b02a[state=MUST_ABORT,commands=0] https://bitbucket.org/marianne_hagaseth/creationtool/src/4953dd590b189c014ad8c81ff31cf20eee586cc1/dom/src/main/java/dom/regulation/?at=master Med vennlig hilsen / Best regards, Marianne Hagaseth Forsker - Maritime transportsystemer Research Scientist - Maritime Transport Systems MARINTEK (Norsk Marinteknisk Forskningsinstitutt AS) Address: POB 4125 Valentinlyst, NO-7450 Trondheim, Norway Mobile: +47 90 95 64 69 - Phone: +47 464 15 000 Web: www.marintek.sintef.nohttp://www.marintek.sintef.no/>;;
