You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/06/12 08:03:17 UTC

[GitHub] [rocketmq] heshengjun811 opened a new issue #2091: use logback in client error

heshengjun811 opened a new issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091


   
   I use logback Logappender in my client , but integrate to run  has error, this info is
   ===========================================================
   Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.rocketmq.client.log.ClientLogger
   	at org.apache.rocketmq.client.producer.DefaultMQProducer.<init>(DefaultMQProducer.java:63)
   	at org.apache.rocketmq.client.producer.DefaultMQProducer.<init>(DefaultMQProducer.java:145)
   	at com.maoge.demo._01_hello.ProducerDemo.main(ProducerDemo.java:14)
   ===========================================================
   logback.xml
   =============================================
   <?xml version="1.0" encoding="UTF-8"?>
   <configuration>
       <appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender">
           <tag>TagA</tag>
           <topic>01_hello</topic>
           <producerGroup>maoge</producerGroup>
           <nameServerAddress>192.168.48.102:9876</nameServerAddress>
           <layout>
               <pattern>%date %p %t - %m%n</pattern>
           </layout>
       </appender>
       <root level="info">
           <appender-ref ref="mqAppender1" />
       </root>
   </configuration>
   =============================================
   pom.xml
   =============================================
      <dependencies>
           <dependency>
               <groupId>org.apache.rocketmq</groupId>
               <artifactId>rocketmq-client</artifactId>
               <version>4.7.0</version>
           </dependency>
           <dependency>
               <groupId>org.apache.rocketmq</groupId>
               <artifactId>rocketmq-logappender</artifactId>
               <version>4.7.0</version>
           </dependency>
           <dependency>
               <groupId>org.projectlombok</groupId>
               <artifactId>lombok</artifactId>
               <version>1.18.12</version>
           </dependency>
           <dependency>
               <groupId>ch.qos.logback</groupId>
               <artifactId>logback-core</artifactId>
               <version>1.2.3</version>
           </dependency>
           <dependency>
               <groupId>ch.qos.logback</groupId>
               <artifactId>logback-classic</artifactId>
               <version>1.2.3</version>
           </dependency>
       </dependencies>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] imaffe commented on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
imaffe commented on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-645097880


   Could you please provide a small but detailed demo to reproduce this bug including testing environment, steps to take?  Would be nice for use to investigate further into this problem.
   
   
   Intuitively, this looks like a jar dependency conflicts to me, maybe we can start from here 😄 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] hachihub commented on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
