Git Product home page Git Product logo

Comments (4)

aguibert avatar aguibert commented on June 2, 2024

hi @scottkurz, I'm not quite clear on what you're referring to as an "application from some other package"?

Do you mean that you have a resource class like com.foo.StarterResource and the JAX-RS Application class is from a different package like org.bar.MyApplication?

from microshed-testing.

scottkurz avatar scottkurz commented on June 2, 2024

hi @scottkurz, I'm not quite clear on what you're referring to as an "application from some other package"?

Do you mean that you have a resource class like com.foo.StarterResource and the JAX-RS Application class is from a different package like org.bar.MyApplication?

That's right. I was referring to the introspection done by RestClientBuilder.locateApplicationPath()

from microshed-testing.

aguibert avatar aguibert commented on June 2, 2024

Ok, I understand the scenario now thanks. A few questions now:

  1. What packages were being used in your case?
  2. Did you get a clear error message when this didn't work? Or did it take a while to figure out that the package scanning wasn't working?

Currently a heuristic is used where the first 3 packages of the resource class will be scanned.
So suppose you had com.foo.app.fourth.fifth.sixth.MyResource. We would scan for an Application in the com.foo.app.* package domain. I chose this because usually the first 3 packages are in the format <COM|ORG|etc>.<COMPANY_NAME>.<PROJECT_NAME>. Would relaxing this a bit to the first 2 packages (i.e. scan com.foo.*) solve the problem in your case?

Ultimately the auto-package scanning is a heuristic, so currently the backup way is to use RestClientBuilder. Would it be helpful if we added an optional applicationPath attribute to the @RESTClient annotation? Using the original example you could do something like:

@RESTClient(applicationPath = "/api") // since @ApplicationPath cannot be auto-detected from pkg scanning
public static StarterResource appService;

or, we could roll the entire path into a single (more generic) annotation attribute:

@RESTClient(path = "/api/starter")
public static StarterResource appService;

from microshed-testing.

scottkurz avatar scottkurz commented on June 2, 2024

I would say the error msg was reasonably clear. It didn't completely jump out at me but wasn't hard to see looking over it a couple times:

2822 DEBUG org.microshed.testing.jupiter.MicroShedTestExtension - Regsitered JSONB ObjectMapper for REST Assured
2841 DEBUG org.microshed.testing.jaxrs.RestClientBuilder - no classes implementing Application found in pkg: dev.odo.sample
2841 INFO org.microshed.testing.jaxrs.RestClientBuilder - No classes implementing 'javax.ws.rs.core.Application' found on classpath to set as context root for class dev.odo.sample.SampleResource. Defaulting context root to '/'
2939 INFO org.microshed.testing.jaxrs.RestClientBuilder - Building rest client for class dev.odo.sample.SampleResource with base path: http://asi3-5fbcf8d6b8-t28d9:9080/ and providers: [class org.microshed.testing.jaxrs.JsonBProvider]
3311 DEBUG org.microshed.testing.jupiter.MicroShedTestExtension - Injected rest client for public static dev.odo.sample.SampleResource dev.odo.sample.EndpointIT.appService
3332 INFO dev.odo.sample.EndpointIT - In test method: testAppResponse
[INFO] [WARNING ] SRVE0190E: File not found: /resource

My use case has the Application "pre-generated" from the application stack starter (at https://github.com/OpenLiberty/application-stack-starters). This is kind of primitive compared to many starters since the package name isn't customizable. So I always get dev.odo.starter.StarterApplication as my Application but I might want to develop my resources in another package name, e.g. I use dev.odo.sample.SampleResource here.

I'm just looking for something simple-looking and transparent to use with the starter, for people to learn without frustration in simple, getting started apps. Just for this use case it doesn't seem worth engineering too complex a solution.

It seems like:

@RESTClient(applicationPath = "/api") // since @ApplicationPath cannot be auto-detected from pkg scanning
public static StarterResource appService;

could be a simple solution which in a simple sample would be easy to understand to see how the client/server paths align.

from microshed-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.