Results 1 to 5 of 5

Thread: java.lang.ClassCastException

  1. #1

    Question java.lang.ClassCastException

    Hi.
    Tell me please, what is this mistake? I can't understand.

    ERROR	server	comment	2012-12-05	08:31:28	-	-	-	-	-	63437.16	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:28	-	-	-	-	-	63437.168	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:28	-	-	-	-	-	63437.171	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:28	-	-	-	-	-	63437.176	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:33	-	-	-	-	-	63442.265	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:36	-	-	-	-	-	63445.651	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:36	-	-	-	-	-	63445.661	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:40	-	-	-	-	-	63449.991	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:40	-	-	-	-	-	63449.998	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:41	-	-	-	-	-	63450.002	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:42	-	-	-	-	-	63451.179	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:42	-	-	-	-	-	63451.182	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:42	-	-	-	-	-	63451.188	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:42	-	-	-	-	-	63451.191	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:42	-	-	-	-	-	63451.801	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:42	-	-	-	-	-	63451.807	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:50	-	-	-	-	-	63459.024	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:50	-	-	-	-	-	63459.799	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:50	-	-	-	-	-	63459.912	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:50	-	-	-	-	-	63459.912	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:50	-	-	-	-	-	63459.926	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:51	-	-	-	-	-	63460.591	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:51	-	-	-	-	-	63460.769	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    ERROR	server	comment	2012-12-05	08:31:51	-	-	-	-	-	63460.879	-	-	-	-	-	-	-	-	getUsersList: java.lang.ClassCastException
    Here is the function code:

    public void getUsersList(IClient client, RequestFunction function, AMFDataList params)
    	{
    		String soName = params.getString(PARAM1); 
    		IApplicationInstance appInstance = client.getAppInstance();
    		
    		if (appInstance != null){
    
    			AMFDataMixedArray clientList = new AMFDataMixedArray();		
    			ISharedObject list_so = getSO(soName, appInstance);			
    
    			try
    			{				
    				Iterator iter = list_so.getSlotNames().iterator();			
    				
    				while (iter.hasNext())  
    				{
    					String slotName = (String)iter.next();
    					
    					if (list_so.getSlot(slotName) != null){
    						
    						AMFDataObj userObj = (AMFDataObj)list_so.getSlot(slotName).getData();
    						clientList.put(slotName, userObj);
    						
    					}
    		 
    				}
    				
    			}
    			catch (Exception Ex)
    			{	
    				getLogger().error("getUsersList: " + Ex.toString());
    			}
    			finally
    			{
    				sendResult(client, params, clientList);
    			}				
    			
    		}
    		else{
    			getLogger().error("getUsersList: Error Get appInstance");
    		}
    		
    	}

  2. #2
    Join Date
    Sep 2011
    Posts
    1,934

    Default

    Hi
    You cold try adding some debug into your code to see where you get before you experience this issue.

    Jason

  3. #3

    Default

    I have found that problem is in this thing:

    AMFDataObj userObj = (AMFDataObj)list_so.getSlot(slotName).getData();

    Datas can't be sent. I don't know why.
    Maybe because I block the Share object in this function?

    public void onConnectAccept(IClient client) {
             
    		IApplicationInstance appInstance = client.getAppInstance();
    
    		String userName = client.getProperties().getPropertyStr("u_nm");
    	    String userSid = client.getProperties().getPropertyStr("u_sd");
    		String userRole = client.getProperties().getPropertyStr("u_rl");				
    		String refId = client.getProperties().getPropertyStr("u_rf");
    		String userId = client.getProperties().getPropertyStr("u_id");		
    		
    		if(userId!=null && userSid!=null && userRole!=null && refId!=null && userName!=null){
    
    			String userList = "L_" + appInstance.getName();			
    			AMFDataObj userObj = new AMFDataObj();  			
    			ISharedObject list_so = getSO(userList, appInstance);
    			
    			list_so.lock();
    			
    			try
    			{
    
    				userObj.put("name", new AMFDataItem(userName));
    				userObj.put("sid", new AMFDataItem(userSid));
    				userObj.put("role", new AMFDataItem(userRole));		
    				userObj.put("ref", new AMFDataItem(refId));	
    				
    				list_so.setProperty(userId, userObj);
    				
    			}
    			catch (Exception Ex)
    			{	
    				getLogger().error("onConnectAccept: " + Ex.toString());
    			}
    			finally
    			{
    				list_so.unlock();
    			}				
    			
    		}
    		else{
    			
    			client.rejectConnection(); getLogger().error("onConnectAccept: Error Get UserData"); 
    			
    		}
    		
    	}

  4. #4
    Join Date
    Sep 2011
    Posts
    1,934

    Default

    Hi
    I don't think the data you're sending to the AMFDataObject is an AMFDataObject type that's why you're getting this error.
    You can check the class type by changing the original code from:

    AMFDataObj userObj = (AMFDataObj)list_so.getSlot(slotName).getData();
    clientList.put(slotName, userObj);
    to:

    getLogger().info("data type is "+list_so.getSlot(slotName).getData().getClass().getName());
    This will then tell you the type of data that you are trying to add to the AMFDataObj which may give you the correct data type.
    This will then allow you to change this code:

    AMFDataObj userObj = (AMFDataObj)list_so.getSlot(slotName).getData();
    clientList.put(slotName, userObj);
    to what it actually needs to be to accept the data that you're getting back.

    Jason

  5. #5

    Default

    I have tested and got the next messages, I am at a loss...

    data type is com.wowza.wms.amf.AMFDataItem
    I am actually add users only using the onConnectAccept function...

    public void onConnectAccept(IClient client) {
             
    		IApplicationInstance appInstance = client.getAppInstance();
    
    		String userName = client.getProperties().getPropertyStr("u_nm");
    	    String userSid = client.getProperties().getPropertyStr("u_sd");
    		String userRole = client.getProperties().getPropertyStr("u_rl");				
    		String refId = client.getProperties().getPropertyStr("u_rf");
    		String userId = client.getProperties().getPropertyStr("u_id");		
    		
    		if(userId!=null && userSid!=null && userRole!=null && refId!=null && userName!=null){
    
    			String userList = "L_" + appInstance.getName();			
    			AMFDataObj userObj = new AMFDataObj();  			
    			ISharedObject list_so = getSO(userList, appInstance);
    			
    			list_so.lock();
    			
    			try
    			{
    
    				userObj.put("name", new AMFDataItem(userName));
    				userObj.put("sid", new AMFDataItem(userSid));
    				userObj.put("role", new AMFDataItem(userRole));		
    				userObj.put("ref", new AMFDataItem(refId));	
    				
    				list_so.setProperty(userId, userObj);
    				
    			}
    			catch (Exception Ex)
    			{	
    				getLogger().error("onConnectAccept: " + Ex.toString());
    			}
    			finally
    			{
    				list_so.unlock();
    			}				
    			
    		}
    		else{
    			
    			client.rejectConnection(); getLogger().error("onConnectAccept: Error Get UserData"); 
    			
    		}
    		
    	}

Similar Threads

  1. Unexpected exception.: java.lang.OutOfMemoryError: Java heap space
    By sriv.mayank in forum Performance and Tuning
    Replies: 1
    Last Post: 03-26-2014, 02:40 PM
  2. Wowza failed after 10 days - java.lang.OutOfMemoryError: Java heap space
    By tribalhost in forum Performance Tuning Discussion
    Replies: 5
    Last Post: 04-10-2013, 06:30 AM
  3. Replies: 1
    Last Post: 02-17-2012, 12:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •