Skip to content

Unable to use embedded pulsar for unit tests in 2.6.0 #7678

@fusionswap

Description

@fusionswap

Failed to start PulsarStandalone as embedded pulsar programmatically for unit testing. I was following guidelines based on https://github.com/streamlio/pulsar-embedded-tutorial to start embedded pulsar server.

To Reproduce
Steps to reproduce the behavior:
use below code snippet

        PulsarStandalone standalone = PulsarStandaloneBuilder.instance().build();
        final File tempFile = File.createTempFile("standalone-", "-embedded.conf");
        standalone.setConfigFile(tempFile.getAbsolutePath());
        standalone.setNoStreamStorage(true);
        standalone.start();

Expected behavior
Embedded pulsar should start and we should be able to produce and consumer messages.

Additional context
It throws below stack trace

java.lang.NoSuchMethodError: org.apache.pulsar.common.util.ObjectMapperFactory.create()Lcom/fasterxml/jackson/databind/ObjectMapper;
	at org.apache.pulsar.broker.cache.ResourceQuotaCache.<init>(ResourceQuotaCache.java:47)
	at org.apache.pulsar.broker.cache.LocalZooKeeperCacheService.<init>(LocalZooKeeperCacheService.java:122)
	at org.apache.pulsar.broker.PulsarService.startZkCacheService(PulsarService.java:693)
	at org.apache.pulsar.broker.PulsarService.start(PulsarService.java:441)
	at org.apache.pulsar.PulsarStandalone.start(PulsarStandalone.java:324)

The ObjectMapperFactory used is org.apache.pulsar.common.util.ObjectMapperFactory from pulsar-client-2.6.0.jar
It is expecting com.fasterxml.jackson.databind.ObjectMapper to be returned.
However org.apache.pulsar.common.util.ObjectMapperFactory from pulsar-client-2.6.0.jar returns shaded ObjectMapper org.apache.pulsar.shade.com.fasterxml.jackson.databind.ObjectMapper

I think it is happening as pulsar-broker and pulsar-client both are in classpath.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions