简体   繁体   English

找不到从方法引用的类“ org.codehaus.jackson.map.ObjectMapper”

[英]Could not find class 'org.codehaus.jackson.map.ObjectMapper', referenced from method

I am trying to make an chat application with atmosphere framework.For this adding dependency I am using maven dependency. 我正在尝试创建一个带有大气框架的聊天应用程序。为此,我正在使用maven依赖项。 The problem is whenever I try to compile project with maven dependency library included,It is giving error as "conversion to dalvik format failed with error 1" if remove the library project runs but it gives above mentioned exception. 问题是,每当我尝试编译包含maven依赖库的项目时,如果删除库项目运行,就会出现错误,如“转换为dalvik格式失败,错误为1”,但出现上述异常。

Here is my code. 这是我的代码。

  public class ListenerService extends Service
   {
    private String serverIpAddress ="someIp";

    private AtmosphereClient client;

    private final Handler uiHandler = new Handler();

    private final static ObjectMapper mapper = new ObjectMapper();//Exception comes here

    public static final String BROADCAST_ACTION = "Message";

    RequestBuilder request;

    public ListenerService()
    {

    }

    @Override
    public IBinder onBind(Intent intent)
    {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void onDestroy()
    {
        // TODO Auto-generated method stub
        super.onDestroy();
        Log.d("Service", "Destroyed");
    }

    @Override
    public void onCreate()
    {
        super.onCreate();
        PrefernceHelper prefernceHelper = new PrefernceHelper(this);
        String id = prefernceHelper.getPrefernce("OWNERID");
        Log.d("Service", "Id to be listened is " + id);
        startListening(id);

    }

    public void startListening(String channel)
    {
        Log.d("Service", "Inside Strat listening");
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        client = ClientFactory.getDefault().newClient(AtmosphereClient.class);
        Log.d("Service", "Listening on " + channel);
        request = client.newRequestBuilder().method(Request.METHOD.GET).uri(serverIpAddress + "/pubsub/" + channel)
                .trackMessageLength(true)

                .encoder(new Encoder<Message, String>()
                {

                    @Override
                    public String encode(Message data)
                    {
                        Log.d("Service", "Inside encode" + data.toString());
                        try
                        {
                            return mapper.writeValueAsString(data);
                        }
                        catch (IOException e)
                        {
                            throw new RuntimeException(e);
                        }
                    }
                }).decoder(new Decoder<String, Message>()
                {

                    @Override
                    public Message decode(Event type, String data)
                    {
                        Log.d("Service", "Inside decode" + data.toString());
                        data = data.trim();

                        // Padding if (data.length() == 0) { return null; }

                        if (type.equals(Event.MESSAGE))
                        {
                            try
                            {
                                return mapper.readValue(data, Message.class);
                            }
                            catch (IOException e)
                            {
                                e.printStackTrace();
                                return null;
                            }
                        }
                        else
                        {
                            return null;
                        }
                    }
                })

                .transport(Request.TRANSPORT.WEBSOCKET);

        final org.atmosphere.wasync.Socket socket = client.create();
        socket.on("message", new Function<String>()
        {

            @Override
            public void on(final String message)
            {
                uiHandler.post(new Runnable()
                {
                    @Override
                    public void run()
                    {

                        String id = "";
                        String receviedMessage = "";
                        if (message != "")
                        {
                            try
                            {
                                JSONObject json = new JSONObject(message);
                                id = json.getString("from_id");
                                receviedMessage = json.getString("message");
                            }
                            catch (JSONException e)
                            {
                                e.printStackTrace();
                            }

                            Log.d("Service", message);
                            Intent intent = new Intent(BROADCAST_ACTION);
                            intent.putExtra("id", id);
                            intent.putExtra("message", receviedMessage);
                            sendBroadcast(intent);
                        }
                    }
                });
            }
        });
        try
        {
            socket.on(new Function<Throwable>()
            {

                @Override
                public void on(Throwable t)
                {

                }

            }).open(request.build());
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

My Pom.xml 我的Pom.xml

<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">
    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>5</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.inscripts.chatproject</groupId>
    <artifactId>chatproject</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>chatproject</name>
    <url>http://github.com/Atmosphere/wasync</url>
    <scm>
        <connection>scm:git:git@github.com:Atmosphere/wasync.git</connection>
        <developerConnection>scm:git:git@github.com:Atmosphere/wasync.git</developerConnection>
        <url>http://github.com/Atmosphere/wasync</url>
    </scm>
    <prerequisites>
        <maven>2.2.0</maven>
    </prerequisites>
    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>wasync</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.ning</groupId>
            <artifactId>async-http-client</artifactId>
            <version>${ahc.version}</version>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>nettosphere</artifactId>
            <version>${nettosphere.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>${atmosphere.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>5.8</version>
            <scope>test</scope>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.3</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.5.2</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6) -->
                        <platform>8</platform>
                    </sdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${source.property}</source>
                    <target>${target.property}</target>
                    <maxmem>1024m</maxmem>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.8.1</version>
                <configuration>
                    <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${project.basedir}/META-INF</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}/works</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}/overlays</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}</directory>
                            <includes>
                                <include>*.log</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <aggregate>true</aggregate>
                    <source>1.6</source>
                    <encoding>UTF-8</encoding>
                    <maxmemory>1g</maxmemory>
                    <links>
                        <link>http://java.sun.com/javase/6/docs/api/</link>
                    </links>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <outputDirectory>target/site</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <aggregate>true</aggregate>
                    <debug>true</debug>
                    <links>
                        <link>http://docs.oracle.com/javaee/6/docs/api/</link>
                        <link>http://docs.oracle.com/javase/6/docs/api/</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>project-team</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
    <repositories>
        <repository>
            <id>oss.sonatype.org</id>
            <url>http://oss.sonatype.org/content/repositories/releases</url>
        </repository>
        <repository>
            <id>oss.sonatype.org-snapshot</id>
            <url>http://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>
    <distributionManagement>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Sonatype Release</name>
            <url>http://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>sonatype-nexus-snapshots</name>
            <url>${distMgmtSnapshotsUrl}</url>
        </snapshotRepository>
    </distributionManagement>
    <properties>
        <distMgmtSnapshotsUrl>http://oss.sonatype.org/content/repositories/snapshots</distMgmtSnapshotsUrl>
        <surefire.redirectTestOutputToFile>false</surefire.redirectTestOutputToFile>
        <source.property>1.6</source.property>
        <target.property>1.6</target.property>
        <atmosphere.version>2.0.0.RC3</atmosphere.version>
        <nettosphere.version>2.0.0.RC4</nettosphere.version>
        <ahc.version>1.7.19</ahc.version>
    </properties>
</project>

"conversion to dalvik format failed with error 1" “转换为dalvik格式失败,错误为1”
This error come from your class does not support dalvik (Android JVM) 此错误来自您的类,不支持dalvik(Android JVM)

If you don't care just use json standard lib 如果您不在乎,请使用json标准库

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到方法org.codehaus.jackson.map.ObjectMapper.writeValueAsString引用的类&#39;org.codehaus.jackson.io.SegmentedStringWriter&#39; - Could not find class 'org.codehaus.jackson.io.SegmentedStringWriter', referenced from method org.codehaus.jackson.map.ObjectMapper.writeValueAsString Eclipse Mars 中的“java.lang.ClassNotFoundException:org.codehaus.jackson.map.ObjectMapper” - "java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper" in Eclipse Mars WAS服务器中的org / codehaus / jackson / map / ObjectMapper.setSerializationInclusion异常 - org/codehaus/jackson/map/ObjectMapper.setSerializationInclusion exception in WAS server 异常是java.lang.NoSuchMethodError:org / codehaus / jackson / map / ObjectMapper.getTypeFactory()Lorg / codehaus / jackson / map / type / TypeFactory - exception is java.lang.NoSuchMethodError: org/codehaus/jackson/map/ObjectMapper.getTypeFactory()Lorg/codehaus/jackson/map/type/TypeFactory 无法解析org.codehaus.jackson.JsonGenerationException类型。 它是从所需的.class文件间接引用的 - The type org.codehaus.jackson.JsonGenerationException cannot be resolved. It is indirectly referenced from required .class files 获取java.lang.noclassdeffounderror org / codehaus / jackson / map / objectmapper错误。 - Getting java.lang.noclassdeffounderror org/codehaus/jackson/map/objectmapper error. 使用 REST 重载 Java 方法 - org.codehaus.jackson.map.JsonMappingException - Java method Overloading with REST - org.codehaus.jackson.map.JsonMappingException 如何使用codehaus.jackson.map.ObjectMapper映射无法识别的字段 - How to map Unrecognised field with codehaus.jackson.map.ObjectMapper 找不到类&#39;org.apache.http.entity.mime.content.Filebody&#39;,从方法中引用 - Could not find class 'org.apache.http.entity.mime.content.Filebody', referenced from method Android / Eclipse错误-“找不到从方法引用的类&#39;org.jivesoftware.smack.ConnectionConfiguration&#39;” - Android/Eclipse Error - “Could not find class 'org.jivesoftware.smack.ConnectionConfiguration', referenced from method”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM