You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Raymond (Jira)" <ji...@apache.org> on 2022/09/08 09:33:00 UTC

[jira] [Created] (CAMEL-18485) Error message when loading a routetemplate as resource

Raymond created CAMEL-18485:
-------------------------------

             Summary: Error message when loading a routetemplate as resource
                 Key: CAMEL-18485
                 URL: https://issues.apache.org/jira/browse/CAMEL-18485
             Project: Camel
          Issue Type: Bug
          Components: came-core
    Affects Versions: 3.18.1
         Environment: - JDK 11 (OpenJDK Temurin)
- Windows 10
- Camel 3.18.1
            Reporter: Raymond


I'm loading a xml routetemplate as resource as follows:


{code:java}
loader = extendedCamelContext.getRoutesLoader();

Resource resource = IntegrationUtil.setResource(routetemplate);

log.info("Loading routetemplate " + routetemplate);

try{
   loader.loadRoutes(resource);
}catch(java.lang.IllegalArgumentException e){
   loader.updateRoutes(resource);
}
 {code}

I however made a mistake and the resource was empty. The error message/stacktrace I received was:


{code:java}
Unable to parse resource: route.yaml        
at org.apache.camel.dsl.yaml.YamlRoutesBuilderLoaderSupport.lambda$doLoadRouteBuilder$1(YamlRoutesBuilderLoaderSupport.java:90)
        at java.base/java.util.Optional.orElseThrow(Optional.java:408)
        at org.apache.camel.dsl.yaml.YamlRoutesBuilderLoaderSupport.doLoadRouteBuilder(YamlRoutesBuilderLoaderSupport.java:90)
        at org.apache.camel.dsl.support.RouteBuilderLoaderSupport.loadRoutesBuilder(RouteBuilderLoaderSupport.java:104)
        at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:124)
        at org.apache.camel.spi.RoutesLoader.findRoutesBuilders(RoutesLoader.java:117)
        at org.apache.camel.spi.RoutesLoader.loadRoutes(RoutesLoader.java:72) {code}

I was a bit puzzled about this because I was thinking I was providing a XML. Maybe better in this case:


{code:java}
Unable to parse resource: empty resource {code}

The text also mentions 'route', but it can also be a routeConfiguration or a routeTemplate.


Three sidenotes (some things I noticed): 

1. In general one could check faulty input better. (is it a valid xml, yaml etc, or just some random text, empty or null). And for routetemplate are all the template parameters provide?
2. Notice in the example code I first need to create a resource before passing it to the routeloader. I have a string and would like to pass directly as a String to the routeloader.
3. When loading an existing route the routeloader may give an error (for example when the route already exist). I would like to loadOrUpdateRoute(String route) (this was possible in Camel 2).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)