You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by urwithsumit <su...@gmail.com> on 2017/01/05 08:28:24 UTC

Camel EhCache 2.18.1 - Exception during initialization

Hi,

I am using Camel 2.18.1, and as per the documentation camel-cache is getting
depricated from 2.18.x version. 

I want to stay with the latest and wan tto use the new camel-ehcache
component. I did the configuration looking at the documentation and taking
some sample from the camel ehcache component test cases.

Below is what i am doing:
1. I have created a ehcache-config.xml as per the sample xml provided in the
ehcache-component test case. The config is placed directly inside my
resources folder.
2. I am creating an endpoint for ehcache and passing the ehcache-config.xml
as below:
from("ehcache://appCache?configUri=ehcache-config.xml")
.log("*** Value added to the primary cache ****")
.end();

On running the code, i am getting the exception

Caused by: java.lang.IllegalArgumentException: CacheConfiguration must be
specified
	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:308)
	at
org.apache.camel.component.ehcache.EhcacheConfiguration.getMandatoryConfiguration(EhcacheConfiguration.java:243)
	at
org.apache.camel.component.ehcache.EhcacheManager.getCache(EhcacheManager.java:72)
	at
org.apache.camel.component.ehcache.EhcacheManager.getCache(EhcacheManager.java:88)
	at
org.apache.camel.component.ehcache.EhcacheProducer.<init>(EhcacheProducer.java:40)
	at
org.apache.camel.component.ehcache.EhcacheEndpoint.createProducer(EhcacheEndpoint.java:46)
	at
org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:574)


Please advice how i need to set the value for configUri so it gets parsed
correctly to configuration.

Regards
Sumit



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by urwithsumit <su...@gmail.com>.
Luca,

I reverted back to the camel-cache component as i was not getting ahead with
ehcache.

As per your request, I have logged it as a minor bug: 

https://issues.apache.org/jira/browse/CAMEL-10681

Regards
Sumit




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164p5792291.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by Luca Burgazzoli <lb...@gmail.com>.
Setting configUri was supposed to work so can you raise a jira issue ?
I will have a look later this week



---
Luca Burgazzoli


On Thu, Jan 5, 2017 at 7:11 PM, urwithsumit <su...@gmail.com> wrote:
> So now i tired another way, in the Camel test cases for ehcache used jndi
> registry to bind the configuration. I am starting the camel context through
> Main class, and below is the change i have to do:
>> I am loading Spring context with Main.main(args).
>> I am binding the cacheConfiguration to the psmCacheConfig in the JNDI
>> registry.
>> JNDI registry gets added to a new DefaultCamelContext
>> The DefaultCamelContext is added to the list of context in the current
>> Main
>> Now i add the ConfigLoadServerRoute to the Main as i have the JNDI entry
>> now available.
>> After this i add my FileWatchServerRoute routes that are calling the
>> endpoint present in ConfigLoadServerRoute.
>
> public static void main(String[] args) throws Exception {
>
>         Main.main(args);
>                 JndiRegistry registry = new JndiRegistry();
>                  registry.bind("psmCacheConfig",
>                             CacheConfigurationBuilder.newCacheConfigurationBuilder(
>                                 String.class,
>                                 String.class,
>                                 ResourcePoolsBuilder.newResourcePoolsBuilder()
>                                     .heap(10000, EntryUnit.ENTRIES)
>                                     .offheap(30, MemoryUnit.MB))
>                             .build()
>                         );
>                 DefaultCamelContext context = new DefaultCamelContext(registry);
>                 Main.getInstance().getCamelContexts().add(context);
>
>                 Main.getInstance().addRouteBuilder(new ConfigLoadServerRoute());
>                 Main.getInstance().addRouteBuilder(new FileWatchServerRoute());
>     }
>
> My Route inside the ConfigLoadServerRoute looks like this -
> from("ehcache://appCache?configUri=file:/home/config/ehcache/ehcache-config.xml&configuration=#psmCacheConfig")
> .log("*** Value added to the primary cache ****")
> .end();
>
> jndi.properties file is present in the resources, and has the following
> entry
> java.naming.factory.initial =
> org.apache.camel.util.jndi.CamelInitialContextFactory
>
>
> With this, my application loads. But now my question is there a better way
> to configure JNDI registry before hand so I don't have to add the routes in
> main method but i can load the routes from Spring context.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164p5792213.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by urwithsumit <su...@gmail.com>.
So now i tired another way, in the Camel test cases for ehcache used jndi
registry to bind the configuration. I am starting the camel context through
Main class, and below is the change i have to do: 
> I am loading Spring context with Main.main(args).
> I am binding the cacheConfiguration to the psmCacheConfig in the JNDI
> registry. 
> JNDI registry gets added to a new DefaultCamelContext
> The DefaultCamelContext is added to the list of context in the current
> Main
> Now i add the ConfigLoadServerRoute to the Main as i have the JNDI entry
> now available.
> After this i add my FileWatchServerRoute routes that are calling the
> endpoint present in ConfigLoadServerRoute.

public static void main(String[] args) throws Exception {
		
    	Main.main(args);
		JndiRegistry registry = new JndiRegistry();
		 registry.bind("psmCacheConfig",
		            CacheConfigurationBuilder.newCacheConfigurationBuilder(
		                String.class,
		                String.class,
		                ResourcePoolsBuilder.newResourcePoolsBuilder()
		                    .heap(10000, EntryUnit.ENTRIES)
		                    .offheap(30, MemoryUnit.MB))
		            .build()
		        );
		DefaultCamelContext context = new DefaultCamelContext(registry);
		Main.getInstance().getCamelContexts().add(context);
		
		Main.getInstance().addRouteBuilder(new ConfigLoadServerRoute());
		Main.getInstance().addRouteBuilder(new FileWatchServerRoute());
    }

My Route inside the ConfigLoadServerRoute looks like this - 
from("ehcache://appCache?configUri=file:/home/config/ehcache/ehcache-config.xml&configuration=#psmCacheConfig")
.log("*** Value added to the primary cache ****")
.end();

jndi.properties file is present in the resources, and has the following
entry
java.naming.factory.initial =
org.apache.camel.util.jndi.CamelInitialContextFactory


With this, my application loads. But now my question is there a better way
to configure JNDI registry before hand so I don't have to add the routes in
main method but i can load the routes from Spring context.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164p5792213.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by urwithsumit <su...@gmail.com>.
@lburgazzoli - I have tried your way earlier. It gives the same errror.  

Caused by: java.lang.IllegalArgumentException: CacheConfiguration must be
specified
	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:310)
	at
org.apache.camel.component.ehcache.EhcacheConfiguration.getMandatoryConfiguration(EhcacheConfiguration.java:243)



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164p5792208.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by Luca Burgazzoli <lb...@gmail.com>.
I would suggest to try with something like:

    from("ehcache://appCache?configUri=classpath:ehcache-config.xml")




---
Luca Burgazzoli


On Thu, Jan 5, 2017 at 9:48 AM, urwithsumit <su...@gmail.com> wrote:
> As per the EhcacheTestsupport.java, I made the change to read the xml
> configuration.
>
> final URI url =
> this.getClass().getResource("/ehcache/ehcache-config.xml").toURI();
> //final Configuration xmlConfig = new XmlConfiguration(url);
>
> from("ehcache://appCache?configUri=" + url)
> .log("*** Value added to the primary cache ****")
> .end();
>
> But this does not solve the problem. Still give the earlier error message.
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164p5792167.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by urwithsumit <su...@gmail.com>.
As per the EhcacheTestsupport.java, I made the change to read the xml
configuration.

final URI url =
this.getClass().getResource("/ehcache/ehcache-config.xml").toURI();
//final Configuration xmlConfig = new XmlConfiguration(url);
		
from("ehcache://appCache?configUri=" + url)
.log("*** Value added to the primary cache ****")
.end();

But this does not solve the problem. Still give the earlier error message.






--
View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164p5792167.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel EhCache 2.18.1 - Exception during initialization

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

A good idea can be to look at the unit tests of camel-ehcache to see
how it tests itself.

On Thu, Jan 5, 2017 at 9:28 AM, urwithsumit <su...@gmail.com> wrote:
> Hi,
>
> I am using Camel 2.18.1, and as per the documentation camel-cache is getting
> depricated from 2.18.x version.
>
> I want to stay with the latest and wan tto use the new camel-ehcache
> component. I did the configuration looking at the documentation and taking
> some sample from the camel ehcache component test cases.
>
> Below is what i am doing:
> 1. I have created a ehcache-config.xml as per the sample xml provided in the
> ehcache-component test case. The config is placed directly inside my
> resources folder.
> 2. I am creating an endpoint for ehcache and passing the ehcache-config.xml
> as below:
> from("ehcache://appCache?configUri=ehcache-config.xml")
> .log("*** Value added to the primary cache ****")
> .end();
>
> On running the code, i am getting the exception
>
> Caused by: java.lang.IllegalArgumentException: CacheConfiguration must be
> specified
>         at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:308)
>         at
> org.apache.camel.component.ehcache.EhcacheConfiguration.getMandatoryConfiguration(EhcacheConfiguration.java:243)
>         at
> org.apache.camel.component.ehcache.EhcacheManager.getCache(EhcacheManager.java:72)
>         at
> org.apache.camel.component.ehcache.EhcacheManager.getCache(EhcacheManager.java:88)
>         at
> org.apache.camel.component.ehcache.EhcacheProducer.<init>(EhcacheProducer.java:40)
>         at
> org.apache.camel.component.ehcache.EhcacheEndpoint.createProducer(EhcacheEndpoint.java:46)
>         at
> org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:574)
>
>
> Please advice how i need to set the value for configUri so it gets parsed
> correctly to configuration.
>
> Regards
> Sumit
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-EhCache-2-18-1-Exception-during-initialization-tp5792164.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2