Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在应用中使用cat-client报错 #699

Closed
catshitaf opened this issue Dec 18, 2014 · 21 comments
Closed

在应用中使用cat-client报错 #699

catshitaf opened this issue Dec 18, 2014 · 21 comments

Comments

@catshitaf
Copy link

@catshitaf catshitaf commented Dec 18, 2014

你好,我用maven导入了cat-client:1.1.9 编译成功;但是在执行后,访问含有以下代码的服务接口,就报错;

环境:

osX + tomcat + java7 or java6 + spring or servlet

代码:

        Transaction t = Cat.getProducer().newTransaction("URL", "af-trans");  // 这行报错

        try {
            Cat.logEvent("URL.Server", "af-event");
            Cat.logMetricForCount("convert-cnt");
            String data = this.getData();
            resp.setContentType("text/html;charset=GBK");
            resp.getOutputStream().write(data.getBytes("GBK"));
            t.setStatus(Transaction.SUCCESS);
        } catch (Exception e) {
            t.setStatus(e);
        } finally {
            t.complete();
        }

报错:

exception

java.lang.RuntimeException: Unable to get instance of Logger, please make sure the environment was setup correctly!
    org.unidal.initialization.DefaultModuleContext.<init>(DefaultModuleContext.java:28)
    com.dianping.cat.Cat.initialize(Cat.java:91)
    com.dianping.cat.Cat.initialize(Cat.java:87)
    com.dianping.cat.Cat.checkAndInitialize(Cat.java:45)
    com.dianping.cat.Cat.getManager(Cat.java:72)
    com.dianping.cat.servlet.CatFilter$CatHandler$1.handle(CatFilter.java:104)
    com.dianping.cat.servlet.CatFilter$Context.handle(CatFilter.java:406)
    com.dianping.cat.servlet.CatFilter.doFilter(CatFilter.java:53)
root cause

org.codehaus.plexus.component.repository.exception.ComponentLookupException: Component descriptor cannot be found in the component repository
      role: org.codehaus.plexus.logging.LoggerManager
  roleHint: 
classRealm: none specified
    org.codehaus.plexus.DefaultComponentRegistry.getComponentManager(DefaultComponentRegistry.java:435)
    org.codehaus.plexus.DefaultComponentRegistry.getComponent(DefaultComponentRegistry.java:353)
    org.codehaus.plexus.DefaultComponentRegistry.lookup(DefaultComponentRegistry.java:178)
    org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:383)
    org.unidal.initialization.DefaultModuleContext.<init>(DefaultModuleContext.java:24)
    com.dianping.cat.Cat.initialize(Cat.java:91)
    com.dianping.cat.Cat.initialize(Cat.java:87)
    com.dianping.cat.Cat.checkAndInitialize(Cat.java:45)
    com.dianping.cat.Cat.getManager(Cat.java:72)
    com.dianping.cat.servlet.CatFilter$CatHandler$1.handle(CatFilter.java:104)
    com.dianping.cat.servlet.CatFilter$Context.handle(CatFilter.java:406)
    com.dianping.cat.servlet.CatFilter.doFilter(CatFilter.java:53)

我在spring mvc项目和最简单的servlet项目中都试过,报的时同样的错误;
请问使用cat-client还有别的隐藏条件吗?这个问题折磨了我好久!希望大侠尽快回复~呜呜呜

@youyong205

This comment has been minimized.

Copy link
Collaborator

@youyong205 youyong205 commented Dec 22, 2014

try config
/data/appdatas/cat/client.xml 这个文件在你把cat-home搭建起来,会自动生成。

@qmwu2000

This comment has been minimized.

Copy link
Contributor

@qmwu2000 qmwu2000 commented Dec 23, 2014

报错信息不太对。

Sent from my iPhone

On Dec 22, 2014, at 22:14, youyong205 notifications@github.com wrote:

try config
/data/appdatas/cat/client.xml 这个文件在你把cat-home搭建起来,会自动生成。


Reply to this email directly or view it on GitHub.

@catshitaf

This comment has been minimized.

Copy link
Author

@catshitaf catshitaf commented Dec 23, 2014

/data/appdatas/cat/client.xml 文件内容如下,还需要添加什么配置吗:

<?xml version="1.0" encoding="utf-8"?>

<config mode="client" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="config.xsd">
        <servers>
                <!-- Local mode for development -->
                <server ip="127.0.0.1" port="2280" http-port="2281" />
                <!-- If under production environment, put actual server address as list. -->
                <!--
                        <server ip="192.168.7.71" port="2280" />
                        <server ip="192.168.7.72" port="2280" />
                -->
        </servers>
</config>

youyong205 commented 13 hours ago
try config
/data/appdatas/cat/client.xml 这个文件在你把cat-home搭建起来,会自动生成。

@youyong205

This comment has been minimized.

Copy link
Collaborator

@youyong205 youyong205 commented Dec 23, 2014

你需要部署一个服务端。

这个IP要改为自己的服务端的IP地址。

在 2014-12-23 10:28:25,"catshitaf" notifications@github.com 写道:

/data/appdatas/cat/client.xml 文件内容如下,还需要添加什么配置吗:


Reply to this email directly or view it on GitHub.

@catshitaf

This comment has been minimized.

Copy link
Author

@catshitaf catshitaf commented Dec 23, 2014

我的服务端部署在同一台机子上,server.xml内容如下:

<?xml version="1.0" encoding="utf-8"?>

