简体   繁体   English

即使通过dependecy,也无法通过org.json.simple.parser.ParseException找到类。pom.xml中有吗?

[英]Getting class not found for org.json.simple.parser.ParseException even through dependecy is there in pom.xml?

Here is my pom.xml 这是我的pom.xml

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

<dependency>
   <groupId>org.apache.hadoop</groupId>
   <artifactId>hadoop-core</artifactId>
   <version>1.2.0</version>
   <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>
  </dependencies>

I have added the com.googlecode.json-simple as a dependency in the project, and it is working fine in eclipse build wise, but when I run the jar in hadoop I get 我在项目中添加了com.googlecode.json-simple作为依赖项,并且在eclipse构建方面运行良好,但是当我在hadoop中运行jar时,我得到了

Error: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:270)
        at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:2134)
        at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2099)
        at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2193)
        at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:186)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:745)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

Any ideas? 有任何想法吗?

I think the issue could be because of the scope . 我认为问题可能是因为范围大。

Please try to change the scope to "compile" or "test" . 请尝试将范围更改为“ compile”或“ test”。 I think you are using it for testing. 我认为您正在使用它进行测试。

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1</version>
    <scope>provided</scope>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 读取JSON对象作为映射器的输入值时,获取“ java.lang.ClassNotFoundException:org.json.simple.parser.ParseException” - Getting “java.lang.ClassNotFoundException: org.json.simple.parser.ParseException” while reading JSON object as input value of mapper Servlet:java.lang.ClassNotFoundException:org.json.simple.parser.ParseException - Servlet: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException 通过pom.xml执行主类 - Executing Main Class through pom.xml 在pom.xml中获取错误 - Getting errors in pom.xml 即使我已经在 POM.xml 中包含了所有依赖项,我在“mvn install”时也会收到符号未找到错误 - Even if I have included all the dependencies in POM.xml, I am getting symbol not found error while “mvn install” 从POM.xml获取MavenProject - pom解析器? - Get MavenProject from just the POM.xml - pom parser? java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException with eclipse 和 spring - java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException with eclipse and spring 无法解决错误:java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException - Can't resolve the error: java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException Maven:即使在pom.xml的依赖项列表中声明了org.junit包,也不存在 - Maven: package org.junit does not exist even though it is declared in dependencies list in pom.xml 将Gson添加到pom.xml但未找到 - Added Gson to the pom.xml but is not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM