|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Getting started with ikvmI am trying to have a .net client talk to a java server
page, and from what I have read the ikvm tool would work well but I am having
some troubles getting started. My first issue is that when I try to write an object that
has implemented the Serializable class to an ObjectOutputStream I am receiving a
NotSerializableException error. I am starting with a Command class that exists in the java
server code. I am using ikvmc to compile the .class file of this Command
class (see code below) into a dll, and then referencing that dll in my j#
project. The code to write to the object output stream is in the j#
project (posted below). If I create a class in the j# project with the
same code for the Command class then the object can be successfully written to
the ObjectOutputStream and the java server receives it. Can someone explain to me why the class in the dll created
using ikvmc is not serializable? According to the object browser
ISerializable is one of its base types. My class: package mar.common.beans; import java.io.Serializable; public class Command implements Serializable { private final static long
serialVersionUID = 1; private int
commandId_; private Object o; public Command(int commandId, Object
obj) { commandId_
= commandId; o
= obj; } public void
setCommandId(int commandId) { commandId_
= commandId; } public int
getCommandId() { return commandId_; } public Object
getObject() { return o; } } Code to write to the object output stream: public static Object Post(Command
cmd, ReturnType rType) { Object objectToReturn = null; try { URL url = new URL("http://localhost:8080/MyJavaServer/MySystem"); HttpURLConnection urlc = (HttpURLConnection)url.openConnection(); urlc.setRequestMethod("POST"); urlc.setDoInput(true); urlc.setDoOutput(true); urlc.connect(); OutputStream os = urlc.getOutputStream(); ObjectOutputStream oos = new
ObjectOutputStream(os); try { oos.writeObject(cmd);
// Error here } catch (Exception
ex) { } //
More Stuff, but need to get past this error first } David
Burt IGT
Mariposa 702.669.7520 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
|
|
Re: Getting started with ikvmHi David,
You cannot mix IKVM and J#. Regards, Jeroen > -----Original Message----- > From: Burt.David [mailto:David.Burt@...] > Sent: Monday, October 19, 2009 10:48 PM > To: ikvm-developers@... > Subject: [Ikvm-developers] Getting started with ikvm > > I am trying to have a .net client talk to a java server page, and from > what I have read the ikvm tool would work well but I am having some > troubles getting started. > > > > My first issue is that when I try to write an object that has > implemented the Serializable class to an ObjectOutputStream I am > receiving a NotSerializableException error. > > I am starting with a Command class that exists in the java server code. > I am using ikvmc to compile the .class file of this Command class (see > code below) into a dll, and then referencing that dll in my j# project. > The code to write to the object output stream is in the j# project > (posted below). If I create a class in the j# project with the same > code for the Command class then the object can be successfully written > to the ObjectOutputStream and the java server receives it. > > > > Can someone explain to me why the class in the dll created using ikvmc > is not serializable? According to the object browser ISerializable is > one of its base types. > > > > My class: > > package mar.common.beans; > > import java.io.Serializable; > > public class Command implements Serializable > > { > > private final static long serialVersionUID = 1; > > private int commandId_; > > private Object o; > > > > public Command(int commandId, Object obj) > > { > > commandId_ = commandId; > > o = obj; > > } > > > > public void setCommandId(int commandId) > > { > > commandId_ = commandId; > > } > > > > public int getCommandId() > > { > > return commandId_; > > } > > > > public Object getObject() > > { > > return o; > > } > > } > > > > Code to write to the object output stream: > > public static Object Post(Command cmd, ReturnType rType) > > { > > Object objectToReturn = null; > > try > > { > > URL url = new > URL("http://localhost:8080/MyJavaServer/MySystem"); > > HttpURLConnection urlc = > (HttpURLConnection)url.openConnection(); > > > > urlc.setRequestMethod("POST"); > > urlc.setDoInput(true); > > urlc.setDoOutput(true); > > urlc.connect(); > > > > OutputStream os = urlc.getOutputStream(); > > ObjectOutputStream oos = new ObjectOutputStream(os); > > > > try > > { > > oos.writeObject(cmd); // Error here > > } > > catch (Exception ex) { } > > // More Stuff, but need to get past this error first > > } > > > > > > David Burt > > IGT Mariposa > > 702.669.7520 > > David.Burt@... > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
|
|
Tr : Re : Getting started with ikvmHello, before all i would like tell you congratulation for this job.
I want to submit you a bug in the H2 database dll, produce by ikvm.
The necessaries ikvm.openjdk.*.dll used are:
ikvm.openjdk.Core.dll
ikvm.openjdk.Jdbc.dll
ikvm..openjdk.Text.dll
ikvm.openjdk.Util.dll
ikvm.openjdk.Runtime.dll
The code below produce an exception during the execution of the getConnection method:
'-------------------------------------------------------------------------
Public Class Form1 Private Sub btTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btTest.Click Tryorg.h2.Driver.load() Dim cnt As org.h2.jdbc.JdbcConnection Dim h2ds As New org.h2.jdbcx.JdbcDataSource()h2ds.setURL( "jdbc:h2:~/classicmodels/data")h2ds.setPassword( "")h2ds.setUser( "sa")cnt = h2ds.getConnection() cnt.close() Catch ex0 As java.lang.NullPointerExceptionMessageBox..Show(ex0.getMessage) Catch ex1 As ExceptionMessageBox.Show(ex1.Message) End TryEnd Sub End Class'-------------------------------------------------------------------------------------------------------------- FileNotFoundException can not be cast into Java.lang.Exception
You will find the lastest H2 database jar file in attachment. The H2 database files exist on my hard drive, and i can use it with H2 console.
Could you do anything for me?
Thank you ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
|
|
Re: Tr : Re : Getting started with ikvmHi,
Before asking for help you need to try with *all* IKVM.OpenJDK.*.dll assemblies available. Regards, Jeroen > -----Original Message----- > From: Kossonou Krémé Landry [mailto:kossonou_landry@...] > Sent: Wednesday, October 21, 2009 9:21 PM > To: ikvm-developers@... > Subject: [Ikvm-developers] Tr : Re : Getting started with ikvm > > Hello, before all i would like tell you congratulation for this job. > > I want to submit you a bug in the H2 database dll, produce by ikvm. > The necessaries ikvm.openjdk.*.dll used are: > ikvm.openjdk.Core.dll > ikvm.openjdk.Jdbc.dll > ikvm..openjdk.Text.dll > ikvm.openjdk.Util.dll > ikvm.openjdk.Runtime.dll > > The code below produce an exception during the execution of the > getConnection method: > '---------------------------------------------------------------------- > --- > Public Class Form1 > > Private Sub btTest_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btTest.Click > > Try > > org.h2.Driver.load() > > Dim cnt As org.h2.jdbc.JdbcConnection > > Dim h2ds As New org.h2.jdbcx.JdbcDataSource() > > h2ds.setURL("jdbc:h2:~/classicmodels/data") > > h2ds.setPassword("") > > h2ds.setUser("sa") > > cnt = h2ds.getConnection() > > cnt.close() > > Catch ex0 As java.lang.NullPointerException > > MessageBox..Show(ex0.getMessage) > > Catch ex1 As Exception > > MessageBox.Show(ex1.Message) > > End Try > > > > End Sub > > End Class > > '---------------------------------------------------------------------- > ---------------------------------------- > > > > FileNotFoundException can not be cast into Java.lang.Exception > > > > You will find the lastest H2 database jar file in attachment. > > The H2 database files exist on my hard drive, and i can use it with H2 > console. > > > > Could you do anything for me? > > > > Thank you > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Ikvm-developers mailing list Ikvm-developers@... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |
| Free embeddable forum powered by Nabble | Forum Help |