KKcorps opened a new issue #10903:
URL: https://github.com/apache/pulsar/issues/10903


   **Describe the bug**
   I am using `pulsar-broker-shaded` dependency to create `PulsarStandalone` 
cluster locally. However, the cluster fails at startup with the following 
exception - 
   
   ```
   java.io.IOException: Failed to instantiate ledger storage : 
org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.bookie.LedgerStorageFactory.createLedgerStorage(LedgerStorageFactory.java:35)
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.bookie.Bookie.buildLedgerStorage(Bookie.java:637)
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.bookie.Bookie.<init>(Bookie.java:759)
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.proto.BookieServer.newBookie(BookieServer.java:152)
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.proto.BookieServer.<init>(BookieServer.java:120)
        at 
org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble.runBookies(LocalBookkeeperEnsemble.java:302)
        at 
org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble.startStandalone(LocalBookkeeperEnsemble.java:430)
        at org.apache.pulsar.PulsarStandalone.start(PulsarStandalone.java:258)
        at org.kharekartik.Main.main(Main.java:39)
   Caused by: java.lang.RuntimeException: 
org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage not 
org.apache.pulsar.shade.org.apache.bookkeeper.bookie.LedgerStorage
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.common.util.ReflectionUtils.newInstance(ReflectionUtils.java:169)
        at 
org.apache.pulsar.shade.org.apache.bookkeeper.bookie.LedgerStorageFactory.createLedgerStorage(LedgerStorageFactory.java:33)
        ... 8 more
   ```
   
   The `pulsar-broker` unshaded dependency works correctly but I can't use it 
as it throws a lot of dependency convergence errors due to `maven enforcer` 
plugin. The plugin is present in parent pom and is mandatory so can't disable 
it.
   
   
   **To Reproduce**
   
   ```java
   final File clusterConfigFile = new 
File(Main.class.getClassLoader().getResource("standalone.conf").toURI());
       ServiceConfiguration config =
           PulsarConfigurationLoader.create((new 
FileInputStream(clusterConfigFile)), ServiceConfiguration.class);
       config.setManagedLedgerDefaultEnsembleSize(1);
       config.setManagedLedgerDefaultWriteQuorum(1);
       config.setManagedLedgerDefaultAckQuorum(1);
       String zkServers = "127.0.0.1";
       config.setAdvertisedAddress("localhost");
   
       PulsarStandalone
           pulsarStandalone = 
PulsarStandaloneBuilder.instance().withConfig(config).withNoStreamStorage(true).build();
   
       if (config.getZookeeperServers() != null) {
         
pulsarStandalone.setZkPort(Integer.parseInt(config.getZookeeperServers().split(":")[1]));
       }
   
       config.setZookeeperServers(zkServers + ":" + 
pulsarStandalone.getZkPort());
       config.setConfigurationStoreServers(zkServers + ":" + 
pulsarStandalone.getZkPort());
   
       config.setRunningStandalone(true);
   
       pulsarStandalone.setConfigFile(clusterConfigFile.getAbsolutePath());
       pulsarStandalone.setConfig(config);
   
       pulsarStandalone.start();
   
       PulsarAdmin admin =
           PulsarAdmin.builder().serviceHttpUrl("http://localhost:"; + 
config.getWebServicePort().get()).build();
   
       admin.topics().createPartitionedTopic("test-topic", 3);
   ```
   
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0";
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
   
     <groupId>org.example</groupId>
     <artifactId>pulsar-standalone-repro</artifactId>
     <version>1.0-SNAPSHOT</version>
   
     <properties>
       <pulsar.version>2.7.2</pulsar.version>
     </properties>
   
     <dependencies>
       <dependency>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-broker-shaded</artifactId>
         <version>${pulsar.version}</version>
         <exclusions>
           <exclusion>
             <groupId>org.apache.pulsar</groupId>
             <artifactId>pulsar-client-original</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.apache.pulsar</groupId>
             <artifactId>pulsar-client-admin-original</artifactId>
           </exclusion>
         </exclusions>
       </dependency>
       <dependency>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-client</artifactId>
         <version>${pulsar.version}</version>
       </dependency>
       <dependency>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-client-admin</artifactId>
         <version>${pulsar.version}</version>
       </dependency>
     </dependencies>
   
     <build>
       <plugins>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
             <source>8</source>
             <target>8</target>
           </configuration>
         </plugin>
       </plugins>
     </build>
   
   </project>
   ```
   
   The `standalone.conf` is the one supplied out of the box in pulsar package.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to