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个回答

强制转换错误,onclick方法里获取的和强转的不是同一对象类型

0
qq_28186229
崔峰鸣 是的,但是不会改
2 年多之前 回复
0
qq_35982678
顾念成痴 就是你的思路要清晰
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
记录一次java.lang.ClassCastException的java类型转换异常解决方案-附最终解决方案
自己的项目中,有个定时任务的模块,里面需要将返回的对象强转为某个实体类JobModel,可是在转换的过程中,却报出了java.lang.ClassCastException: com.jy.admin.server.model.JobModel cannot be cast to com.jy.admin.server.model.JobModel at com.jy.admin.server....
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解决方法及定位源码
在近来开发百度地图定位
强制类型转换异常——java.lang.ClassCastException
前言:强制类型转换异常 1.实例——》动物,狗,猫,将猫转换为狗异常 2.解决办法 Object o = new Xx(); o.getClass().getName();获取对象类名 o instanceof 类型 判断 参考链接:https://blog.csdn.net/hlang8160/article/details/78214...
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中父类和子类转型的问题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: $Proxy0 cannot be cast to 的解决办法
出现此问题的场景一般有以下两种: (1)在Java中使用代理模式创建对象。如何创建代理对象在这就不说了。首先,要为代理对象实现接口,然后生成的代理对象用接口的类型进行接收。此处是使用JDK的代理方式,另一种参考下面的第二种应用场景。 (2)在spring框架中使用代理的方式创建对象。Spring的文档中这么写的:Spring AOP部分使用JDK动态代理或者CGLIB来为目标对象创建代
hibernate命名查询时总是报类型转换异常:java.lang.ClassCastException
异常描述如下; 1、在user.hbm.xml中配置如下 2、测试代码如下: public static void getByNamedQuery(String queryName){ //queryName = "com.summer.entity.User.mySQLquery"; Session session = HibernateUt
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
为什么web应用在tomcat启动时报java.lang.ClassCastException异常?
QQ图片~1.JPG (102.65 KB, 下载次数: 0) 下载附件 2015-5-27 11:09 上传           其实这是maven的tomcat插件的一个Bug,使用独立版本的tomcat或者使用maven的jetty插件可以避免这个问题。
定时任务 quartz中出现相同类型的对象无法转换问题(java.lang.ClassCastException)
环境:springboot 排查问题过程: 1:确认不是serialVersionUID版本问题 2:确认不是序列化工具(Jackson)问题 3:写了一个测试方法:将对象put到JobDataMap中,再取出来强转,并无问题 解决方法:去掉spring-boot-devtools即可。。。。。...
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泛型擦除与ClassCastException的问题
今天在复习java泛型时遇到一个疑问:即然java泛型的原理是编译时定,运行时擦除,那为什么还会在运行时抛出ClassCastException异常呢? 问题代码如下:ArrayList<String> list = new ArrayList<String>();//泛型类型为String Method method = list.getClass().getMethod("ad
Java RMI调用发生ClassCastException的处理方法
在学习RMI的时候,通过网上资料或者《Java网络编程和分布式计算》经典教程对RMI有了一定的了解。但是前几天在写一个网络应用软件的时候却发生了点问题。服务器端,客户端都按照RMI规范完成之后,客户端在Naming.lookup()之后,获得的Object转换成接口的时候总是抛出java.lang.ClassCastException $Proxy ... 异常。调试了很长时间,也google了很
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
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; { ...
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 其中...
在父类转换到子类时发生java.lang.ClassCastException
在父类转换到子类时会发生ClassCastException异常,稍微了解Java的人都知道,但是我为什么要写出来,只是抛出一个问题用来提出解决办法,当你面对一个工程时成千上百的类时,是不太容易发现类之间的关系的,所以即使知道该原则,有时候还是避免不了
springboot之继承JpaRepository后自定义数据库操作后出现java.lang.ClassCastException的错误
java.lang.ClassCastException: * cannot be cast to *;这是数据类型强制转化失败的问题。在继承的Jpa的接口中,使用如下的查询方式:在Jpa的自带的方法中,删除操作的方法只有这几种:但是如果我要根据FileName来进行删除操作,一般是如上面的操作,添加方法deleteByFileName(String fileName);使用该方法,你会发现会报C...
springboot 出现两个相同的类强转类型报错 java.lang.ClassCastException
springboot 出现两个相同的类强转类型报错 java.lang.ClassCastException今天出现了一个令我感到惊奇的问题是时候打破常规了 今天出现了一个令我感到惊奇的问题 Java 强转类型,相信大家并不陌生,通常来说,强转类型都是我们知道这个类可以转换成另一个类,可能是他的父类或者是他的同类,这样转换一般来说千百年都不会出错。例如下面的 //Father 是 son 的父类...
Hive批量插入分区表时报java.lang.ClassCastException解决办法
将从一个表查询结果插入到一个分区表时,有时会在Load data步骤出错,这是在执行语句前没切换到目标表所在的库导致。 所以在执行插入语句前,先用use databasename切换到目标表所在的库下就正常了。 ——————————以下是出错语句示例———————————— $ hiveLogging initialized using configuration in jar:file...
关于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...
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.lang.ClassCastException:
FeeDaoImpl中的代码:rnrn public List findFeeAndRole() rn String hql = "from PFee f,PTransFee tf,PTransRole tr where f.feeId = tf.feeId and tf.transRoleId = tr.transRoleId";rn Object[] obj = new Object[3];rn obj[0] = new PFee();rn obj[1] = new PTransRole();rn obj[2] = new PTransFee();rn rn rn return this.getHibernateTemplate().find(hql);rn rnrn页面中的部分代码:rnrn <%rn PagedListHolder ph = null;rn ph=(PagedListHolder)request.getAttribute("list");rn List list=(List)ph.getPageList();rn try rn if (list.size() == 0) rn %>rn rn 没有符合条件的记录rn rn <%rnrn else rn for(Iterator it = list.iterator();it.hasNext();)rn Object[] pair= (Object[])it.next();rn PFee fee = (PFee)pair[0];rn PTransRole role = (PTransRole)pair[1];rn PTransFee tf=(PTransFee)pair[2];rn %>rnrnrn控制台的错误信息:rnrnrnjava.lang.ClassCastException: com.crinode.mbank.pmgt.po.PFeern at org.apache.jsp.frame.pfee.browser_jsp._jspService(browser_jsp.java:138)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)rn at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)rn at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)rn at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)rn at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)rn at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at com.crinode.mbank.pmgt.basedata.SetCharsetFilter.doFilter(SetCharsetFilter.java:13)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)rn at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)rn at java.lang.Thread.run(Unknown Source)
关于一个奇怪的ClassCastException
关于一个奇怪的ClassCastException:android.widget.RelativeLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams 今天在写自定义相机的时候发现一个莫名其妙的异常情况:android.widget.RelativeLayout$Layo...
Spring事务配置上去后出现如下报错:java.lang.ClassCastException: $Proxy1解决
问题描述:查询功能一切正常,但是在增、删、改操作中发现,数据库表中数据没有改变,查看控制台日志也没有任何异常发现,纳闷了好久,仔查检查日志,发现在新增操作中表id有在自增,由此确定是问题出在事务没有提交。将事务配置上去后出现如下报错:java.lang.ClassCastException: $Proxy1,百度上搜到一文,在业务类如果实现了接口,得增加如下代码    true 果然如此,再次
使用net.sf.json包生成一个pojo的json数据出现的问题
今天在使用一个net.sf.json这个包中的类来生成一个pojo的json数据,总是出现一个net.sf.json.JSONException: java.lang.ClassCastException: net.sf.json.JSONObjectcannot be cast to java.lang.String错误,刚开始就纳闷,怎么会出现情况啊。最后我发现,难道是我的get个set方
关于得到泛型的class 异常问题
开始项目环境的搭建,在开始搭建之初,我考虑(s2sh) 底层和数据库交互是直接用hibernateTemplate 这个工具类呢 还是在重新开始封装一次 这样代码的扩展性就会很强,项目耦合明显降低,所有有必要写一个通用的baseDao,baseDao代码中 private Class poClass; @SuppressWarnings("unchecked") public BasicDA
关于我使用spring mvc框架做文件上传时遇到的问题
昨天尝试着用spring mvc框架做文件上传,犯了挺多不该犯的毛病问题1:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: org.apache.catalina.connector.Re
在使用PageHelper分页时的ParseException异常原因
在使用PageHelper分页时的ParseException异常原因 异常信息如下 net.sf.jsqlparser.JSQLParserException ...(省略)...... Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "LIKE" "LIKE "" at line 65, column 28...
使用xStream进行java object<-->xml之间的转换
官方网站:http://xstream.codehaus.org/ 测试了一下,的确十分方便。 java 代码 public static void write() {        XStream sm = new XStream();        mytest t = new mytest();        t.setName(&quot;moogle&quot;...
Fastjson 解析多级泛型时而失败的解决方案
fastjson 解析多级泛型时而失败:class PeiqiResponse<T> { Boolean success; Integer errCode; String errDes; T result; }声明:PeiqiResponse<List<Dept>>调试分析经过多次调试,问题出现在这里 DefaultFieldDeserializer#pa
使用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
tomcat 8.0.35上传好像没成功
tomcat8.0.35刚好像没上传成功 java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
weblogic部署javaweb项目遇到的一些问题
1〉weblogic.application.ModuleException:Cannot load driver class:com.t
org.apache.jasper.JasperException: java.lang.ClassCastException:
我在运行程序进入主界面时出现这样的错误,在网上搜了一下说是有两个jasper.jar文件,我在电脑里搜了一下,一个在Tomcat的文件夹里,一个在myeclipse的文件夹里,我把这两个分别换了一下名字,好像都没用,谁能指点一下,再次先谢了。rnrnrnHTTP Status 500 - rn________________________________________rntype Exception reportrnmessage rndescription The server encountered an internal error () that prevented it from fulfilling this request.rnexception rnorg.apache.jasper.JasperException: java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessorrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)rn org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)rn com.ynstudio.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:74)rn org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn com.hrj.DTMonitor.filter.LoginFilter.doFilter(LoginFilter.java:32)rnroot cause rnjava.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessorrn org.apache.jsp.frame.login.userLogin_jsp._jspInit(userLogin_jsp.java:38)rn org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)rn org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)rn org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)rn com.ynstudio.webapp.filter.LocaleFilter.doFilterInternal(LocaleFilter.java:74)rn org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn com.hrj.DTMonitor.filter.LoginFilter.doFilter(LoginFilter.java:32)rnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.rn________________________________________rnApache Tomcat/6.0.16rnrn
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: [Ljava.lang.Object;
在 action中代码:rnList itemsList=(List)financeService.getexpensesListByCExpenses("CExpensesName as n,CExpenses as c,CExpensesItems as s ");rn CExpensesItems cei=new CExpensesItems();rn CExpenses ce=new CExpenses(); rn rn d[12]=0.0;rn if(itemsList !=null)rn for(int i=0;i
文章热词 机器学习教程 Objective-C培训 交互设计视频教程 颜色模型 设计制作学习
相关热词 mysql关联查询两次本表 native底部 react extjs glyph 图标 怎么学习互联网大数据 村干部学习大数据心得