Java Deserialization Error - java

So for some reason stack overflow won't let me post more than 2 links so here is a link containing links: http://pastebin.com/FERUSH2P
Hello, so I have no idea why but I am getting ClassNotFoundException when
trying to deserialize a .bin file. I am serializing in one program and deserializing in another. The serialversion IDs are the same. Here is class in the first program: (Link 1) and the second program: (Link 2) Here is seriazation code (in second program): (Link 3) And here is deserialization code (in first program): (Link 4) And finally here is the error: (Link 5)
I would really appreciate any help! Thanks!
EDIT: By the way, getCause() returns null
EDIT: I fixed it by moving the classes now are in packages with the same name. Thanks!

Your code seems correct (except for a minor remark - it's better to put your "stream.close()" in "finally" clauses).
The error clearly indicates that the reading side doesn't have class "AnimatedModelData" on its classpath. Your can verify it by calling Class.forName("core.ModelData.AnimatedModelData") on the reading side, even without reading the stream. The standard solution is to compile such model classes once, optionally package them as a jar, then adding them to the classpath of both sides - reader and writer.

Related

RSyntaxTextArea Custom Language JFlex

I'm trying to use JFlex to add custom language highlighting to RSyntaxTextArea. However, the moment I type a character I get an Index Out of Bounds Exception:
http://pastie.org/private/ygjyj4y5nludeu3dn1xug
This occurs even if I use the example JFlex code provided here: https://github.com/bobbylight/RSyntaxTextArea/wiki/Adding-Syntax-Highlighting-for-a-new-Language
I'm not sure what could be causing this. Could someone point me in the right direction?
I'm not quite sure why this works, but I appear to have fixed this problem by copying part of the yylex method from PythonTokenMaker.java to the Java class created by JFlex.
Specifically, I copied and replaced this section of the code: http://pastie.org/private/whjzfhbrzwm8qc88t1idq
It is from the defintion of the method to the line with the comment // store back cached position
Hopefully this will help someone stuck on the same problem!

ifstream error readings characters from string

so, I've written programs using ifstream in the past, successfully. yet this time, I can't seem to correct this "cannot read characters from string" error shown in the image. I basically declare ifstream inputFileStream in the class header, then try stating inputFileStream("text.txt"); and I already have that given error in the debugger.
More specifically, I construct an instance of the given class in the main method, and call (from the main method,) the public method which contains the statement inputFileStream("text.txt");.
I've made sure that the given text file is actually in the same folder as the project. Anybody familiar with this error?
I looked up the cccccccc error code and it has to do with an uninitialized stack something, but why would that be relevant to this?
The closest post to this was here, but im still trying to decipher the problem How to end up with a pointer to 0xCCCCCCCC
so, I got it working. I'm using visual studio 2013. all I had to do was copy the code into a new project, and compile it there. no idea why this worked as such

Java find where a class is used in the code - programmatically

I have a List of classes which I can iterate through. Using Java is there a way of finding out where these classes are used so that I can write it out to a report?
I know that I can find out using 'References' in Eclipse but there are too many to be able to do this manually. So I need to be able to do this programmatically. Can anyone give me any pointers please?
Edit:
This is static analysis and part of creating a bigger traceability report for non-technical people. I have comprehensive Javadocs but they are not 'friendly' and also work in the opposite direction to how I need the report. Javadocs start from package and work downwards, whereas I need to start a variable level and work upwards. If that makes any sense.
You could try to add a stacktrace dump somewhere in the class that isolates the specific case you are looking for.
public void someMethodInMyClass()
{
if (conditions_are_met_to_identify)
{
Thread.dumpStack();
}
// ... original code here
}
You may have to scan all the sources, and check the import statements. (Taking care of the * imports.. having to setup your scanner for both the fully Qualified class name and its packagename.*)
EDIT: It would be great to use the eclipse search engine for this. Perhaps here is the answer
Still another approach (probably not complete):
Search Google for 'java recursively list directories and files' and get source code that will recursively list all the *.java file path/names in a project.
For each file in the list:
1: See if the file path/name is in the list of fully qualified file names you are interested in. If so, record is path/name as a match.
2: Regardless if its a match or not, open the file and copy its content to a List collection. Iterate through the content list and see if the class name is present. If found, determine its path by seeing if its in the same package as the current file you are examining. If so, you have a match. If not, you need to extract the paths from the *.import statements, add it to the class name, and see if it exists in your recursive list of file path/names. If still not found, add it to a 'not found' list (including what line number it was found on) so you can manually see why it was not identified.
3: Add all matches to a 'found match' list. Examine the list to ensure it looks correct.
Not sure what you are trying to do, but in case you want to analyse code during runtime, I would use an out-of-the box profiler that shows you what is loaded and what allocated.
#Open source profilers: Open Source Java Profilers
On the other hand, if you want to do this yourself (During runtime) you can write your own custom profiler:
How to write a profiler?
You might also find this one useful (Although not exactly what you want):
How can I list all classes loaded in a specific class loader
http://docs.oracle.com/javase/7/docs/api/java/lang/instrument/Instrumentation.html
If what you are looking is just to examine your code base, there are really good tools out there as well.
#see http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis

java : Tracing out the Error line in my case

I am working on a existing Java EE based application .
Somehow the functionality is not working written by them .
When i found out the logs in Linux server i found out this Exception there
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at com.cyber.EasyOptions.view(EasyOptions.java:2054)
What does this mean exactly ??
I guess there is a class named EasyOptions and in that there is a method view and inside it there is this Exception occuring ??
This particular class EasyOptions is present inside a jar file in our code .
I am using JD-GUI decompiler and when navigated to this particualr jar , and saw this class EasyOptions , inside view method there is no such line (2054)
so dont know we can match the line numbers this way or not ??
I guess we cant match line numbers this way , my questions how can we trace out the exact line of error ??
guess there is a class named EasyOptions and in that there is a method view and inside it there is this Exception occuring ??
That's correct.
I am using JD-GUI decompiler and when navigated to this particualr jar , and saw this class EasyOptions , inside view method there is no such line (2054)
The line number only makes sense in the context of the original source code. The decompiled code isn't identical to the original and will have different line numbering.
how can we trace out the exact line of error
Without the original source code it's going to be tricky. One way to narrow down the possibilities is to look through the decompiled code for EasyOptions.view(), looking for places where an array is being accessed.

Dll function returns 1

Im using Java (JNA) to use a function in a third party .dll file. The functions I'm calling are returing the integer value 1.
After reading, I've discovered that this return value is traditionally 0 if everything runs correctly.
Was wondering if this is always the case or if theres any way to determine what it should be?
In the .h file bundled with the .dll it has the comment
// rc: EXIT_SUCCESS means NO ERROR
After the function.
Check actual dll documentation, there should be the way to tell what's wrong.
If nothing helps try calling GetLastError() WinAPI - some meaningful error code might be reported.
Also try to look at debug output during function call - some traces might be there even in Release build
Yes, zero typically means success in the C/C++ world.
In the days before exception handling you had to have a way to indicate failure and the return value was pretty much reserved for failure/success. As for what '1' means, you will have to look in the header of the dll for the function that is returning '1' and see if they included anything about error conditions. There are too many possibilities without seeing the code or knowing more about the dll to provide any easy answers.
What is the name of the function? What is it attempting to do? What can you do if you know the function failed?

Categories

Resources