Searching the web there are hundreds of answers to why getDefinitionByName doesn't work - because the class definition that you are trying to get is not included in the swf.
This is not that problem.
My app is loading a swc at run time, unzipping it, reading the xml and displaying a list of classes that were in that swc. You can then select a class and it will be added to the stage.
When I load the swc and try to use getDefinitionByName I get the following trace:
getting class: com.company.assets:AppFooterShadow
error: Error #1065: Variable assets:AppFooterShadow is not defined.
The com.company is stripped off the beginning!
From code similar to this:
try
{
trace( "getting class: " + definition );
var currentClass : Class = getDefinitionByName( definition ) as Class;
}
catch( e : Error )
{
trace( "error: " + e.message );
}
If I type a class name in a text input box and try to load that it works fine - with exactly the same string being passed to the function.
Anyone got any idea what is going on here? Seems very odd to me.
I can't believe how long I've been staring at this and not seeing what the problem was!
I had typed in this:
com.company.assets.AppFooterShadow
and this was in the list:
com.company.assets:AppFooterShadow
a colon instead of a full stop!
Ok I'll stop talking to myself - please ignore this!
Related
I response this error when get JSON data by retrofit.
List<NewLicense> result = null;
Call<List<NewLicense>> serviceResult = ShahrdariApp.getShahrdariWebService().getLicenses(Configuration.getInstance().getString(SharedPrefs.MAC_ADDRESS), id);
try {
Response<List<NewLicense>> response = serviceResult.execute();
result = response.body();
Log.d("responseCode", String.valueOf(response.code()) );
} catch (Exception e) {
exceptionHandling(e);
Log.d("responseCode", String.valueOf(e.getMessage()) );
}
return result;
I had the same issue and forgot to set the Project SDK added this and it resolved the issue.
Simply restarting the IDE via File -> Invalidate caches can often solve this issue.
I faced the message
Unable to evaluate the expression Cannot find source class for
java.util.List
in hovering a List field while debugging in IntelliJ IDEA 2022.1.3 (UltimateEdition).
Even though an SDK was assigned to my Project, it helped to visit
IDEA ->File ->Project Structure -> Platform Settings ->SDKs and re-assign the SDK already visible in the list.
Namely I assigned openjdk-1.8.0.302-1, applied "OK", after that it was possible to debug a List foo.
IDE restart after that may additionally be necessary.
I am creating a unit Stringy and its type is TStringy = Class. I am then trying to use this class in my form. So in other file.pas, I am trying to use it. While doing uses Stringy; on Stringy I am getting red line error 'Can not resolve unit name 'Stringy'
//TStringy.pas file:
unit Stringy;
interface
type
TStringy = Class
//Code on form that is supposed to use it:
uses Stringy;
I changed my file name to Stringy.pas from TStringy.pas and issue resolved.
Object.class.getMethod(methodName, Object.class);
is not getting executed by bsh.Interpreter and throwing exceptions
Typed variable declaration : reflection error: bsh.ReflectError: Method getMethod( java.lang.String, java.lang.Class ) not found in class'java.lang.Class'
Any idea how to fix this ?
Thanks in advance.
Beanshell doesn't support variable parameters, so you need to put it in an array as per older versions of the Java language.
Object.class.getMethod("equals", new Class[] { Object.class } );
Im trying to connect a Flash client to BlazeDS. There has been some success with this from others using the vanilla BlazeDS setup. However I'm using the new Spring BlazeDS Integration from springsource and running aground.
The flash client actually seems to be working in that I can see the correct data in the body of the returned object, but for some reason unknown it fails casting as an IMessage. It fails in PollingChannel.as on this line with the subject line error
var messageList:Array = msg.body as Array;
for each (var message:IMessage in messageList) <--
On application load I register a whole bunch of classes like so
registerClassAlias( "flex.messaging.messages.RemotingMessage", RemotingMessage );
registerClassAlias("mx.messaging.messages.IMessage", IMessage);
etc..
my code is basically
var channelSet:mx.messaging.ChannelSet = new mx.messaging.ChannelSet();
var channel:mx.messaging.channels.AMFChannel = new AMFChannel("my-amf", "http://localhost:8400/SpringA/messagebroker/amf");
channelSet.addChannel(channel);
var consumer:mx.messaging.Consumer = new Consumer();
consumer.channelSet = channelSet;
consumer.destination = "simple-feed";
consumer.subscribe();
consumer.addEventListener(MessageEvent.MESSAGE, test);
private function test(event:IMessage)
{
trace("msg..");
// breakpoint never makes it here
}
I have a flex client which works 100% with same destination/channel.
The error in the title means that you, for some reason, got an object that is not implementing or extending the IMessage interface, therefore the loop can not cast it in this part:
for each (var message:IMessage in messageList){
Either you should somehow make sure that you don't add anything that is not extending or implementing IMessage, or check if the variable IS actually ext./imp. it. Also - if you want to do that, you will have to change the for each like this:
for each (var obj in messageList){
if (obj is IMessage){
var message:IMessage = obj as IMessage;
// DO STUFF HERE
}
}
Add this Object mapping:
registerClassAlias("flex.messaging.io.ObjectProxy", ObjectProxy);
If on your Java VO objects you have overridden the hashcode() method, this situation could happen.
Remove the hashcode() override (if you are able to).
See my blog for the backstory on how I discovered this. http://squaredi.blogspot.com/2013/12/remoting-landmine-without-stack-trace.html
I had the same error when trying to send an actionscript object to the backend. My problem was that my c# equivalent object was missing an public parameterless constructor.
I am working on an indent and outdent for the advanced datagrid. I have a set of functions which work when operating on the underlying data fine, but which throw "Error: Bookmark no longer valid" when operating on the selected items of the datagrid.
When I run this code it runs fine:
indentLeaf(l5)
outdentLeaf(l4)
But this code fails:
adg.selectedItem = l5
indentLeaf(adg.selectedItem as Leaf)
adg.selectedItem = l4
outdentLeaf(adg.selectedItem as Leaf)
The code does not fail in all instances, only for some configurations of the data grid data tree.
The code needs to be run in the debugger version of the flash player if you want to see the error thrown. I have cut and pasted the error I get into the text area for reference as well as below.
The code in the toy app seems to recover ok when the exception is thrown, but in my larger app it leads to hard crashes.
Example code can be found here with view source turned on: http://www.crcarlson.com/adg/ADGArrayCollectionUpdate.swf
To create the error, reset the tree and then click "indent/outdent2"
I would appreciate any suggestions on how to get around this.
The full stack trace looks like this:
Error: Bookmark no longer valid.
at ListCollectionViewCursor/seek()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:2417]
at mx.collections::HierarchicalCollectionViewCursor/get current()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:220]
at mx.collections::HierarchicalCollectionViewCursor/collectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:1143]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::HierarchicalCollectionView/nestedCollectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionView.as:1595]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1024]
at mx.collections::ListCollectionView/handlePropertyChangeEvents()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1433]
at mx.collections::ListCollectionView/listChangeHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1300]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ArrayList/internalDispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:673]
at mx.collections::ArrayList/itemUpdateHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:704]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at Leaf/dispatchChildrenChanged()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:119]
at Leaf/addChildAt()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:63]
at Leaf/move()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:96]
at ADGArrayCollectionUpdate/outdentLeaf()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:86]
at ADGArrayCollectionUpdate/IO2_clickHandler()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:113]
at ADGArrayCollectionUpdate/__IO2_click()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:183]
I just found a workaround for this bug (I am using SDK 3.5 but I guess a 4.1 fix would be very much the same). The problem lies within the "current()" getter of the HierarchicalCollectionViewCursor class.
It doesn't catch the CursorError that's caused by an invalid bookmark.
Step 1 is to create a better cursor class:
public class HierarchicalCollectionViewCursor2 extends HierarchicalCollectionViewCursor
{
public function HierarchicalCollectionViewCursor2(collection:HierarchicalCollectionView, model:ICollectionView, hierarchicalData:IHierarchicalData)
{
super(collection, model, hierarchicalData);
}
override public function get current() : Object
{
// original HierarchicalCollectionViewCursor class fails to catch the "bookmark no
// longer valid" Error, which is thrown as a CollectionViewError instance in ListCollectionView,
// but transformed to a CursorError within the same class
try {
var result:Object = super.current;
}
catch (e:CursorError) {
result = null;
}
// done
return result;
}
}
Step 2 is to create a HierarchicalCollectionView class, which returns that new cursor:
use namespace mx_internal;
public class HierarchicalCollectionView2 extends HierarchicalCollectionView
{
public function HierarchicalCollectionView2(hierarchicalData:IHierarchicalData=null, argOpenNodes:Object=null)
{
super(hierarchicalData, argOpenNodes);
}
override public function createCursor() : IViewCursor
{
return new HierarchicalCollectionViewCursor2(this, treeData, this.source);
}
}
Step 3 is to actually use that new HierarchicalCollectionView2 class as your data-provider.
var itemsAC:ArrayCollection = new ArrayCollection();
// add items etc
this.adgDataProvider = new HierarchicalCollectionView2(new HierarchicalData(itemsAC));
Now you would think that all is well BUT the drama wouldn't be complete without another annoying Flex-SDK bug. In this case its:
https://bugs.adobe.com/jira/browse/FLEXDMV-1846
So, Step 4 is to subclass the AdvancedDataGrid component as described in the bug issue.
That's it -- works for me!
This Exeption may hapen in Flex AdvancedDatagrid with HierarchicalData.
When items are added to Dataprovider it notifies the datagrid . the datagrid receives colection change events each time items are added to it.then some Datagrid internal can be messed up .
You could disable the automatic ArayCollecion refresh :
dataprovider.disableAutoUpdate();
and when you datagrid is ready to use refresh datagrid rendering :
if (advancedDataGrid) {
advancedDataGrid.invalidateList();
advancedDataGrid.invalidateDisplayList();
advancedDataGrid.expandAll();
}
I hope this will help.
Sami was right about the internals (of HierarchicalCollectionViewCursor) getting messed up. This was one of the most long-standing bugs in the Flex framework. It was recently documented - and fixed - at FLEX-34119 and all its linked tickets. It should be available in Flex SDK 4.14, which means that no workaround will be needed from that point onward.