Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native build is broken? #126

Open
anthonydahanne opened this issue Nov 12, 2024 · 2 comments
Open

Native build is broken? #126

anthonydahanne opened this issue Nov 12, 2024 · 2 comments

Comments

@anthonydahanne
Copy link
Contributor

  • checkout main branch
  • use Java 21
  • do a native build with:
./mvnw  -Pbuildpacks-native
  • start the container
docker run -it -p 8080:8080 restbucks:1.0.0-SNAPSHOT
  • do a POST request
POST http://localhost:8080/orders
Content-Type: application/json

{
  "location": "To go"
}

You'll get 500 with:

13:50:00.280 I -     main : Started Restbucks in 0.385 seconds (process running for 0.393)
13:50:02.678 I - andler-0 : Initializing Spring DispatcherServlet 'dispatcherServlet'
13:50:02.678 I - andler-0 : Initializing Servlet 'dispatcherServlet'
13:50:02.678 I - andler-0 : Completed initialization in 0 ms
13:50:02.681 E - andler-0 : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null
        at org.springsource.restbucks.order.web.LocationAndDrinks.toOrder(LocationAndDrinks.java:43)
        at de.odrotbohm.spring.web.model.MappedPayloads$MappedPayload.mapIfValid(MappedPayloads.java:455)
        at org.springsource.restbucks.order.web.OrderController.placeOrder(OrderController.java:53)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)

Hint

It's possible there's missing metadata (or incompatible classes)for the native compilation; playing around with the app, I also got:

13:41:35.805 E - andler-2 : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class org.springsource.restbucks.drinks.Drink: Common causes of this problem include using a final class or a non-visible class] with root cause

java.lang.NoSuchFieldException: CGLIB$FACTORY_DATA
        at [email protected]/java.lang.Class.checkField(DynamicHub.java:1044)
        at [email protected]/java.lang.Class.getField(DynamicHub.java:1029)
@anthonydahanne
Copy link
Contributor Author

also had

13:57:29.771 I - andler-0 : Completed initialization in 0 ms
13:57:37.963 I - andler-1 : Couldn't read class metadata for interface org.springsource.restbucks.order.OrderProjection. Input property calculation might fail

@anthonydahanne
Copy link
Contributor Author

it's possible that the Rest API does not handle the error cases very well, hence some 500

Http failure response for http://localhost:8080/orders/search/findByStatus?status=jjj: 500 OK

{
  "cause": {
    "cause": {
      "cause": null,
      "message": "No enum constant org.springsource.restbucks.order.Order$Status.jjj"
    },
    "message": "Failed to convert from type [java.lang.String] to type [@org.springframework.data.repository.query.Param org.springsource.restbucks.order.Order$Status] for value [jjj]"
  },
  "message": "Failed to convert jjj into org.springsource.restbucks.order.Order$Status"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant