I am using apache crunch and have got a cryptic error message from Avro:
java.lang.NoSuchMethodError: org.apache.avro.mapred.AvroKey: method <init>()V not found
at org.apache.crunch.types.avro.AvroKeyConverter.getWrapper(AvroKeyConverter.java:57)
at org.apache.crunch.types.avro.AvroKeyConverter.outputKey(AvroKeyConverter.java:36)
at org.apache.crunch.types.avro.AvroKeyConverter.outputKey(AvroKeyConverter.java:25)
at org.apache.crunch.impl.mr.emit.MultipleOutputEmitter.emit(MultipleOutputEmitter.java:41)
at org.apache.crunch.MapFn.process(MapFn.java:34)
at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:99)
at org.apache.crunch.impl.mr.emit.IntermediateEmitter.emit(IntermediateEmitter.java:56)
at org.apache.crunch.MapFn.process(MapFn.java:34)
at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:99)
at org.apache.crunch.impl.mr.emit.IntermediateEmitter.emit(IntermediateEmitter.java:56)
at org.apache.crunch.MapFn.process(MapFn.java:34)
at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:99)
at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:110)
at org.apache.crunch.impl.mr.run.CrunchMapper.map(CrunchMapper.java:60)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212)
What is the meaning of the " init()V " error ? Specifically, I'd like to fix this problem in crunch also - it only occurs when using hthe Mapredce pipeline option for a job, but i dont see it occuring using MemPipeline.
<init>()V is the internal name of a constructor that takes no parameters.
The error means that the class org.apache.avro.mapred.AvroKey that you are using does not have a no-args constructor.
You might be running your application with a version of Avro that is different from what you compiled it with. If that's the case, make sure you use the same version for compiling and running.
Otherwise, find out why your code is trying to access a constructor that doesn't exist.
<init>()V refers to the 0-parameter constructor. It seems that the class AvroKey does not have such a constructor.
This often happens when you have mismatched versions of the libraries on your classpath. In this case, it is likely that the version of Crunch on your classpath expects a version of Avro that has the no-arg constructor, but the version you are providing does not have that constructor. Hence the runtime NoSuchMethodError.
To add some color on this:
The OLD AvroKey class only supports a single, ONE argument constructor.
/** The wrapper of keys for jobs configured with {#link AvroJob} . */
public class AvroKey<T> extends AvroWrapper<T> {
/** Wrap a key. */
public AvroKey(T datum) { super(datum); }
}
The NEW AvroKey Class (1.4) and up includes an empty constructor.
So it must be an old avro implementation on my org.apache.avro.mapred.AvroKey on my classpath somewhere.
Related
This is the Google Guice calling code:
public static ContainerRunner forInjector(Injector injector) {
return (ContainerRunner)injector.getInstancefaultContainerRunner.class);
}
public static ContainerRunner forModules(Iterable<? extends Module> modules) {
return forInjector(Guice.createInjector(modules));
}
And this the exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.inject.internal.Initializer.requestInjection(Lcom/google/inject/internal/InjectorImpl;Ljava/lang/Object;Lcom/google/inject/Binding;Ljava/lang/Object;Ljava/util/Set;)Lcom/google/inject/internal/Initializable;
at com.google.inject.internal.BindingProcessor$1.visit(BindingProcessor.java:108)
at com.google.inject.internal.BindingProcessor$1.visit(BindingProcessor.java:70)
at com.google.inject.internal.ProviderInstanceBindingImpl.acceptTargetVisitor(ProviderInstanceBindingImpl.java:62)
at com.google.inject.internal.BindingProcessor.visit(BindingProcessor.java:70)
at com.google.inject.internal.BindingProcessor.visit(BindingProcessor.java:43)
at com.google.inject.internal.BindingImpl.acceptVisitor(BindingImpl.java:93)
at com.google.inject.internal.AbstractProcessor.process(AbstractProcessor.java:56)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:186)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.baml.gmt.xasf.container.ContainerRunners.forModules(ContainerRunners.java:39)
My problem is that the message does not tell me which particular method is missing. Is there a good way to debug this? Can this be a Maven transitive dependency issue?
It tells you exactly what method is missing. It's:
package com.google.inject.internal.Initializer
Initializable requestInjection(InjectorImpl, Object, Binding, Object, Set)
Considering that method signature was last changed Five years ago, you almost certainly have some sort of build issue that is making the method not be in your classpath somehow. You haven't given us enough information to be able to debug further.
It turns out that, when I executed in Unix environment, there were permission issue with the files in lib directory. As soon as I changed the permission, it got past this Guice error. This Guice error, from my paste experience, is almost always due to dependency issues, one way or the other. But Guice does not give you a more specific, more descriptive error message.
I have this code:
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
String msg = getString(R.string.common_google_play_services_update_text);
Log.e(TAG, msg);
Dialog errDlg = googleAPI.getErrorDialog(MyActivity.this, result, 1111, listener);
When this runs, the String common_google_play_services_update_text is correctly written to LogCat, but getErrorDialog() throws this Exception:
java.lang.NoSuchFieldError: No static field
common_google_play_services_update_text of type I in class
Lcom/google/android/gms/R$string; or its superclasses (declaration of
'com.google.android.gms.R$string' appears in
/data/app/com.mygame-1/base.apk)
How can I fix this?
The error NoSuchFieldError means that the class doesn't have a field of a specified name. It is thrown if an application tries to access or modify a specified field of an object, and that object no longer has that field. Normally, this error is caught by the compiler and can only occur at run time if the definition of a class has incompatibly changed.
Also, maybe you've got old code that is referencing a field that no longer exists in the recompiled class files. You may check it here.
The solution is to clean out all the class files and compile everything from fresh.
Update: If you still get the same error after recompiling everything, then you're probably compiling against one version of an external library and using another at runtime.
What you need to do now is first identify the class that is causing the problem (it looks like you have done this already) and then run your application with the -verbose:class command line option. It will dump a lot of class loading information on your standard out and you'll be able to find out where the problematic class is exactly loaded from.
Hope this helps!
I have the following class signature:
public BlockstemRequester(RateLimiter throttler,
String url, List<String> payloadsToBeRequested, List<String> objRef) {
.
.
.
}
And I'm using that constructor at this following code:
threads.add(new BlockstemRequester(RateLimiter.create(1.0),
String.format("url...", apiKey),
chunks.get(index),
chunksObjRef.get(index)))
where:
RateLimiter is from import com.google.common.util.concurrent.RateLimiter
chunks is defined as val chunks:util.List[util.List[String]] = new util.Vector[util.List[String]]
chunksObjRef is defined as val chunksObjRef:util.List[util.List[String]] = new util.Vector[util.List[String]]
But, unfortunately I'm getting an error telling me that class constructor was not found or defined:
java.lang.NoSuchMethodError: BlockstemRequester.<init>(Lcom/google/common/util/concurrent/RateLimiter;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)
Basically, I'm using this class defined in Scala at my java code project, and I did defined the scala class to use List from java to avoid any problem of incompatible types between the languages.
At runtime I'm getting this following types according to my debug process:
chunks is a Vector[Collections$SynchronizedRandomAccessList]
chunksObjRef is a Vector[Collections$SynchronizedRandomAccessList]
I appreciate any kind of help towards this problem. Thank you!
As per Java docs:
Thrown if an application tries to call a specified method of a class
(either static or instance), and that class no longer has a definition
of that method. Normally, this error is caught by the compiler; this
error can only occur at run time if the definition of a class has
incompatibly changed.
From you question it is not clear if you are getting this at compile time or run time but looks like you are having issue at run time. So, use a Java decompiler and check the .class of this class whether this method is present or not.
Most probable root cause of this issue is that library used at compile time have such a method but library used at runtime doesn't have it, and hence NoSuchMethodError.
Use decompiler and check .class file of the class.
Just solved the problem. So this was the scenario: I have a project X and using a library Y. So both X and Y have different definition of the class BlockstemRequester, both with different constructor signatures. I had to change that class name of my project and refactor my code. So, at runtime the constructor pointed out it was that one from my project X and not from that one defined in the library Y
I appreciate any advise if there is any way to approach this problem better than just renaming/refactoring my local classes
I think that the problem is with your 'typed' list.
If you change the signature to
public BlockstemRequester(RateLimiter throttler,
String url, List payloadsToBeRequested, List objRef)
Or
public BlockstemRequester(RateLimiter throttler,
String url, List<?> payloadsToBeRequested, List<?> objRef)
This will work.
I am attempting to run a tomcat application, but when I try to go to the application I get:
java.lang.NoClassDefFoundError: Could not initialize class ysl.util.Utils
ysl.util.Utils.executeQuery(Utils.java:186)
ysl.util.Utils.getProperty(Utils.java:395)
ysl.util.Utils.getProperty(Utils.java:383)
ysl.util.YslMachineProperties.init(YslMachineProperties.java:76)
ysl.util.YslMachineProperties.getTomcatImagesDirectory(YslMachineProperties.java:109)
org.apache.jsp.YSLLogin_jsp._jspService(YSLLogin_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
I have found many references to this problem on the web - most say there was a class available when the application was compiled that is not available at run time and that I need to add something to the java classpath to find it. But how can I determine what class is missing?
The error message says that the Utils class could not be initialized, yet the stacktrace shows that we are into the second method in the class, so I would think that the class was already initialized. And certainly that is not the class whose definition can't be found, since we have line number information in the stacktrace.
The method which is triggering the error looks like this:
static public ResultSet executeQuery(String queryString) throws SQLException {
return dbConnPool.executeQuery(queryString);
Any suggestions?
Most likely the Utils class is trying to use another class that is unavailable during static initialization (that would be the root cause that #BalusC pointed out). The failure to load that class causes Utils to fail as well, so even though Utils is defined, its dependencies are not.
If you are using oracle (ex Sun) java, try running:
java -verbose:class
more options under http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html
You will see what classes were loaded.
I'm trying to use the org.apache.ddlutils package for reading database metadata.
I've written the following method:
public static void readMetaData(DataSource dataSource) throws DdlUtilsException{
final Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
}
But the statement throws DdlUtilsException gives the following error:
No exception of type DdlUtilsException can be thrown; an exception type must be a subclass of Throwable
I simply do not understand the reason behind this error because the API at http://db.apache.org/ddlutils/api/org/apache/ddlutils/DdlUtilsException.html clearly states the following:
java.lang.Object
extended by java.lang.Throwable
extended by java.lang.Exception
extended by java.lang.RuntimeException
extended by org.apache.commons.lang.exception.NestableRuntimeException
extended by org.apache.ddlutils.DdlUtilsException
Please advice.
My guess is that you've got another class called DdlUtilsException somewhere - possibly in the top-level package, given that the compiler isn't mentioning a full package name. If you're using Eclipse or something similar, try to navigate to the class declaration.
EDIT: Okay, judging by your comment, you aren't including the various dependencies. Make sure you've downloaded DdlUtils-1.0-bin.zip, and the dependencies are all in the lib directory. It's not immediately clear to me whether you need all of them, but you might as well use them all to start with, and then remove what you don't need.
It looks like that other class 'org.apache.commons.lang.exception.NestableRuntimeException' is located in commons-lang. Download and add that jar and it should work. Check the docs for DDL Utils and see what else it depends on.