java.lang.ClassCastException

图片说明

public class GroupFragment extends Fragment {

private static RecyclerView recyclerView;

public String json = null;

private ArrayList<ItemObject> itemObjectArrayList;

private LinearLayoutManager linearLayoutManager;
private GroupAdapter groupAdapter;

private View listTouchInterceptor;
private View detailsLayout;
private UnfoldableView unfoldableView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_group, null);

    recyclerView = (RecyclerView) view.findViewById(R.id.group_list_view);
    linearLayoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(linearLayoutManager);

    listTouchInterceptor = (View) view.findViewById(R.id.touch_interceptor_view);
    listTouchInterceptor.setClickable(false);

    detailsLayout = (View) view.findViewById(R.id.details_layout);
    detailsLayout.setVisibility(View.INVISIBLE);

    unfoldableView = (UnfoldableView) view.findViewById(R.id.unfoldable_view);

    Bitmap glance = BitmapFactory.decodeResource(getResources(), R.drawable.unfold_glance);
    unfoldableView.setFoldShading(new GlanceFoldShading(glance));

    unfoldableView.setOnFoldingListener(new UnfoldableView.SimpleFoldingListener() {

        @Override
        public void onUnfolding(UnfoldableView unfoldableView) {
            listTouchInterceptor.setClickable(true);
            detailsLayout.setVisibility(View.VISIBLE);
            page_up.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onUnfolded(UnfoldableView unfoldableView) {
            listTouchInterceptor.setClickable(false);
        }

        @Override
        public void onFoldingBack(UnfoldableView unfoldableView) {
            listTouchInterceptor.setClickable(true);
        }

        @Override
        public void onFoldedBack(UnfoldableView unfoldableView) {
            listTouchInterceptor.setClickable(false);
            detailsLayout.setVisibility(View.INVISIBLE);
            page_up.setVisibility(View.VISIBLE);
        }

    });

    try {
        json = HttpUtil.getRequest("http://music.svner.com/cuiyunlong/feb_three_list.html");
    } catch (Exception e) {
        e.printStackTrace();
    }

    JSONObject jObject = null;
    int result = 0;
    try {
        jObject = new JSONObject(json);
        result = jObject.getInt("result");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    if (result == 1) {
        JSONObject jsonObject;
        itemObjectArrayList = new ArrayList<ItemObject>();
        try {
            jsonObject = new JSONObject(json);
            JSONArray jsonArray = jsonObject.getJSONArray("data");
            for (int i = 0; i < jsonArray.length(); i++) {
                jsonObject = jsonArray.getJSONObject(i);
                ItemObject itemObject = new ItemObject();
                itemObject.group_image = jsonObject.getString("group_image");
                itemObject.group_top = jsonObject.getString("group_top");
                itemObject.group_bottom = jsonObject.getString("group_bottom");
                itemObject.group_right = jsonObject.getString("group_right");
                itemObjectArrayList.add(itemObject);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        groupAdapter = new GroupAdapter(getActivity(), itemObjectArrayList);
        recyclerView.setAdapter(groupAdapter);
    }

    groupAdapter.setOnItemClickListener(new GroupAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
        unfoldableView.unfold(view, detailsLayout);
        }
    });

    public class ItemObject{
    public String group_image;
    public String group_top;
    public String group_bottom;
    public String group_right;
}

}

public class GroupAdapter extends RecyclerView.Adapter {

private final Context context;
private final ArrayList<GroupFragment.ItemObject> itemObjectArrayList;

public GroupAdapter(Context context, ArrayList<GroupFragment.ItemObject> itemObjectArrayList) {
    this.context = context;
    this.itemObjectArrayList = itemObjectArrayList;
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new GroupViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.group_list_item, null));
}

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
    final GroupFragment.ItemObject itemObject = itemObjectArrayList.get(position%(itemObjectArrayList.size()));
    final GroupViewHolder groupViewHolder = (GroupViewHolder) holder;

    if (mOnItemClickListener != null){
        groupViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnItemClickListener.onItemClick(groupViewHolder.itemView, position);
            }
        });
    }

    try {
        URL url = new URL(itemObject.group_image);
        Utils.onLoadImage(url, new Utils.OnLoadImageListener() {
            @Override
            public void OnLoadImage(Bitmap bitmap, String bitmapPath) {
                if (bitmap != null) {
                    BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
                    groupViewHolder.group_image.setImageDrawable(bitmapDrawable);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

    groupViewHolder.group_top.setText(itemObject.group_top);
    groupViewHolder.group_bottom.setText(itemObject.group_bottom);
    groupViewHolder.group_right.setText(itemObject.group_right);
}

@Override
public int getItemCount() {
    return itemObjectArrayList.size();
}

public interface OnItemClickListener{
    void onItemClick(View view, int position);
}

private OnItemClickListener mOnItemClickListener;

public void setOnItemClickListener(OnItemClickListener mOnItemClickListener){
    this.mOnItemClickListener = mOnItemClickListener;
}

}

public class GroupViewHolder extends RecyclerView.ViewHolder {

public ImageView group_image;
public TextView group_top;
public TextView group_bottom;
public TextView group_right;

public GroupViewHolder(View view) {
    super(view);
    group_image = (ImageView) view.findViewById(R.id.group_image);
    group_top = (TextView) view.findViewById(R.id.group_top);
    group_bottom = (TextView) view.findViewById(R.id.group_bottom);
    group_right = (TextView) view.findViewById(R.id.group_right);

}

}

图片说明

图片说明

0

查看全部2条回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java.lang.ClassCastException 两个一样的类不能强转
spring boot 项目引入了 spring的devtools 经常会产生这个问题  ,当把这个引入取消就不会出现了  &amp;lt;dependency&amp;gt;            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;            &amp;lt;artifactId&amp;gt;spring-boot-devtools&amp;lt...
java.lang.ClassCastException 在 android 当尝试获取应用程序的图标
Caused by: java.lang.ClassCastException: android.graphics.drawable.NinePatchDrawable cannot be cast to android.graphics.drawable.BitmapDrawable 图标是没有实例的 BitmapDrawable,一个可以检查像这样: Bitmap
关于使用动态代理创建代理对象是报错 java.lang.ClassCastException: $Proxy0 cannot be cast to 的解决办法
出现此问题的场景一般有以下两种: (1)在Java中使用代理模式创建对象。如何创建代理对象在这就不说了。首先,要为代理对象实现接口,然后生成的代理对象用接口的类型进行接收。此处是使用JDK的代理方式,另一种参考下面的第二种应用场景。 (2)在spring框架中使用代理的方式创建对象。Spring的文档中这么写的:Spring AOP部分使用JDK动态代理或者CGLIB来为目标对象创建代
定时任务 quartz中出现相同类型的对象无法转换问题(java.lang.ClassCastException)
环境:springboot 排查问题过程: 1:确认不是serialVersionUID版本问题 2:确认不是序列化工具(Jackson)问题 3:写了一个测试方法:将对象put到JobDataMap中,再取出来强转,并无问题 解决方法:去掉spring-boot-devtools即可。。。。。...
关于java中父类和子类转型的问题java.lang.ClassCastException
我们都知道,java是面向对象的语言,继承是其一个很重要的特性,看下面这段代码:package my.java.test; class FatherClass { int fatherField; void fatherMethod() { System.out.println(&quot;这是父类的方法&quot;); } } package my.java.test; ...
百度地图开发中的java.lang.ClassCastException解决方法及定位源码
在近来开发百度地图定位
java开源框架集成常见错误之使用Criteria添加查询条件出现java.lang.ClassCastException异常
问题描述:使用Criteria添加查询条件criteria.add(Restrictions.eq("chcDueId", pageResult.getCondition().getMcuser()));出现如下异常javax.servlet.ServletException: java.lang.ClassCastException: java.lang.String org.apache.st
hibernate命名查询时总是报类型转换异常:java.lang.ClassCastException
异常描述如下; 1、在user.hbm.xml中配置如下 2、测试代码如下: public static void getByNamedQuery(String queryName){ //queryName = "com.summer.entity.User.mySQLquery"; Session session = HibernateUt
Maven部署过程中的ClassCastException问题
引言: Maven功能强大,但是又有些复杂,难以捉摸和使用。在本人开发中碰到了一个ClassCastException的问题,通过这个问题的解决,加深了对于maven依赖管理中scope的理解。
Spring事务配置上去后出现如下报错:java.lang.ClassCastException: $Proxy1解决
问题描述:查询功能一切正常,但是在增、删、改操作中发现,数据库表中数据没有改变,查看控制台日志也没有任何异常发现,纳闷了好久,仔查检查日志,发现在新增操作中表id有在自增,由此确定是问题出在事务没有提交。将事务配置上去后出现如下报错:java.lang.ClassCastException: $Proxy1,百度上搜到一文,在业务类如果实现了接口,得增加如下代码    true 果然如此,再次
weblogic部署,常见错误解决二——ClassCastException
3. weblogic使用了自己带的xml解析器造成的ClassCastException 早上接到项目组发来的java程序接口报错信息。分析其中出错信息如下: 1. Warning: Caught exception attempting to use SAX to load a SAX XMLReader    2. Warning: Exception was: java.lang.C
java.lang.ClassCastException 两个一样的类不能强转
spring boot 项目引入了 spring的devtools 经常会产生这个问题  ,当把这个引入取消就不会出现了   &amp;lt;dependency&amp;gt;             &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;             &amp;lt;artifactId&amp;gt;spring-boot-devtool...
Java RMI调用发生ClassCastException的处理方法
在学习RMI的时候,通过网上资料或者《Java网络编程和分布式计算》经典教程对RMI有了一定的了解。但是前几天在写一个网络应用软件的时候却发生了点问题。服务器端,客户端都按照RMI规范完成之后,客户端在Naming.lookup()之后,获得的Object转换成接口的时候总是抛出java.lang.ClassCastException $Proxy ... 异常。调试了很长时间,也google了很
为什么web应用在tomcat启动时报java.lang.ClassCastException异常?
QQ图片~1.JPG (102.65 KB, 下载次数: 0) 下载附件 2015-5-27 11:09 上传           其实这是maven的tomcat插件的一个Bug,使用独立版本的tomcat或者使用maven的jetty插件可以避免这个问题。
在父类转换到子类时发生java.lang.ClassCastException
在父类转换到子类时会发生ClassCastException异常,稍微了解Java的人都知道,但是我为什么要写出来,只是抛出一个问题用来提出解决办法,当你面对一个工程时成千上百的类时,是不太容易发现类之间的关系的,所以即使知道该原则,有时候还是避免不了
java.lang.ClassCastException:
在编写jsp时用到了javabean得一个类老是有如下异常,跪求高手指教!rnjsp文件:rn<%-- rn Document : loginrn Created on : 2011-11-21, 23:51:07rn Author : Administratorrn--%>rnrn<%@page contentType="text/html" pageEncoding="gbk"%>rnrnrn rn rn JSP Pagern <%rn request.setCharacterEncoding("gbk");rn String s1 = request.getParameter("user");rn String p1 = request.getParameter("passWord");rn if (s1.length() != 11 || p1.length() != 6) //验证用户名和密码格式rn%>rn rn <% else rn %>rn rn rn <%--以用户创建user类--%>rn <%--把得到的用户名和密码传入user类--%>rn <%rn if (use.userIsExist()) //判断用户名在数据库中用户表中是否存在rn if (use.passWordIsExist()) //判断密码是否正确rn use.Close();rn %>rn <%--创建student类--%>rn rn <%rn if (stu.IsExist(use.getUser())) //判断用户是否是学生rn stu.Close();rn use.Close();rn teacher.CloseConnecting();rn %>rn rn <% else if (teacher.IsExist(use.getUser())) rn stu.Close();rn use.Close();rn %>rn rn <% rn else rn %>rn rn <% rn else rn %>rn rn <% rn rn %>rn rnrnrnrnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: java.lang.ClassCastException: java.lang.String cannot be cast to javabean.Teacherrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:534)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)rn 。。。。。。rn org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)rnrnrnroot cause rnrnjava.lang.ClassCastException: java.lang.String cannot be cast to javabean.Teacherrn org.apache.jsp.login_jsp._jspService(login_jsp.java:113)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn 。。。。。。。rn org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/7.0.14 logs.rnjavabean代码如下rnpackage javabean;rnrnimport java.sql.*;rnrnpublic class Teacher extends User rnrn private String[] snumber;rn private String[] sname;rn private String[] ssex;rn private String[] sGrade;rn private String[] department;rn private String[] major;rn private String url = "jdbc:sqlserver://localhost:1433;databaseName=学生成绩管理系统;user=sa;password=sqlserver;";rn private Connection dbcon;rn private Statement stmt;rn private ResultSet rs;rn private String databaseServerDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";rnrn public Teacher() rn stmt = null; rn rs = null;rn rn this.dbcon = super.dbcon;// 连接数据库rn rnrn public Teacher(String url, String databaseServerDriver) rn super();rn this.url = url;rn this.databaseServerDriver = databaseServerDriver;rn try rn Class.forName(databaseServerDriver);rn dbcon = DriverManager.getConnection(url);rn catch (SQLException ex) rn // 打印出异常信息rn System.out.println(ex.toString());rn catch (ClassNotFoundException ex) rn // 打印出异常信息rn System.out.println(ex.toString());rn rn rnrn rn rnrn rn public boolean IsExist(String number) rnrn String sql = "select * from 教师表 where 职工号='" + number+"'";rn try rn rs = null;rn stmt = dbcon.createStatement();rn rs = stmt.executeQuery(sql);rnrn if (rs.next()) rn return true;rn else rn return false;rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn return false;rn rnrn rnrn rnrnrnrnpackage javabean;rnrnimport com.microsoft.sqlserver.jdbc.SQLServerException;rnimport java.sql.*;rn rn/**rn * 实现对用户表的操作rn * **/rnpublic class User rnrn private String url = "jdbc:sqlserver://localhost:1433;databaseName=学生成绩管理系统;user=sa;password=sqlserver;";rn protected Connection dbcon;rn private Statement stmt;rn private ResultSet rs;rn private String databaseServerDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";rn private String user;rn private String passWord;rnrn rn public User() rn // 初始化参数rn stmt = null;rn rs = null;rn // 连接数据库rn try rn Class.forName(databaseServerDriver);rn dbcon = DriverManager.getConnection(url);rn catch (SQLException ex) rn // 打印出异常信息rn System.out.println(ex.toString());rn catch (ClassNotFoundException ex) rn // 打印出异常信息rn System.out.println(ex.toString());rn rnrn rnrn // 构造一个连接,用给定的url和服务器驱动rn public User(String url, String databaseServerDriver) rn super();rn this.url = url;rn this.databaseServerDriver = databaseServerDriver;rn try rn Class.forName(databaseServerDriver);rn dbcon = DriverManager.getConnection(url);rn catch (SQLException ex) rn // 打印出异常信息rn System.out.println(ex.toString());rn catch (ClassNotFoundException ex) rn // 打印出异常信息rn System.out.println(ex.toString());rn rn rnrn /**rn * @对数据库执行sql执行语句,主要是插入和更新操作,返回一个布尔值变量rn */rn rn public boolean userIsExist(String user) rnrn String sql = "select * from 用户表 where 用户号='" + user+"'" ;rn try rn rs = null;rn stmt = dbcon.createStatement();rn rs = stmt.executeQuery(sql);rn rs.next();rn String s = rs.getString(1);rn if (s.equals(user)) rn return true;rn else rn return false;rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn return false;rn rnrn rnrn public boolean userIsExist() rnrn String sql = "select * from 用户表 where 用户号='" + user + "'";rn try rn rs = null;rn stmt = dbcon.createStatement();rn rs = stmt.executeQuery(sql);rn rn rn if ( rs.next()) rn return true;rn else rn return false;rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn return false;rn rnrn rnrn public boolean passWordIsExist() rn try rn rs=null;rn stmt = dbcon.createStatement();rn rs = stmt.executeQuery("select * from 用户表 where 密码='"+passWord+"' and 用户号='"+user+"'");rn rs.next();rn int row = rs.getRow();rn if (row != 0) rn return true;rn else rn return false;rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn return false;rn rn rn rnrnrnrnrn
cxf+webservice基本配置及java.lang.ClassCastException: 服务端实体类 cannot be cast to 客户端实体类错误解决
** cxf+webservice基本配置及java.lang.ClassCastException: 服务端实体类 cannot be cast to 客户端实体类错误解决** 例如:java.lang.ClassCastException: com.xima.webservice.service.User cannot be cast to com.xima.breast.vo.User 其中...
使用Spring容器取出Bean时的奇怪的ClassCastException
今天在练习使用Spring的时候遇到了一个奇怪的BUG,在容器中取出的Bean只能转换为接口而不能转换为其实现类,现记录如下:j接口Thinker代码如下:package com.zdz.util;public interface Thinker { void thinkOfSomething(String thought); }其实现类Volunteer类如下:package com.zd
springboot之继承JpaRepository后自定义数据库操作后出现java.lang.ClassCastException的错误
java.lang.ClassCastException: * cannot be cast to *;这是数据类型强制转化失败的问题。在继承的Jpa的接口中,使用如下的查询方式:在Jpa的自带的方法中,删除操作的方法只有这几种:但是如果我要根据FileName来进行删除操作,一般是如上面的操作,添加方法deleteByFileName(String fileName);使用该方法,你会发现会报C...
Hive批量插入分区表时报java.lang.ClassCastException解决办法
将从一个表查询结果插入到一个分区表时,有时会在Load data步骤出错,这是在执行语句前没切换到目标表所在的库导致。 所以在执行插入语句前,先用use databasename切换到目标表所在的库下就正常了。 ——————————以下是出错语句示例———————————— $ hiveLogging initialized using configuration in jar:file...
使用网上流传的一个数据库连接池在Proxy.newProxyInstance处引起 java.lang.ClassCastException 问题的解决方法
getFreeConnection方法的代码如下:    public Connection getFreeConnection() {        //返回数据库连接conn的接管类,以便截住close方法        Connection conn2 = null;        if (conn instanceof Connection) {            conn2 = (C
关于springboot打war包部署在weblogic上,运行时报java.lang.ClassCastException异常的解决办法
一、 java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to org.glassfish.tyrus.server.TyrusServerContainer     at weblogic.websocket.tyrus.TyrusServletFil...
ssh框架web项目中Transaction发生转换异常
java.lang.ClassCastException: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction cannot be cast to javax.transaction.Transaction at com.jyjt.web.dao.StudentsDaoImpl.save(StudentsDaoImpl.j
HashMap并发异常小记
Caused by: java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode at java.util.HashMap$TreeNode.moveRootToFront(HashMap.java:1819) at java.util.HashMap$TreeNode.treeify(HashMap.java:1936) at java.util.HashMap.t
使用Idea提交Spark程序
参考这个文章(使用Intellij IDEA开发并提交Spark应用到远程Spark集群)试了一下,把遇到问题记录一下。1,错误:Permission denied: user=root, access=WRITE, inode=”/user”:hdfs:supergroup:dr这个问题的原因是因为Idea在执行程序时,使用了系统用户作为向Hadoop进行写的用户了。比如,你的电脑系统用户是:ad
在glassfish部署应用成功后,访问时出类转换异常的解决
在Glassfish服务器部署项目成功后,访问时出现在如下异常: SEVERE: PWC3989: An exception or error occurred in the container during the request processing  java.lang.ClassCastException: com.sun.grizzly.config.ContextRootInfo
java.lang.ClassCastException 在用泛型创建数组抛出异常
在平常自己写代码中会用到用泛型创建数组,一般都是直接使用如下方式进行创建,如果说创建的泛型类型不进行比较还好,一旦涉及到需要比较,比如你需要实现一个map,k一定会进行比较,这个时候泛型就要继承Ccompara&amp;lt;E&amp;gt; 在项目启动过程中你会发现直接就抛出异常了 public class HeapMap&amp;lt;T extends Comparable&amp;lt;T&amp;gt;&amp;gt; { ...
关于得到泛型的class 异常问题
开始项目环境的搭建,在开始搭建之初,我考虑(s2sh) 底层和数据库交互是直接用hibernateTemplate 这个工具类呢 还是在重新开始封装一次 这样代码的扩展性就会很强,项目耦合明显降低,所有有必要写一个通用的baseDao,baseDao代码中 private Class poClass; @SuppressWarnings("unchecked") public BasicDA
调用第三方提供的jar包,本地Tomcat部署没有问题,发布到weblogic上会抛异常:weblogic.net.http.SOAPHttpsURLConnection
调用第三方提供的jar包,本地Tomcat部署没有问题,发布到weblogic上会抛异常:weblogic.net.http.SOAPHttpsURLConnection 根本原因是,jar包存在以下方法:HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();   而weblogic下url.openConnect
关于我使用spring mvc框架做文件上传时遇到的问题
昨天尝试着用spring mvc框架做文件上传,犯了挺多不该犯的毛病问题1:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: org.apache.catalina.connector.Re
ClassCastException异常的出现原因和解决方法
ClassCastException是JVM在检测到两个类型间转换不兼容时引发的运行时异常。此类错误通常会终止用户请求。在执行任何子系统的应用程序代码时都有可能发生ClassCastException异常。通过转换,可以指示Java编译器将给定类型的变量作为另一种变量来处理。对基础类型和用户定义类型都可以转换。Java语言规范定义了允许的转换,其中大多数可在编译时进行验证。不过,某些转换还需要运行...
使用idea sbt运行spark程序
1.新建scala-sbt 项目 2.待sbt及相关依赖下载完成后,配置spark依赖 spark 2.0.0后,目录下没有lib文件夹,也找不到assembly jar包,实际上该jar已经分拆成了spark安装目录下的jars文件夹下的各jar包。导入依赖如下 打开idea - file - project structure - libraries,点击“+” - java,选择jar
Fastjson 解析多级泛型时而失败的解决方案
fastjson 解析多级泛型时而失败:class PeiqiResponse<T> { Boolean success; Integer errCode; String errDes; T result; }声明:PeiqiResponse<List<Dept>>调试分析经过多次调试,问题出现在这里 DefaultFieldDeserializer#pa
hive与hbase的兼容性问题
Hive命令行查询表时的错误信息:(hbase-0.98.X)(hive-0.12.0) Failed with exception java.io.IOException:java.lang.ClassCastException: org.apache.hadoop.hbase.client.Result cannot be cast to org.apache.hadoop.io.Writa
关于一个奇怪的ClassCastException
关于一个奇怪的ClassCastException:android.widget.RelativeLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams 今天在写自定义相机的时候发现一个莫名其妙的异常情况:android.widget.RelativeLayout$Layo...
jedis中陷阱
在使用jedis并发时,发现总出现一个bug,使用了连接池,总是报 java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Long at redis.clients.jedis.Connection.getIntegerReply(Connection.java:161) at redis.
java.lang.ClassCastException: org.apache.hadoop.hbase.io.ImmutableBytesWritable
我用hadoop2.20 + hbase.98在linux搭建了个环境,跑hadoop自带的mapreduce example没有问题,我写了个以hbase以输入和输出的mapreduce任务,运行报这样的错,源码如下,熟悉的哥们帮忙解答一下:rnrn我在windows 下用eclipse + maven编译成jar包放到Linux服务器上运行的rnrn报的异常如下:rnjava.lang.Exception: java.lang.ClassCastException: org.apache.hadoop.hbase.io.ImmutableBytesWritable cannot be cast to org.apache.hadoop.hbase.client.Mutationrn at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:403)rnCaused by: java.lang.ClassCastException: org.apache.hadoop.hbase.io.ImmutableBytesWritable cannot be cast to org.apache.hadoop.hbase.client.Mutationrn at org.apache.hadoop.hbase.mapreduce.TableOutputFormat$TableRecordWriter.write(TableOutputFormat.java:87)rn at org.apache.hadoop.mapred.MapTask$NewDirectOutputCollector.write(MapTask.java:634)rn at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)rn at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:112)rn at pchour.PCHourMapper.map(PCHourMapper.java:20)rn at pchour.PCHourMapper.map(PCHourMapper.java:11)rn at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)rn at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:763)rn at org.apache.hadoop.mapred.MapTask.run(MapTask.java:339)rn at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:235)rn at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)rn at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)rn at java.util.concurrent.FutureTask.run(FutureTask.java:166)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)rn at java.lang.Thread.run(Thread.java:724)rnrnPCHourMapper.javarnrn[code=java]package pchour;rnrnimport java.io.IOException;rnrnimport org.apache.hadoop.hbase.KeyValue;rnimport org.apache.hadoop.hbase.client.Result;rnimport org.apache.hadoop.hbase.io.ImmutableBytesWritable;rnimport org.apache.hadoop.hbase.mapreduce.TableMapper;rnimport org.apache.hadoop.hbase.util.Bytes;rnrnpublic class PCHourMapper extends TableMapper rn public void map(ImmutableBytesWritable row, Result values, Context context) throws IOException, InterruptedException rn ImmutableBytesWritable value = null;rn ImmutableBytesWritable key = null;rn rn for (KeyValue kv : values.list()) rn if ("m".equals(Bytes.toString(kv.getFamily())) && "city_id".equals(Bytes.toString(kv.getQualifier()))) rn key = row;rn value = new ImmutableBytesWritable(kv.getValue());rn context.write(key, value);rn rn rn rn[/code]rnrnPCHourReducer.javarnrn[code=java]package pchour;rnrnimport java.io.IOException;rnrnimport org.apache.hadoop.hbase.client.Put;rnimport org.apache.hadoop.hbase.io.ImmutableBytesWritable;rnimport org.apache.hadoop.hbase.mapreduce.TableReducer;rnimport org.apache.hadoop.hbase.util.Bytes;rnrnpublic class PCHourReducer extends TableReducer, ImmutableBytesWritable> rn rn public void reduce(ImmutableBytesWritable key, Iterable values, Context context) throws IOException, InterruptedException rn int count = 0;rn for (ImmutableBytesWritable val : values) rn count += Bytes.toInt(val.get());rn rn rn Put put = new Put(key.get());rn rn put.add(Bytes.toBytes("m"), Bytes.toBytes("city_id_all"), Bytes.toBytes(count));rnrn context.write(key, put);rn rn[/code]rnrnPCHourAnalysis.javarnrn[code=java]package pchour;rnrnimport java.io.IOException;rnrnimport org.apache.hadoop.conf.Configuration;rnimport org.apache.hadoop.hbase.HBaseConfiguration;rnimport org.apache.hadoop.hbase.client.Scan;rnimport org.apache.hadoop.hbase.io.ImmutableBytesWritable;rnimport org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;rnimport org.apache.hadoop.mapreduce.Job;rnrnpublic class PCHourAnalysis rn protected Configuration configure;rn protected int taskCount;rn rn public PCHourAnalysis(String zookeeperClientPort, String zookeeperQuoRum, int taskCount) rn configure = HBaseConfiguration.create();rn configure.set("hbase.zookeeper.property.clientPort", zookeeperClientPort);rn configure.set("hbase.zookeeper.quorum", zookeeperQuoRum);rn rnrn public int analysis() rn int result = 0;rnrn Job job;rn try rn job = new Job(configure);rn rn job.setJobName("pc hour analysis job");rn rn job.setJarByClass(getClass());rn job.setMapperClass(PCHourMapper.class); rn job.setReducerClass(PCHourReducer.class);rn rn catch (IOException e) rn result = -1;rn rn return result;rn rn rn Scan scan = new Scan();rn scan.setCaching(500); rn scan.setCacheBlocks(false); rn rn try rn TableMapReduceUtil.initTableMapperJob("newnetworkbenchSpeedDataRaw", scan, PCHourMapper.class, ImmutableBytesWritable.class, ImmutableBytesWritable.class, job);rn TableMapReduceUtil.initTableReducerJob("newnetworkbenchhourresult", PCHourReducer.class, job);rn catch (IOException e) rn result = -2;rn rn return result;rn rn rn job.setNumReduceTasks(taskCount); rn rn try rn if(!job.waitForCompletion(true)) rn result = -3;rn rn catch (ClassNotFoundException | IOException | InterruptedException e) rn result = -4;rn rn rn return result; rn rn[/code]rnrnPCHour.javarnrn[code=java]package pchour;rnrnpublic class PCHour rnrn public static void main(String[] args) rn String zookeeperClientPort = "8023";rn String zookeeperQuoRum = "tc-op-uaq07.tc,yf-uaq-jsl-ruby00.yf01,tc-uaq-jsl-ruby00.tc,tc-op-uaq17.tc";rnrn PCHourAnalysis hourAnalysis = new PCHourAnalysis(zookeeperClientPort, zookeeperQuoRum, 8);rn hourAnalysis.analysis();rn rn[/code]
java.lang.ClassCastException 问题???
currClass的类型是java.util.ArrayListrn但是我通过以下类型转换时怎么报java.lang.ClassCastException错误,请高手指点。rnCollection colTemp = Collection.class.cast(currClass);
文章热词 设计制作学习 机器学习教程 Objective-C培训 交互设计视频教程 颜色模型
相关热词 ios获取idfa server的安全控制模型是什么 sql android title搜索 学习java哪种书好 大数据需要学习java