I'm having trouble to get started with gridgain, i'm using the xml configuration file that come with gridgain examples example-cache.xml (Is there a simpler configuration file?).
When I start gridgain as follows I got a GridException
:
public static void main(String[] args) throws GridException, URISyntaxException {
URL url = GridgainCache.class.getClassLoader().getResource("gridgain.xml");
String filename = url.toURI().toString();
System.out.println("Reading gridgain conf from: "+filename);
Grid g = GridGain.start(filename);
...
}
Here is full stack trace:
Exception in thread "main" class org.gridgain.grid.GridException: Failed to add no-op logger for Log4j.
For more information see:
Troubleshooting: http://bit.ly/GridGain-Troubleshooting
Documentation Center: http://bit.ly/GridGain-Documentation
at org.gridgain.grid.util.GridUtils.addLog4jNoOpLogger(GridUtils.java:7709)
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:714)
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:659)
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:522)
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:492)
at org.gridgain.grid.GridGain.start(GridGain.java:314)
at com.examples.gridgain.GridgainCache.main(GridgainCache.java:102)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gridgain.grid.util.GridUtils.addLog4jNoOpLogger(GridUtils.java:7706)
... 6 more
Do I need to configure log4j? i'm using slf4j.
GridGain checks if there are Log4j classes available in classpath and tries to add Log4j logger automatically, which in your case leads to the error because of Log4j version mismatch.
Since you cannot switch to the Log4j v1.2.17 supported by GridGain, you should configure another logger manually. I would use SLF4j bridge matching the version of Log4j you already have (note you will need to add gridgain-slf4j dependency):
<property name="gridLogger">
<bean class="org.gridgain.grid.logger.slf4j.GridSlf4jLogger"/>
</property>
Another option is to use Java logging (no additional dependencies needed)
<property name="gridLogger">
<bean class="org.gridgain.grid.logger.java.GridJavaLogger"/>
</property>