[
https://issues.apache.org/jira/browse/CAMEL-8420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Espen Tjonneland updated CAMEL-8420:
------------------------------------
Description:
If you inline your Dto classes with your services then Camel fails to load them
(ClassNotFoundException).
Can easily be reproduced by modifying the Camel :: Example :: Serlet REST
example by moving the User class into the UserService and update the UserRoute
builder to use the moved type.
public class UserService {
// use a tree map so they become sorted
private final Map<String, org.apache.camel.example.rest.UserService.User>
users = new TreeMap<String, org.apache.camel.example.rest.UserService.User>();
private Random ran = new Random();
public UserService() {
users.put("123", new
org.apache.camel.example.rest.UserService.User(123, "John Doe"));
users.put("456", new
org.apache.camel.example.rest.UserService.User(456, "Donald Duck"));
users.put("789", new
org.apache.camel.example.rest.UserService.User(789, "Slow Turtle"));
}
/**
* Gets a user by the given id
*
* @param id the id of the user
* @return the user, or <tt>null</tt> if no user exists
*/
public org.apache.camel.example.rest.UserService.User getUser(String id) {
....
}
/**
* List all users
*
* @return the list of all users
*/
public Collection<org.apache.camel.example.rest.UserService.User>
listUsers() {
....
}
/**
* Updates or creates the given user
*
* @param user the user
*/
public void updateUser(org.apache.camel.example.rest.UserService.User user)
{
....
}
public static class User {
private int id;
private String name;
........
}
was:
If you inline your Dto classes with your services then Camel fails to load them
(ClassNotFoundException).
Can be reproduced by modifying the Camel :: Example :: Serlet REST Tomcat and
moving the User class into the User Service:
If you inline your Dto objects in your service as a public static class, camel
fails loading it with a java.lang.ClassNotFoundException
Can easily be reproduced by modifying the Servlet Rest Tomcat example by moving
the User class into the UserService and update the UserRoute builder to use the
moved type.
public class UserService {
// use a tree map so they become sorted
private final Map<String, org.apache.camel.example.rest.UserService.User>
users = new TreeMap<String, org.apache.camel.example.rest.UserService.User>();
private Random ran = new Random();
public UserService() {
users.put("123", new
org.apache.camel.example.rest.UserService.User(123, "John Doe"));
users.put("456", new
org.apache.camel.example.rest.UserService.User(456, "Donald Duck"));
users.put("789", new
org.apache.camel.example.rest.UserService.User(789, "Slow Turtle"));
}
/**
* Gets a user by the given id
*
* @param id the id of the user
* @return the user, or <tt>null</tt> if no user exists
*/
public org.apache.camel.example.rest.UserService.User getUser(String id) {
....
}
/**
* List all users
*
* @return the list of all users
*/
public Collection<org.apache.camel.example.rest.UserService.User>
listUsers() {
....
}
/**
* Updates or creates the given user
*
* @param user the user
*/
public void updateUser(org.apache.camel.example.rest.UserService.User user)
{
....
}
public static class User {
private int id;
private String name;
........
}
> Not possible to use inner classes for Dtos in Camel Swagger
> -----------------------------------------------------------
>
> Key: CAMEL-8420
> URL: https://issues.apache.org/jira/browse/CAMEL-8420
> Project: Camel
> Issue Type: Bug
> Components: camel-core, camel-swagger
> Affects Versions: 2.14.1
> Reporter: Espen Tjonneland
>
> If you inline your Dto classes with your services then Camel fails to load
> them (ClassNotFoundException).
> Can easily be reproduced by modifying the Camel :: Example :: Serlet REST
> example by moving the User class into the UserService and update the
> UserRoute builder to use the moved type.
> public class UserService {
> // use a tree map so they become sorted
> private final Map<String, org.apache.camel.example.rest.UserService.User>
> users = new TreeMap<String, org.apache.camel.example.rest.UserService.User>();
> private Random ran = new Random();
> public UserService() {
> users.put("123", new
> org.apache.camel.example.rest.UserService.User(123, "John Doe"));
> users.put("456", new
> org.apache.camel.example.rest.UserService.User(456, "Donald Duck"));
> users.put("789", new
> org.apache.camel.example.rest.UserService.User(789, "Slow Turtle"));
> }
> /**
> * Gets a user by the given id
> *
> * @param id the id of the user
> * @return the user, or <tt>null</tt> if no user exists
> */
> public org.apache.camel.example.rest.UserService.User getUser(String id) {
> ....
> }
> /**
> * List all users
> *
> * @return the list of all users
> */
> public Collection<org.apache.camel.example.rest.UserService.User>
> listUsers() {
> ....
> }
> /**
> * Updates or creates the given user
> *
> * @param user the user
> */
> public void updateUser(org.apache.camel.example.rest.UserService.User
> user) {
> ....
> }
> public static class User {
> private int id;
> private String name;
> ........
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)