<!-- Configuration for development environment-->
<config local-mode="true" job-machine="true" alert-machine="true">
        <consumer>
                <long-config default-url-threshold="1000" default-sql-threshold="100">
                        <domain name="Cat" url-threshold="500" sql-threshold="40"/>
                </long-config>
        </consumer>

        <console default-domain="Cat" show-cat-domain="true">
                <remote-servers>127.0.0.1:2281</remote-servers>
        </console>

        <ldap ldapUrl="ldap://192.168.50.11:389/DC=dianpingoa,DC=com"/>

</config>

youyong205 commented 2 hours ago
你需要部署一个服务端。
<server ip="127.0.0.1" port="2280" http-port="2281" />
这个IP要改为自己的服务端的IP地址。

@qmwu2000

This comment has been minimized.

Copy link
Contributor

@qmwu2000 qmwu2000 commented Dec 23, 2014

local mode is true?

Sent from my iPhone

On Dec 23, 2014, at 14:33, catshitaf notifications@github.com wrote:

我的服务端部署在同一台机子上,server.xml内容如下:

    <console default-domain="Cat" show-cat-domain="true">
            <remote-servers>127.0.0.1:2281</remote-servers>
    </console>

    <ldap ldapUrl="ldap://192.168.50.11:389/DC=dianpingoa,DC=com"/>
youyong205 commented 2 hours ago 你需要部署一个服务端。 这个IP要改为自己的服务端的IP地址。


Reply to this email directly or view it on GitHub.

@catshitaf

This comment has been minimized.

Copy link
Author

@catshitaf catshitaf commented Dec 23, 2014

我把local mode改成false 重新部署服务端,还是报同样的错误;
你们遇到过和我一样的问题吗?

qmwu2000 commented 10 minutes ago
local mode is true?

@youyong205

This comment has been minimized.

Copy link
Collaborator

@youyong205 youyong205 commented Dec 29, 2014

你可以先按照cat的步骤搭建,很多人都OK的。
主要是一些目录权限的问题,在插件部署时候会有提示的。
如果还是启动不起来,可以自己debug下,看看具体哪里出了问题。

@youyong205 youyong205 closed this Dec 29, 2014
@adonis2014

This comment has been minimized.

Copy link

@adonis2014 adonis2014 commented Mar 19, 2015

@catshitaf 这个问题解决了没?我现在也遇到这个问题。服务是启动成功了,http://localhost:2281/cat,

@youyong205

This comment has been minimized.

Copy link
Collaborator

@youyong205 youyong205 commented Jul 8, 2015

check /data/appdatas/cat/ 这个路径是否有读写权限

@sunnyhui2010

This comment has been minimized.

Copy link

@sunnyhui2010 sunnyhui2010 commented Mar 22, 2016

@adonis2014 @catshitaf 这个问题解决了吗?我也遇到这个问题了,我home已经跑起来了的。

@songwie

This comment has been minimized.

Copy link

@songwie songwie commented May 29, 2016

大家好我也遇到这个错误,发现用maven 的tomcat插件启动就会有这个错误,正常的tomcat启动不会有问题,怀疑maven插件jar冲突,其他人又遇到的么

@yue-ch

This comment has been minimized.

Copy link

@yue-ch yue-ch commented Oct 11, 2016

这个问题无解吗?

@yue-ch

This comment has been minimized.

Copy link

@yue-ch yue-ch commented Oct 12, 2016

换成jetty-maven-plugin就没有问题

@qmwu2000

This comment has been minimized.

Copy link
Contributor

@qmwu2000 qmwu2000 commented Dec 15, 2016

有人报,这个问题是tomcat7-maven-plugin所依赖的plexus-container-default与cat依赖的有冲突导致的。我会找时间看一下

@zhangxiang17

This comment has been minimized.

Copy link

@zhangxiang17 zhangxiang17 commented Jan 24, 2017

我也遇到同样的问题,请问 有解决方式吗?

@armysheng

This comment has been minimized.

Copy link
Contributor

@armysheng armysheng commented Feb 16, 2017

很有可能是打包的时候没有带上META-INF/component.xml文件引起的,检查一下确保该文件存在

@zeuskingzb

This comment has been minimized.

Copy link
Contributor

@zeuskingzb zeuskingzb commented Apr 16, 2017

         <dependency>
		<groupId>com.dianping.cat</groupId>
        <artifactId>cat-client</artifactId>   
		<version>1.3.6</version>
	</dependency>
	<dependency>
		<groupId>org.codehaus.plexus</groupId>
		<artifactId>plexus-container-default</artifactId>
		<version>1.6</version>
	</dependency>
            <dependency>
	     <groupId>org.unidal.framework</groupId>
	     <artifactId>foundation-service</artifactId>
	     <version>2.2.0</version>
        </dependency>

目前这是最靠谱的解决办法

@yuweibo

This comment has been minimized.

Copy link

@yuweibo yuweibo commented Apr 20, 2017

你好这个问题解决了吗

@sungine

This comment has been minimized.

Copy link

@sungine sungine commented Jul 11, 2017

我也遇到了这种问题,出现概率30%吧.

@bhxiaoxinba

This comment has been minimized.

Copy link

@bhxiaoxinba bhxiaoxinba commented Feb 6, 2018

在应用中调用cat client api收集数据时出错

tomat+spring
Transaction t = Cat.getProducer().newTransaction("URL", "af-trans"); // 这行报错

错误:
java.lang.RuntimeException: Unable to create Plexus container! Element(component-discoverer-manager) is not expected under plexus!

但是在java项目中不会,各位大神又遇到同样的问题吗,求帮忙?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.