hachihub commented on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-701711859


   there's something wrong:
   
   Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.rocketmq.client.log.ClientLogger
   	at org.apache.rocketmq.client.producer.DefaultMQProducer.<init>(DefaultMQProducer.java:63)
   	at org.apache.rocketmq.client.producer.DefaultMQProducer.<init>(DefaultMQProducer.java:145)
   	at com.maoge.demo.ProducerDemo.main(ProducerDemo.java:9)
   
   
   logback.xml
   <?xml version="1.0" encoding="UTF-8"?>
   <configuration>
       <appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender">
           <tag>TagA</tag>
           <topic>01_test</topic>
           <producerGroup>group1</producerGroup>
           <nameServerAddress>127.0.0.1:9876</nameServerAddress>
           <layout>
               <pattern>%date %p %t - %m%n</pattern>
           </layout>
       </appender>
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
       <root>
           <level value="debug"/>
           <appender-ref ref="mqAppender1"/>
       </root>
       <logger name="testLogger" level="debug" additivity="true">
           <appender-ref ref="mqAppender1"/>
       </logger>
   </configuration>
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] imaffe commented on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
imaffe commented on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-648697363


   I will close this issue for now. But if you have any further questions or the solution provided above doesn't work for you, feel free to reopen this issue~


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] imaffe commented on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
imaffe commented on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-647877363


   @heshengjun811  I think you can try add this to your logback.xml
   ```
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
   ``` according to [logback example](https://rocketmq.apache.org/docs/logappender-example/)
   
   The whole logback.xml looks like 
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <configuration>
       <appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender">
           <tag>TagA</tag>
           <topic>01_test</topic>
           <producerGroup>group1</producerGroup>
           <nameServerAddress>127.0.0.1:9876</nameServerAddress>
           <layout>
               <pattern>%date %p %t - %m%n</pattern>
           </layout>
       </appender>
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
       <root>
           <level value="debug"/>
           <appender-ref ref="mqAppender1"/>
       </root>
       <logger name="testLogger" level="debug" additivity="true">
           <appender-ref ref="mqAppender1"/>
       </logger>
   </configuration>
   ```
   
   Once I added this, it will work properly.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] heshengjun811 commented on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
heshengjun811 commented on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-646023163


   > Could you please provide a small but detailed demo to reproduce this bug including testing environment, steps to take? Would be nice for use to investigate further into this problem.
   > 
   > Intuitively, this looks like a jar dependency conflicts to me, maybe we can start from here 😄
   
   Thank Your reply,  **https://github.com/heshengjun811/rocketmq-demo.git** this is demo 
   
   since use RocketmqLogbackAppender in my logback.xml, it`s happens error when  I  start Producer 
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] imaffe edited a comment on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
imaffe edited a comment on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-647877363


   @heshengjun811 you can try add this to your logback.xml
   ```
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
   ``` 
   according to [logback example](https://rocketmq.apache.org/docs/logappender-example/)
   
   The whole logback.xml looks like 
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <configuration>
       <appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender">
           <tag>TagA</tag>
           <topic>01_test</topic>
           <producerGroup>group1</producerGroup>
           <nameServerAddress>127.0.0.1:9876</nameServerAddress>
           <layout>
               <pattern>%date %p %t - %m%n</pattern>
           </layout>
       </appender>
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
       <root>
           <level value="debug"/>
           <appender-ref ref="mqAppender1"/>
       </root>
       <logger name="testLogger" level="debug" additivity="true">
           <appender-ref ref="mqAppender1"/>
       </logger>
   </configuration>
   ```
   
   Once I added this, it will work properly. The reason for NoClassDefFoundError was because we missed some configuration entries, the static initialization process of some class (I don't know which exact class it is) failed, and throws NoClassDefFoundError.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] imaffe edited a comment on issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
imaffe edited a comment on issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091#issuecomment-647877363


   @heshengjun811  I think you can try add this to your logback.xml
   ```
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
   ``` 
   according to [logback example](https://rocketmq.apache.org/docs/logappender-example/)
   
   The whole logback.xml looks like 
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <configuration>
       <appender name="mqAppender1" class="org.apache.rocketmq.logappender.logback.RocketmqLogbackAppender">
           <tag>TagA</tag>
           <topic>01_test</topic>
           <producerGroup>group1</producerGroup>
           <nameServerAddress>127.0.0.1:9876</nameServerAddress>
           <layout>
               <pattern>%date %p %t - %m%n</pattern>
           </layout>
       </appender>
       <appender name="mqAsyncAppender1" class="ch.qos.logback.classic.AsyncAppender">
           <queueSize>1024</queueSize>
           <discardingThreshold>80</discardingThreshold>
           <maxFlushTime>2000</maxFlushTime>
           <neverBlock>true</neverBlock>
           <appender-ref ref="mqAppender1"/>
       </appender>
       <root>
           <level value="debug"/>
           <appender-ref ref="mqAppender1"/>
       </root>
       <logger name="testLogger" level="debug" additivity="true">
           <appender-ref ref="mqAppender1"/>
       </logger>
   </configuration>
   ```
   
   Once I added this, it will work properly.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [rocketmq] RongtongJin closed issue #2091: use logback in client error

Posted by GitBox <gi...@apache.org>.
RongtongJin closed issue #2091:
URL: https://github.com/apache/rocketmq/issues/2091


   


----------------------------------------------------------------
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:
users@infra.apache.org