{"id":3813,"date":"2014-03-30T05:51:52","date_gmt":"2014-03-30T05:51:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/javaserializationrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-03-30T05:51:52","modified_gmt":"2014-03-30T05:51:52","slug":"javaserializationrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/javaserializationrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"java,serializationRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d3dc3e435ec0b356e632169b0452641b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLiam W<br \/>\njava android eclipse android-ndk unsatisfiedlinkerror<br \/>\nI&#8217;ve been trying to figure out why I&#8217;m getting an error stating the method can&#8217;t be found, but everything seems to be in order (at least the things that would cause this error).My Android class:package com.liamw.root.androididchanger;import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;public class DebugUserActivity extends Activity {Button button;TextView logcat;static {System.loadLibrary(&#8220;sqlite&#8221;);}@Overri<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/91b665b7261ccd0c73a987911c96d95f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmj_<br \/>\njava ubuntu service daemon jsvc<br \/>\nI&#8217;m trying to create a service that will run in Ubuntu Linux written in Java. My executable Jar file is a big fat Jar file that has all the dependencies packaged inside with it. I get the following error when I try to run it using JSVC. Java VM created successfully Class org\/apache\/commons\/daemon\/support\/DaemonLoader found Cannot register native methods java_init failed Service exit with a return value of 1What&#8217;s killing me is the &#8220;cannot register native methods&#8221; line. What does this mean and ho<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/59b381921396a653a7749a0349a10d32?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nuser2907333<br \/>\njava android cordova<br \/>\nI&#8217;m making an android app which uses bluetooth using phonegap and I&#8217;m having issues handling code because it get&#8217;s called every 100ms. I want to try if the issue occurs because my phonegap javascript code is to long causing delays. To try this I want to dispaly the received message using a native textbox. Is this possible? and How would I do this?ThanksMartijn PS: I&#8217;ve tried using Toast but since I want to change the displayed value every 100ms this doesn&#8217;t work.Codeupon receiving a message this<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2fbcb2a45fc59dca53295a882b6b34b8?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nPreetygeek<br \/>\njava c++ winforms jni<br \/>\nSo, i have visual studio consloe project that compile to .dll file. I&#8217;ve created simple windows form System::Windows::Forms::FormI&#8217;ve created a .java file:import java.io.Serializable;public class MyBean implements Serializable{\/*** *\/static{System.loadLibrary(&#8220;MyBean&#8221;); }private static final long serialVersionUID = 1L;private static native String getDateCpp();public String getDate(){return getDateCpp();}}compiled it and generate a .h file by javah:\/* DO NOT EDIT THIS FILE &#8211; it is machine genera<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dddf3305018066b6962d07163883bd4e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFelix<br \/>\njava javassist<br \/>\nWith Javassist, is there any way to inject code into a native method? In this case, I&#8217;m trying to make the OpenGL calls in my game print out their names and values when called, but all my attempts have hit errors when I assume the openGL dll code is added.The method would look something like:public static native void glEnable(int paramInt);Since the methods initially have no body, the only way I&#8217;ve found to actually add the code is with something like:CtBehavior method = cl.getDeclaredBehaviors(<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/mNgna.jpg?s=32&amp;g=1\" \/><br \/>\nCan Eldem<br \/>\njava eclipse leap-motion<br \/>\nI have a project that uses leap motion sdk. I wrote this project in Eclipse. When I run my program I don&#8217;t have any problem because I set my native libraries as it is suggested from configuration. However, when I export my application I can not run my program because Eclipse does not include my native libraries and I am having this error. Native code library failed to load. java.lang.UnsatisfiedLinkError: no LeapJava in java.library.pathMy purpose is create a .jar file which user can run with o<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/7Fzgd.jpg?s=32&amp;g=1\" \/><br \/>\nArturs<br \/>\njava android upnp<br \/>\nFrom Android 4.1 (under Wi-Fi Direct service discovery) it is suppose to support native UPnP service discovery.I presume it was developed for Wi-Fi Direct, but the methods available seem to be generic. Even the JavaDoc for methods mention that it searches for all UPnP services on the network and not only WiFi Direct slaves\/masters.However, I am failing to implement it so that it works&#8230; I manage to set up all requirements and I get positive onSuccess callbacks, but I receive no onUpnpServiceAva<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9ea62038ca627187a0d021fc71034b74?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTheEnemyOfQuality<br \/>\njava dll linker jni<br \/>\nI&#8217;ve got a bit of an odd problem. I have a project in C++ that&#8217;s basically a wrapper for a third party DLL like this:MyLibrary &#8211;loads DLL_A &#8212;-loads DLL_BI load DLL_A with LoadLibrary(), wrap several of its functions and generate my own DLL. I&#8217;ve tested this in a C++ project and a C# project. Both do everything they&#8217;re supposed to do: load DLL_A, make a couple of function calls, and indirectly load DLL_B. The problem is when I build a DLL for java and make the calls through JNI. Everything run<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b5a00520765e25a588e93716e5da846f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser614454<br \/>\njava android https<br \/>\nI am trying to make a HTTPS call using Java to a browser that uses the native login prompt.http:\/\/blog.stevensanderson.com\/2008\/08\/25\/using-the-browsers-native-login-prompt\/Currently I&#8217;m using the below for HTTP and it works fine for other websites since I know the parameters to put in&#8230;however it fails for the above type of login (I am not sure how to capture the parameters&#8230;it&#8217;s a login pop up..or if this is even the correct approach)&#8230;.any ideas??..thanksHttpUtility.sendPostRequest(request<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7f21e53182c38f66f448974968fd3653?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKarel Petranek<br \/>\njava java-web-start java-native-interface<br \/>\nI am using Java Web Start to launch a Java application that depends on some third party native libraries. These native libraries then subsequently load another native library (commonLib) as their dependency using LoadLibrary\/dlopen.When not using Web Start, everything works as expected when the native libraries are located in the same directory.Web Start, however, requires the native libraries to be packed in a jar file and referenced in the jnlp file, which I did:&lt;!&#8211; Windows OS &#8211;&gt;&lt;re<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/df990abee45d1415cb492a266f2a392d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKev84<br \/>\nc# serialization datacontractserializer<br \/>\nI am currently trying to serialize a List, it serializes (I think fine), but when it deserialize, Sorry for the amount of code, but I am really stuck and have no idea why this is happening, i also tried to changed the struct into a class and no help.THANKS.i get the following error UPDATEDThere was an error deserializing the object of type There was an error deserializing the object of type `System.Collections.Generic.List`1[[A.B.C.DataValues, A.V, Version=1.0.0.0, Culture=neutral, PublicKeyTok<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6277c350d08116f636da218f4eff0c86?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsgtz<br \/>\nc# serialization protobuf-net<br \/>\n(NOTE: Dictionary where T is some ProtoContract \/ ProtoMembered class works fine. ) This issue only happened for me with type object. I was trying to serialize a dictionary of Dictionary working. typeof(object) doesn&#8217;t work. Should it? Should I implement a string based work around?In this scenario, object will only ever be a .net primitive.[Test]public void De_SerializeObjectDictionary2(){var d = new Dictionary&lt;string, object&gt;();d.Add(&#8220;abc&#8221;, 12);var ms = new MemoryStream();var model =<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/780c1fb914ca536bb5def9493248e61a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndroid Killer<br \/>\njava serialization deserialization object-serialization<br \/>\nI have an object as follows:public class Records implements java.io.Serializable{private int cId;private int pId;private int vlaue;private int tag;public Records(int c, int p, int v, int t){this.cId=c;this.pId=p;this.value=v;this.tag=t;} }I&#8217;ve collected lots of data, constructed objects as in the above class and seralized them to disk. One dump thing I&#8217;ve forgotten to include in the class file is methods to access the values for each object. For example, to access the cId value for a particular<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f8869c89889c2ceff0fc7d7a253d9f8b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChris S<br \/>\nc# unit-testing serialization xml-serialization<br \/>\nI have a class that serializes a set of objects (using XML serialization) that I want to unit test.My problem is it feels like I will be testing the .NET implementation of XML serialization, instead of anything useful. I also have a slight chicken and egg scenario where in order to test the Reader, I will need a file produced by the Writer to do so.I think the questions (there&#8217;s 3 but they all relate) I&#8217;m ultimately looking for feedback on are:Is it possible to test the Writer, without using the<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/84ab267c42156779059c40c742899eab?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSyg<br \/>\nwcf json serialization xml-serialization .net-4.0<br \/>\nI&#8217;m going slidely mad over here, maybe someone can help me figure out what&#8217;s going on. I have a WCF service exposing a function using webinvoke, like so:[OperationContract][WebInvoke(Method = &#8220;POST&#8221;,BodyStyle = WebMessageBodyStyle.Wrapped,RequestFormat = WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json,UriTemplate = &#8220;registertokenpost&#8221;)]void RegisterDeviceTokenForYoumiePost(test token);The datacontract for the test class looks like this:[DataContract(Namespace=&#8221;Zooma.Test&#8221;, Name=&#8221;tes<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4c02e972714a97e66e4111c52ecc49ae?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTuukka Mustonen<br \/>\njava serialization jsf jsf-2<br \/>\nIs it possible to explicitely deny JSF from serializing some component trees? At the moment I am passing a non-serializable object to a h:inputText:&lt;h:inputText value=&#8221;#{nonSerializableBean.nonSerializableClassInstance}&#8221; \/&gt;What happens after a few clicks is that I get (during view restoration):javax.faces.FacesException: Unexpected error restoring state for component with id configurationForm:j_idt292:j_idt302:field. Cause: java.lang.IllegalStateException: java.lang.InstantiationException<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/00c4b6dae0d342a11e70e4982440f9e6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser01<br \/>\njava serialization<br \/>\nI&#8217;m using a 3rd party library that asks to use only serializable object with its methods. How do I ensure that a java object is serializable ?Sometimes my objects are just a list, a string or a simple POJO.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/44d4d7681bfc6f7e6f0c8d606c33d832?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nashwnacharya<br \/>\nc# .net json serialization deserialization<br \/>\nSo, I have an JSON object where one of the string members have characters like quotes(&#8220;) and apostrophes(&#8216;) in them. This JSON object is returned by a third party API (which I have no control over). This is how I invoke this API:var client = new WebClient(); var data = new NameValueCollection(); var result = client.UploadValues(url, data); MemoryStream ms = new MemoryStream(result);So, when I try to deserialise this string like so:DataContractJsonSerializer serializer = new DataCon<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/xv0f4.jpg?s=32&amp;g=1\" \/><br \/>\nAbhinav Kumar<br \/>\njava serialization deserialization<br \/>\nI know that we have to define methods with the following signatures to override the default serialization process..private void writeObject(ObjectOutputStream os) {} private void readObject(ObjectInputStream is) {}Is there any restrictions on the type of exceptions which can be thrown by the above methods.I know that exceptions thrown by a method are not part of method signature but wanted to confirm..<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3513eddfd26121033280b74d9dd6fb04?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nblz<br \/>\njava networking serialization<br \/>\nI am trying to measure the amount of bandwidth used by my program to send Java objects across the network. I thought I could simply serialise the objects to disk and use the file size as an indication, but this seems to not be the case. What I did was serialise the objects to a file while capturing the network usage with tcpdump: sudo tcpdump -l -i lo port 54544 | tee test_112_512Then to determine the total traffic used I used the following command:cat test_112_512 | grep &#8216;54544 &gt;&#8217; | awk &#8216;<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Liam W java android eclipse android-ndk unsatisfiedlinkerror I&#8217;ve been trying to figure out why I&#8217;m getting an error stating the method can&#8217;t be found, but everything seems to be in order (at least the things that would cause this error).My Android class:package com.liamw.root.androididchanger;import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;public class DebugUserActivity extends [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3813","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3813"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3813\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}