mercredi 28 octobre 2015

PowerMock in Scala: java.lang.NullPointerException when getPackageName

This code just start a TezClient in local mode (not use any mock techniques yet), but it failed.

At first, it fails with this exception,

 java.lang.IllegalArgumentException: Can't find HmacSHA1 algorithm.

then I have to add this line to fix it,

@PowerMockIgnore(Array("javax.crypto.*"))

but it still failed. Anyone see this problem before?

Code:

import org.apache.tez.client.TezClient
import org.apache.tez.dag.api.TezConfiguration
import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.core.classloader.annotations.PowerMockIgnore
import org.powermock.modules.junit4.PowerMockRunner
import org.scalatest.junit.JUnitSuite

@RunWith(classOf[PowerMockRunner])
@PowerMockIgnore(Array("javax.crypto.*"))
class TestEdgeImpl extends JUnitSuite {

  @Test def test1() {
    val conf = new TezConfiguration
    conf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true)
    conf.setBoolean(TezConfiguration.TEZ_LOCAL_MODE, true)
    val tezClient = TezClient.create("LocalClient", conf)
    tezClient.start()
  }
}

Error logs:

[info]   java.lang.NullPointerException:
[info]   at org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl.getPackageName(RecordFactoryPBImpl.java:95)
[info]   at org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl.getPBImplClassName(RecordFactoryPBImpl.java:82)
[info]   at org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl.newRecordInstance(RecordFactoryPBImpl.java:56)
[info]   at org.apache.hadoop.yarn.util.Records.newRecord(Records.java:36)
[info]   at org.apache.tez2.LocalClient.createApplication(LocalClient.scala:60)
[info]   at org.apache.tez.client.LocalClient.createApplication(LocalClient.java:41)
[info]   at org.apache.tez.client.TezClient.createApplication(TezClient.java:776)
[info]   at org.apache.tez.client.TezClient.start(TezClient.java:345)
[info]   at org.apache.tez2.tmp.TestEdgeImpl.test1(TestEdgeImpl.scala:38)
[info]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[info]   ...

Aucun commentaire:

Enregistrer un commentaire