I am trying to generate CloudFormation file with C#.
Unfortunately whatever I pass as NetworkInterfaces in CfnInstance I get an error.
I Searched through the whole documentation and cannot find a solution to my problem.
Here is my C# Stack.
public class CFStack : Amazon.CDK.Stack
{
public CFStack(Construct parent, string id) : base(parent, id)
{
var vpc = new CfnVPC(this, "VPC", new CfnVPCProps()
{
CidrBlock = "10.0.0.0/16",
EnableDnsHostnames = true,
EnableDnsSupport = true,
InstanceTenancy = "default"
});
var sg = new CfnSecurityGroup(this, "SG", new CfnSecurityGroupProps()
{
GroupDescription = "CF Security group",
GroupName = "CF SG",
VpcId = vpc.Ref,
});
var subnet = new CfnSubnet(this, "Subnet", new CfnSubnetProps()
{
CidrBlock = "10.0.0.0/24",
MapPublicIpOnLaunch = true,
VpcId = vpc.Ref,
});
new CfnSecurityGroupIngress(this, "ingress", new CfnSecurityGroupIngressProps()
{
GroupId = sg.Ref,
FromPort = 3389,
ToPort = 3389,
CidrIp = "213.155.147.202/32",
IpProtocol = "tcp"
});
new CfnSecurityGroupEgress(this, "egress", new CfnSecurityGroupEgressProps()
{
GroupId = sg.Ref,
FromPort = 80,
ToPort = 444,
CidrIp = "0.0.0.0/0",
IpProtocol = "tcp",
});
var blockmapping = new CfnInstance.BlockDeviceMappingProperty()
{
DeviceName = "/dev/sdh",
Ebs = new CfnInstance.EbsProperty()
{
VolumeType = EbsDeviceVolumeType.GP2.ToString(),
DeleteOnTermination = true,
VolumeSize = 65,
}
};
var networkInterface = new CfnNetworkInterface(this, "NetworkInterface", new CfnNetworkInterfaceProps()
{
GroupSet = new[] { sg.ToString() },
SubnetId = subnet.Ref
});
new CfnInstance(this, "EC2", new CfnInstanceProps()
{
NetworkInterfaces = new[] { networkInterface },
BlockDeviceMappings = new[] { blockmapping },
ImageId = "ami-id",
InstanceType = "m5.xlarge",
KeyName = "keyName",
UserData = "test"
});
}
}
Unfortunately the stacktrace of the exception does not make things clear.
Here is the stacktrace itself:
Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Resolution error: Resolution error: Trying to resolve() a Construct at /Resources/${Token[MihailStack.EC2.LogicalID.32]}/Properties/networkInterfaces/0/node/_actualNode.
Object creation stack:
at new Intrinsic (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\private\intrinsic.js:20:44)
at new PostResolveToken (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\util.js:72:9)
at Object.ignoreEmpty (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\util.js:32:12)
at CfnInstance._toCloudFormation (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\cfn-resource.js:214:44)
at C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\stack.js:833:76
at Object.findTokens (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\private\resolve.js:126:13)
at Stack.findTokens (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\stack.js:833:42)
at Stack.prepare (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\stack.js:544:29)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:51
at Kernel._wrapSandboxCode (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8298:20)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:25
at Kernel._ensureSync (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8274:20)
at Kernel.invoke (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7664:26)
at KernelHost.processRequest (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7372:28)
at KernelHost.completeCallback (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7345:25)
at KernelHost.callbackHandler (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7326:33)
at Stack.value (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8012:41)
at Stack.onPrepare (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\construct-compat.js:66:14)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:51
at Kernel._wrapSandboxCode (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8298:20)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:25
at Kernel._ensureSync (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8274:20)
at Kernel.invoke (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7664:26)
at KernelHost.processRequest (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7372:28)
at KernelHost.completeCallback (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7345:25)
at KernelHost.callbackHandler (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7326:33)
at Stack.value (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8012:41)
at Node.prepare (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\constructs\lib\construct.js:371:27)
at Node.synthesize (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\constructs\lib\construct.js:333:14)
at Function.synth (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\construct-compat.js:165:26)
at App.synth (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\app.js:71:59)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:51
at Kernel._wrapSandboxCode (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8298:20)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:25
at Kernel._ensureSync (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8274:20)
at Kernel.invoke (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7664:26)
at KernelHost.processRequest (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7372:28)
at KernelHost.run (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7312:14)
at Immediate._onImmediate (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7315:37)
at processImmediate (internal/timers.js:439:21).
Object creation stack:
at new Intrinsic (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\private\intrinsic.js:20:44)
at new PostResolveToken (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\util.js:72:9)
at CfnInstance._toCloudFormation (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\cfn-resource.js:212:39)
at C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\stack.js:833:76
at Object.findTokens (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\private\resolve.js:126:13)
at Stack.findTokens (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\stack.js:833:42)
at Stack.prepare (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\stack.js:544:29)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:51
at Kernel._wrapSandboxCode (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8298:20)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:25
at Kernel._ensureSync (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8274:20)
at Kernel.invoke (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7664:26)
at KernelHost.processRequest (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7372:28)
at KernelHost.completeCallback (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7345:25)
at KernelHost.callbackHandler (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7326:33)
at Stack.value (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8012:41)
at Stack.onPrepare (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\construct-compat.js:66:14)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:51
at Kernel._wrapSandboxCode (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8298:20)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:25
at Kernel._ensureSync (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8274:20)
at Kernel.invoke (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7664:26)
at KernelHost.processRequest (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7372:28)
at KernelHost.completeCallback (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7345:25)
at KernelHost.callbackHandler (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7326:33)
at Stack.value (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8012:41)
at Node.prepare (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\constructs\lib\construct.js:371:27)
at Node.synthesize (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\constructs\lib\construct.js:333:14)
at Function.synth (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\construct-compat.js:165:26)
at App.synth (C:\Users\hmh\AppData\Local\Temp\jsii-kernel-lGLo4x\node_modules\#aws-cdk\core\lib\app.js:71:59)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:51
at Kernel._wrapSandboxCode (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8298:20)
at C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7665:25
at Kernel._ensureSync (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:8274:20)
at Kernel.invoke (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7664:26)
at KernelHost.processRequest (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7372:28)
at KernelHost.run (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7312:14)
at Immediate._onImmediate (C:\Users\hmh\AppData\Local\Temp\ys3l4mjc.q1n\jsii-runtime.js:7315:37)
at processImmediate (internal/timers.js:439:21)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_0`1.<InvokeInstanceMethod>b__1(IClient client, Object[] args)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceVoidMethod(Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.CDK.Stack.Prepare()
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_0`1.<InvokeInstanceMethod>b__1(IClient client, Object[] args)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceVoidMethod(Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.CDK.Construct.OnPrepare()
I have also tried to pass
NetworkInterfaces = networkInterface
NetworkInterfaces = networkInterface.ToString()
NetworkInterfaces = new[] {networkInterface}
NetworkInterfaces = new[] {networkInterface.ToString()}
If I remove NetworkInteraces property from CfnNetworkInterface the above code works fine.
I cannot understand what the problem is.
Everything I change results the same exception from the above.
Any help is greatly appreciated.
Thank you in advance.
I was able to recreate and fix the API problem using TypeScript. I was able to synthesize the stack. I believe the same is applicable in C#.
new CfnInstance(this, "EC2", {
networkInterfaces: [{
deviceIndex: '0',
groupSet: [sg.toString()],
subnetId: subnet.ref
}],
imageId: "ami-id",
instanceType: "t2.micro",
keyName: "keyName",
userData: "test"
});
The problem lies with the use of CfnNetworkInterface in CfnInstance. The property networkInterfaces in CfnInstance expects an array of type CfnInstance.NetworkInterfaceProperty or cdk.IResolvable. What you are providing to it right now (CfnNetworkInterface) mismatches with the expected type. I was also baffled to see that I wasn't able to import CfnInstance.NetworkInterfaceProperty in my TS code above, but was able to coerce object notation to IResolvable.
Also note that, when you use CfnInstance.NetworkInterfaceProperty you also have to provide the deviceIndex. Hopefully, this will solve your problem in C# code.
PS: I have removed the blockDeviceMappings from my approach for brevity
Related
I'm looking at this https://book.solmeet.dev/notes/intro-to-anchor written according to the code in the textbook:
TypeError: provider.send is not a function when await provider.send()
import * as anchor from '#project-serum/anchor';
import { Program } from '#project-serum/anchor';
import { AnchorEscrow } from '../target/types/anchor_escrow';
import { PublicKey, SystemProgram, Transaction } from '#solana/web3.js';
import { TOKEN_PROGRAM_ID, Token } from "#solana/spl-token";
import { assert } from "chai";
describe('anchor-escrow', () => {
// Configure the client to use the local cluster.
const provider = new anchor.getProvider();
anchor.setProvider(provider);
const program = anchor.workspace.AnchorEscrow as Program<AnchorEscrow>;
let mintA = null;
let mintB = null;
let initializerTokenAccountA = null;
let initializerTokenAccountB = null;
let takerTokenAccountA = null;
let takerTokenAccountB = null;
let vault_account_pda = null;
let vault_account_bump = null;
let vault_authority_pda = null;
const takerAmount = 1000;
const initializerAmount = 500;
const escrowAccount = anchor.web3.Keypair.generate();
const payer = anchor.web3.Keypair.generate();
const mintAuthority = anchor.web3.Keypair.generate();
const initializerMainAccount = anchor.web3.Keypair.generate();
const takerMainAccount = anchor.web3.Keypair.generate();
it("Initialize program state", async () => {
// Airdropping tokens to a payer.
await provider.connection.confirmTransaction(
await provider.connection.requestAirdrop(payer.publicKey, 10000000000),
"confirmed"
);
// ⚠️ An error has occurred here
await provider.send(
(() => {
const tx = new Transaction();
tx.add(
SystemProgram.transfer({
fromPubkey: payer.publicKey,
toPubkey: initializerMainAccount.publicKey,
lamports: 100000000,
}),
SystemProgram.transfer({
fromPubkey: payer.publicKey,
toPubkey: takerMainAccount.publicKey,
lamports: 100000000,
})
);
return tx;
})(),
[payer]
);
});
then run anchor test
Warning: cargo-build-bpf is deprecated. Please, use cargo-build-sbf
cargo-build-bpf child: /Users/yjy/.local/share/solana/install/active_release/bin/cargo-build-sbf --arch bpf
Error: Function _ZN13anchor_escrow9__private8__global8exchange17hb34dfff05db149f5E Stack offset of 4096 exceeded max offset of 4096 by 0 bytes, please minimize large stack variables
Finished release [optimized] target(s) in 0.34s
Found a 'test' script in the Anchor.toml. Running it as a test suite!
Running test suite: "/Users/yjy/Documents/Code/solana/anchor-projects/anchor-escrow/Anchor.toml"
yarn run v1.22.18
warning package.json: No license field
$ /Users/yjy/Documents/Code/solana/anchor-projects/anchor-escrow/node_modules/.bin/ts-mocha -p ./tsconfig.json -t 1000000 'tests/**/*.ts'
anchor-escrow
1) Initialize program state
✔ Initialize escrow
✔ Exchange escrow state
✔ Initialize escrow and cancel escrow
3 passing (598ms)
1 failing
1) anchor-escrow
Initialize program state:
TypeError: provider.send is not a function
at /Users/yjy/Documents/Code/solana/anchor-projects/anchor-escrow/tests/anchor-escrow.ts:45:20
at Generator.next (<anonymous>)
at fulfilled (tests/anchor-escrow.ts:28:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
How can I solve this problem?
It looks like send doesn't exist, but you can use sendAndConfirm if you want to confirm the transction too, or sendAll if you just want to send. That takes an array of Transactions, so you can do:
const tx = new Transaction();
tx.add(
SystemProgram.transfer({
fromPubkey: payer.publicKey,
toPubkey: initializerMainAccount.publicKey,
lamports: 100000000,
}),
SystemProgram.transfer({
fromPubkey: payer.publicKey,
toPubkey: takerMainAccount.publicKey,
lamports: 100000000,
})
);
await provider.sendAll([{tx, signers: [payer]}]);
I have Xamarin Forms app supporting iOS and Android. It works correctly on Android in release mode. On iOS, it doesn't work in release mode but works in Debug mode. It's crashing when clicked on a button which calls few functions. I have attached error log below. The strange thing is, it works on Simulator in release mode.
Error log:
Incident Identifier: 391C564C-028D-4084-BC4A-21ED49BB1F25
CrashReporter Key: 30B4418D-AA04-4575-97A3-97A9F491C62D
Hardware Model: iPhone7,2
Process: TestApp.iOS [600]
Path: /var/containers/Bundle/Application/7F4E5392-9BEA-4578-9E23-02112B61EB96/TestApp.iOS.app/TestApp.iOS
Identifier: uk.co.company.testapp
Version: 0.0.1 (1.0)
Code Type: ARM-64
Parent Process: ??? [1]
Date/Time: 2018-01-22T13:02:31Z
Launch Time: 2018-01-22T13:02:23Z
OS Version: iPhone OS 9.3.2 (13F69)
Report Version: 104-Xamarin
Exception Type: SIGABRT
Exception Codes: #0 at 0x180da811c
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'System.ArgumentNullException', reason: 'System.ArgumentNullException: Value cannot be null.'
Xamarin Exception Stack:
Parameter name: method
at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Collections.Generic.IEnumerable`1[T] arguments) [0x00111] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:1239
at System.Linq.Expressions.Expression.Call (System.Linq.Expressions.Expression instance, System.Reflection.MethodInfo method, System.Linq.Expressions.Expression[] arguments) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:1046
at System.Linq.Expressions.Expression.Call (System.Reflection.MethodInfo method, System.Linq.Expressions.Expression[] arguments) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:1001
at System.Dynamic.ExpandoObject+MetaExpando.BindSetMember (System.Dynamic.SetMemberBinder binder, System.Dynamic.DynamicMetaObject value) [0x00033] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/ExpandoObject.cs:863
at System.Dynamic.SetMemberBinder.Bind (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject[] args) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/SetMemberBinder.cs:57
at System.Dynamic.DynamicMetaObjectBinder.Bind (System.Object[] args, System.Collections.ObjectModel.ReadOnlyCollection`1[T] parameters, System.Linq.Expressions.LabelTarget returnLabel) [0x000c6] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/DynamicMetaObjectBinder.cs:90
at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T] (System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00019] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at System.Runtime.CompilerServices.CallSiteOps.Bind[T] (System.Runtime.CompilerServices.CallSiteBinder binder, System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00000] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Exception source) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:156
at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:172
at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs:327
at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63
at System.Linq.Expressions.Interpreter.LightLambda.Run3[T0,T1,T2,TRet] (T0 arg0, T1 arg1, T2 arg2) [0x00038] in <8bc31b0df50a4d32b3f1d5af764165ad>:0
at TestApp.LoginPage+<onLoginClicked>d__1.MoveNext () [0x00205] in <42b3f78eef3b4fad8ca201e1a739e68b>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/Foundation/NSAction.cs:163
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5665/f70a1348/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at TestApp.iOS.Application.Main (System.String[] args) [0x00000] in <52e34ea9026340479b8dc6a53c640f1e>:0
EDIT:
I have an interesting finding. I'm calling onLoginClicked function on the touch of a button, which then calls PostData function which makes a REST Call to send data to the server. Whenever the PostData function is called, app crashes.
If I move all the code from PostData function to onLoginClicked function, it works!
Please find additional information below:
I tried cleaning and rebuilding the solution but, it didn't work.
There is no point in putting break points on each line in the PostData method as the app is crashing only in release mode, but works in debug mode.
The app crashes in onLoginClicked method at a line where PostData function is called i.e.
string responseData = await PostData(user, "auth/login");
When I tried putting some alerts in PostData function to see what
point it reaches but found that it doesn't even hit the very first
line in that method. This is very strange.
Code:
async void onLoginClicked(object sender, System.EventArgs e)
{
string error = "";
if (txtEmail.Text == null || txtEmail.Text == "")
{
error += Constants.ERR_BLANK_EMAIL + "\r\n";
}
else if (txtEmail.Text.Length < 6)
{
error += Constants.ERR_EMAIL_LENGTH + "\r\n";
}
else if (!Common.isEmailValid(txtEmail.Text))
{
error += Constants.ERR_EMAIL_VALIDATION + "\r\n";
}
if (txtPassword.Text == null || txtPassword.Text == "")
{
error += Constants.ERR_BLANK_PASSWORD;
}
if (error != "")
{
lblError.Text = error;
errorContainer.IsVisible = true;
return;
}
else
{
errorContainer.IsVisible = false;
}
if (CrossConnectivity.Current.IsConnected)
{
var loadingPage = new LoadingPage();
await Navigation.PushPopupAsync(loadingPage);
var device_token = App.channelId;
dynamic user = new System.Dynamic.ExpandoObject();
user.email = txtEmail.Text;
user.user_type = "b2b";
user.device_token = device_token;
user.password = txtPassword.Text;
if (Device.RuntimePlatform == Device.iOS)
{
user.device_type = "ios";
}else{
user.device_type = "android";
}
string responseData = await PostData(user, "auth/login");
dynamic responseObj = JObject.Parse(responseData);
if (responseObj["error_code"].Value == 0)
{
var data = responseObj["data"];
Constants.user = Common.GetUserObject(data.ToString());
Helpers.Settings.Password = "" + txtPassword.Text;
Helpers.Settings.UserId = "" + Constants.user.userId;
Helpers.Settings.accessToken = ""+data.access_token;
Helpers.Settings.Email = "" + txtEmail.Text;
var outletResp = responseObj["outlet_details"];
var outlet_count = outletResp.Count;
if(outlet_count>0)
{
Constants.outlets = new List<Outlet>();
foreach(var store in outletResp){
Outlet shop = new Outlet();
shop.access_token = store["access_token"];
shop.email = store["email"];
shop.user_id = store["id"];
shop.master_id = store["master_id"];
shop.outlet_id = store["outlet_id"];
shop.post_code = store["post_code"];
shop.profile_pic = store["profile_pic"];
shop.retailer_id = store["retailer_id"];
shop.retailer_image = store["retailer_image"];
shop.store_name = store["store_name"];
shop.tutorial_pricing_tool = int.Parse(""+store["tutorial_pricing_tool"]);
Constants.outlets.Add(shop);
}
}
var isPinSet = Helpers.Settings.PinSet;
await Navigation.RemovePopupPageAsync(loadingPage);
if (responseObj.data.pin==0 || !isPinSet){
App.Current.MainPage = new NavigationPage(new SetPinPage(false));
}
else{
App.Current.MainPage = new NavigationPage(new StoreListPage());
}
}
else
{
await Navigation.RemovePopupPageAsync(loadingPage);
if (responseObj["error_code"].Value == 1)
lblError.Text = responseObj["error"];
else
lblError.Text = responseObj["message"];
errorContainer.IsVisible = true;
}
}
else
{
await DisplayAlert(Constants.APP_TITLE, "Please check your internet connection.", "OK");
}
}
async public Task<string> PostData(System.Dynamic.ExpandoObject args, string actionUrl)
{
string responseData = "";
HttpClient client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;
var param = Constants.JWT ? GetJWTToken(args, actionUrl) : JsonConvert.SerializeObject(args);
var content = new StringContent(param, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", param);
client.DefaultRequestHeaders.Add("X-Device-Type", "android");
client.DefaultRequestHeaders.Add("X-APP-Type", "b2b");
client.DefaultRequestHeaders.Add("X-APP-Platform", "xamarin");
HttpResponseMessage response = null;
response = await client.PostAsync(Constants.BaseUrl + actionUrl, content);
if (response.IsSuccessStatusCode)
{
response.EnsureSuccessStatusCode();
}
responseData = await response.Content.ReadAsStringAsync();
if (Constants.JWT)
{
var resp = JObject.Parse(responseData);
var respToken = resp["token"];
var rtokenStr = respToken.ToObject<String>();
var respPayloadStr = rtokenStr.Split('.');
byte[] data = JWTLibrary.Converter.Base64UrlDecode(respPayloadStr[1]);
responseData = JWTLibrary.Converter.GetStringFromBytes(data);
}
return responseData;
}
private string GetJWTToken(System.Dynamic.ExpandoObject args, string actionUrl)
{
var dt = DateTime.Now;
var ticks = dt.Ticks;
var currentSec = ticks / TimeSpan.TicksPerSecond;
var newEndTime = currentSec + 60;
Object payload = new Dictionary<string, object>()
{
{ "iat", currentSec },
{ "nbf", currentSec },
{ "exp", newEndTime },
{ "iss", actionUrl },
{ "jti", "" },
{ "bat_data", args }
};
var secret_key = "key";
dynamic n_header = new System.Dynamic.ExpandoObject();
n_header.typ = "jwt";
n_header.alg = "HS256";
byte[] headerBytes = JWTLibrary.Converter.GetBytesFromString(JsonConvert.SerializeObject(n_header));
byte[] payloadBytes = JWTLibrary.Converter.GetBytesFromString(JsonConvert.SerializeObject(payload));
var enc_header = JWTLibrary.Converter.Base64UrlEncode(headerBytes);
var enc_payload = JWTLibrary.Converter.Base64UrlEncode(payloadBytes);
string jwt_token = enc_header + "." + enc_payload;
var sh_h256 = JWTLibrary.Converter.CreateToken(jwt_token, secret_key);
var jwt_enc_signature = JWTLibrary.Converter.Base64UrlEncode(sh_h256);
jwt_token = jwt_token + "." + jwt_enc_signature;
return jwt_token;
}
I'm afraid the problem was caused by dynamic keyword.
The DynamicMethod class is a part of the set of runtime code generation features that reside with System.Reflection.Emit. However,System.Reflection.Emit API is not available in iOS.
Detail refer to Why can’t I use the “dynamic” C# keyword in Xamarin.iOS?
I am new to java.We have a few tabled valued parameter used in one of our stored procedure when we try with below code then we are getting following error.
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near
'{'.
import java.sql.*;
import com.microsoft.sqlserver.jdbc.SQLServerDataTable; import
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
public class DB_SP_Call {
Connection conn = null;
Statement stmt = null;
String dbserver="10.42..:1198";
String db="t1c";
String USER="t1c";
String PWD="t1c";
String sql; static final String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; public void
runSP(){
String DB_URL = "jdbc:sqlserver://"+dbserver+";databaseName="+db; try{
Class.forName(JDBC_DRIVER);
//STEP 3: Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PWD);
System.out.println("Creating statement...");
stmt = conn.createStatement();
//SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement)conn.prepareStatement("{call exec
t1c.scnTargetingBYO
#InstrID=?,#CAS=?,#PageNum=?,#PageSize=?,#SortField=?,#TotalRecNum=?
output,#OutputFirmFund=?,#Download=?,#FirmContactData=?,#FirmList=?,#CustTagList=?,#LocationList=?,#Orientation=?,#InvTypeIDList=?,#InvStyleIDList=?,#AdvisoryList=?,#SocialyResposible=?,#TurnoverList=?,#SecurityActivity=?,#InstWithUpside=?,#MarketCapPass=?,#PNI=?,#EventFirmMet=?,#EventType=?,#CorpParticipant=?,#SectorList=?,#GeoIDList=?,#MarketCapStr=?,#HoldType=?,#ActThreshold=?,#SavedDataFlag=?
output,#DisplayGroupFlag=?,#PerPeerFlag=?,#UserId=?,#AccountID=?}");
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement)conn.prepareStatement("{ call exec
t1c.scnTargetingBYO
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
}");
pstmt.setInt(1, 264998);
pstmt.setString(2, "P");
pstmt.setInt(3,0);
pstmt.setInt(4, 100);
pstmt.setString(5, "Pos DESC");
pstmt.setInt(6, 2308);
pstmt.setInt(7,0);
pstmt.setInt(8, 0);
pstmt.setInt(9, 0);
SQLServerDataTable p10 = new SQLServerDataTable();
p10.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p10.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
pstmt.setStructured(10, "t1c.InvIDTabType", p10);
SQLServerDataTable p11 = new SQLServerDataTable();
p11.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p11.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
pstmt.setStructured(11, "t1c.InvIDTabType", p11);
SQLServerDataTable p12 = new SQLServerDataTable();
p12.addColumnMetadata("LocationID",java.sql.Types.NUMERIC);
p12.addColumnMetadata("LocationTypeID",java.sql.Types.NUMERIC);
Object[] row= new Object[2];
row[0]=new Integer(10006);
row[1]=new Integer(5);
p12.addRow(row);
pstmt.setStructured(12, "t1c.LocationList", p12);
pstmt.setInt(13,1);
SQLServerDataTable p14 = new SQLServerDataTable();
p14.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p14.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
p14.addColumnMetadata("Lev",java.sql.Types.NUMERIC);
Object[] row1= new Object[3];
row1[0]=new Integer(200);
row1[1]=null;
row1[2]=new Integer(2);
p14.addRow(row1);
Object[] row2= new Object[3];
row2[0]=new Integer(600);
row2[1]=null;
row2[2]=new Integer(1);
p14.addRow(row2);
Object[] row3= new Object[3];
row3[0]=new Integer(100);
row3[1]=null;
row3[2]=new Integer(2);
p14.addRow(row3);
Object[] row4= new Object[3];
row4[0]=new Integer(500);
row4[1]=null;
row4[2]=new Integer(1);
p14.addRow(row4);
Object[] row5= new Object[3];
row5[0]=new Integer(300);
row5[1]=null;
row5[2]=new Integer(2);
p14.addRow(row5);
pstmt.setStructured(14, "t1c.InvIDTabType2", p14);
SQLServerDataTable p15 = new SQLServerDataTable();
p15.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p15.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
p15.addColumnMetadata("Lev",java.sql.Types.NUMERIC);
pstmt.setStructured(15, "t1c.InvIDTabType2", p15);
pstmt.setInt(16,0);
pstmt.setString(17,"NULL");
SQLServerDataTable p18 = new SQLServerDataTable();
p18.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p18.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
pstmt.setStructured(18, "t1c.InvIDTabType", p18);
pstmt.setInt(19,0);
pstmt.setInt(20,0);
pstmt.setInt(21,0);
pstmt.setInt(22,0);
pstmt.setInt(23,3);
SQLServerDataTable p24 = new SQLServerDataTable();
p24.addColumnMetadata("EventID",java.sql.Types.NUMERIC);
p24.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p24.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
pstmt.setStructured(24, "cms.EvtLinkTabType", p24);
SQLServerDataTable p25 = new SQLServerDataTable();
p25.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p25.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
pstmt.setStructured(25, "t1c.InvIDTabType", p25);
SQLServerDataTable p26 = new SQLServerDataTable();
p26.addColumnMetadata("Type",java.sql.Types.VARCHAR);
p26.addColumnMetadata("ID",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID3",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID4",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID5",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID6",java.sql.Types.NUMERIC);
p26.addColumnMetadata("ID7",java.sql.Types.NUMERIC);
pstmt.setStructured(26, "t1c.InvSpecialIDTabType2", p26);
SQLServerDataTable p27 = new SQLServerDataTable();
p27.addColumnMetadata("Type",java.sql.Types.VARCHAR);
p27.addColumnMetadata("ID",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID1",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID2",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID3",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID4",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID5",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID6",java.sql.Types.NUMERIC);
p27.addColumnMetadata("ID7",java.sql.Types.NUMERIC);
pstmt.setStructured(27, "t1c.InvSpecialIDTabType2", p27);
pstmt.setString(28,"NULL");
pstmt.setInt(29,1);
SQLServerDataTable p30 = new SQLServerDataTable();
p30.addColumnMetadata("Category", java.sql.Types.VARCHAR);
p30.addColumnMetadata("ActType", java.sql.Types.NUMERIC);
p30.addColumnMetadata("Threshold", java.sql.Types.VARCHAR);
p30.addColumnMetadata("Min", java.sql.Types.NUMERIC);
p30.addColumnMetadata("Max", java.sql.Types.NUMERIC);
Object[] row6= new Object[5];
row6[0]=new String("O");
row6[1]=new Integer(0);
row6[2]=new String("S");
row6[3]=new Integer(1);
row6[4]=null;
p30.addRow(row6);
Object[] row7= new Object[5];
row7[0]=new String("F");
row7[1]=null;
row7[2]=new String("E");
row7[3]=new Integer(5);
row7[4]=null;
p30.addRow(row7);
pstmt.setStructured(30, "t1c.InvActThresholdTabType", p30);
pstmt.setInt(31,2);
pstmt.setInt(32,2946);
pstmt.setInt(33,0);
pstmt.setInt(34,234568);
pstmt.setInt(35,21022);
ResultSet rs = pstmt.executeQuery();
//ResultSet rs = pstmt.execute();
ResultSetMetaData metaData = rs.getMetaData();
//System.out.println("Hi, fetching resultset.........");
System.out.println(metaData.getColumnCount());
while(rs.next()){
int intdata = rs.getInt("LgcyInvestorID");
System.out.println(intdata);
}
}catch(Exception e){ e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
stmt.close();
}
catch(SQLException se2)
{
}// nothing we can do
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end finally try
}
}
public static void main(String[] args) {
DB_SP_Call dbcall= new DB_SP_Call();
dbcall.runSP(); }
}
Request experts to please help in this regard.
I do not have a lot of experience with deploying applications.
I have an ASP.Net Application from which I perform a call over HTTPS to a third party web service. The webservice returns an xml string which I then parse on my side. On my development environment, this works perfectly. However, when I deploy the application (to a production VM), the webservice inexplicably does not return anything and my parsing step throws a null reference exception.
More information on the production environment:
I provisioned an Azure VM running Windows Server 2008, and published my application directly from Visual Studio 2013 to the VM. I am hosting the application on IIS 7.5 within the DefaultAppPool.
I am able to browse the wsdl for the webservice via IE from the VM (via remote desktop connection)
I have tried installing the https certificate under trusted certificate authorities > local on the VM, and then ran IISRESET.
I have tried to turn off the firewall on the VM completely, but still the service call fails.
The third party service provider has confirmed that they are not seeing any traffic come through from my site.
When I run the application from my dev environment, but use the production databases, it still works, so it is definitely not an issue with my data [UPDATE]
The service call seems to be failing silently as the event log only lists the null reference exception, nothing specifically pertaining to the service call.
What am I missing?
UPDATE:
public void RunEnquiry(Client Client, string ResultType = "XPDF")
{
NormalSearch_Live_Service.NormalSearchServiceClient csClient = new NormalSearch_Live_Service.NormalSearchServiceClient();
using (var db = new CreditBureauxDbContext())
{
// --== Step 1: Create the enquiry data-entities ==--
var eb = new EnquiryBlock
{
CS_Data = "Y",
CPA_Plus_NLR_Data = "N",
Deeds_Data = "N",
Directors_Data = "N",
Identity_number = Client.Person.IDNumber.Truncate(13),
Surname = Client.Person.Surname.Truncate(25),
Forename = Client.Person.FullNames.Trim().Split(' ').Count() > 0 ? Client.Person.FullNames.Trim().Split(' ')[0].Truncate(15) : "",
Forename2 = Client.Person.FullNames.Trim().Split(' ').Count() > 1 ? Client.Person.FullNames.Trim().Split(' ')[1].Truncate(15) : "",
Forename3 = Client.Person.FullNames.Trim().Split(' ').Count() > 2 ? Client.Person.FullNames.Trim().Split(' ')[2].Truncate(15) : "",
Gender = Client.Person.Gender.Truncate(1),
Passport_flag = "N",
DateOfBirth = DateTime.Parse(Client.Person.DateOfBirthUTC).ToString("yyyyMMdd"),
Address1 = "",
Address2 = "",
Address3 = "",
Address4 = "",
PostalCode = "",
HomeTelCode = "",
HomeTelNo = "",
WorkTelCode = "",
WorkTelNo = "",
CellTelNo = "",
ResultType = ResultType,
RunCodix = "N",
Adrs_Mandatory = "N",
Enq_Purpose = db.EnquiryPurposes.FirstOrDefault(ep => ep.Description.ToUpper().Contains("CREDIT ASSESSMENT")).Value,
Run_CompuScore = "N",
ClientConsent = "Y"
};
var enq = new Enquiry
{
pInput_Format = "XML",
pOrigin = "CrediScan",
pOrigin_Version = "1.0",
pVersion = "1.0",
Parameters = eb,
RequestSent_TimestampUTC = DateTime.UtcNow.ToString()
};
using (var settings = new GlobalConfigDbContext())
{
// --== Step 2: Construct & perform service call ==--
var param = new NormalSearch_Live_Service.NormalEnqRequestParamsType
{
pInput_Format = "XML",
pOrigin = "CrediScan",
pOrigin_Version = "1.0",
pUsrnme = settings.GetSettingValueAsString("Credit Check: PROD Username"),
pPasswrd = settings.GetSettingValueAsString("Credit Check: PROD Password"),
pVersion = "1.0",
pTransaction = String.Format("<Transactions>{0}</Transactions>", eb.ToXML())
};
var result = csClient.DoNormalEnquiry(param);
// --== Step 3: Create enquiry result data-entities ==--
var er = new EnquiryResult
{
ErrorCode = result.errorCode,
ErrorString = result.errorString,
TransactionCompleted = result.transactionCompleted,
RetData = result.retData
};
enq.EnquiryResult = er;
Trace.TraceInformation("RETDATA" + Environment.NewLine + result.retData);
var retDataDecoded = result.retData.DecodeBase64ToByteArray();
if (!Encoding.UTF8.GetString(retDataDecoded, 0, 2).Equals("PK") || retDataDecoded.Length <= 5)
throw new FormatException("The data returned from CreditBureaux is not in the correct format or contains an error.");
// --== Step 4: Save the query and validated results to database ==--
try
{
db.Enquiries.Add(enq);
db.SaveChanges();
}
catch (DbEntityValidationException dbe)
{
Trace.TraceError(dbe.ToString());
throw;
}
// --== Step 5: Parse the results ==--
if (ResultType.Equals("XML"))
{
if (!Encoding.UTF8.GetString(retDataDecoded, 0, 2).Equals("PK") || retDataDecoded.Length <= 5)
throw new FormatException("The data returned from CreditBureaux is not in the correct format or contains an error.");
Trace.TraceInformation("\n\n\n" + retDataDecoded.UnZipToMemoryList()[0].ReadToString() + "\n\n\n");
}
if (ResultType.Equals("XPDF"))
{
Trace.TraceInformation("UNZIPPING PDF");
Trace.TraceInformation("RETDATA" + Environment.NewLine + result.retData);
var xmlDoc = XDocument.Parse("<?xml version=\"1.0\"?>" + retDataDecoded.UnZipToMemoryList()[0].ReadToString()); //Important!
var summaryItems = xmlDoc
.Root
.Element("EnqCC_ENQ_COUNTS")
.Element("ROW")
.Elements()
.Select(dn => new EnquirySummaryItem
{
Key = dn.Name.ToString(),
Value = dn.Value
})
.ToList();
var summary = new EnquirySummary
{
Enquiry_Id = xmlDoc.Root.Element("Enquiry_ID").Value,
EnquiryDate = xmlDoc.Root.Element("EnqCC_SRCHCRITERIA").Descendants("ENQ_DATE").ElementAt(0).Value,
EnquiryResult = enq.EnquiryResult,
SummaryItems = summaryItems
};
try
{
db.EnquirySummaries.Add(summary);
db.SaveChanges();
}
catch (DbEntityValidationException dbe)
{
Trace.TraceError(dbe.ToString());
throw;
}
var directory = settings.GetSettingValueAsString("Document Management: Client Documents Root Path").TrimEnd('\\') + "\\CreditBureaux\\" ;
var fileName = summary.Enquiry_Id + ".pdf";
FileHandlingFactory.Create().SaveFile(xmlDoc.Root.Element("CC_PDF_RESULTS").Value.DecodeBase64ToByteArray().ToMemoryStream(), directory, fileName);
docMan.Add_Document(
new FileItem {
CreatedOn_TimeStampUTC = DateTime.UtcNow,
FilePathOnServer = directory,
PrivateFileName = fileName,
PublicFileName = (Client.Person.Surname + Client.Person.NickName[0]) + "_" + fileName,
MimeType = "application/pdf"
},
docMan.FindOrCreate_ContextInstance(
docMan.Get_ContextClass("Client"),
new Dictionary<string, string>(){
{"ClientId",Client.Id.ToString()}
}),
new List<DocumentClass> { docMan.Get_DocumentClass("CreditBureaux enquiry") });
//xmlDoc.Root.Element("CC_PDF_RESULTS").Value
//.DecodeBase64ToByteArray()
//.SaveToFile(directory, summary.Enquiry_Id + ".pdf");
}
}
}
}
The stack trace to follow:
Server Error in '/' Application.
Value cannot be null. Parameter name: s
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: s
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Value cannot be null. Parameter name: s]
System.Convert.FromBase64String(String s) +14073970
SomeCompany.CreditBureaux.BLL.CreditBureauxLiveClient.RunEnquiry(Client
Client, String ResultType) +2270
SomeCompany.CrediScan.UI.Views.ClientController.CreditCheck(Int64 id)
+264 lambda_method(Closure , ControllerBase , Object[] ) +114 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary2 parameters) +242
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor actionDescriptor, IDictionary2
parameters) +39
System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult
asyncResult, ActionInvocation innerInvokeState) +12
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult
asyncResult) +139
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
+112 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
+452 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
+37 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult
asyncResult) +241
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +19
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
I am new to developing iOS client for Google App Engine backend. I encounter an issue where i was able to communicate with the backend but unable to insert a new record into the datastore.
Here is the code for the backend
#ApiMethod(name = "insertDCustomerRecord")
public DCustomerRecord insertDCustomerRecord(DCustomerRecord dcustomerrecord) {
EntityManager mgr = getEntityManager();
try {
//Object pass in is JSON format, convert to object instance
DCustomerRecord newRecord = new DCustomerRecord(dcustomerrecord.getNRIC(), dcustomerrecord.getContactNumber());
if (containsDCustomerRecord(newRecord)) {
throw new EntityExistsException("Object already exists");
}
mgr.persist(newRecord);
} finally {
mgr.close();
}
return dcustomerrecord;
}
here is the code for the ios client
- (void) initView {
GRGServiceManager* manager = [GRGServiceManager getInstance];
GTLServiceDcustomerrecordendpoint* service = [manager getDCustomerRecordService];
GTLDcustomerrecordendpointDCustomerRecord* newRecord = [[GTLDcustomerrecordendpointDCustomerRecord alloc] init];
[newRecord setNric:#"1234567A"];
[newRecord setContactNumber:#"12344574"];
GTLQueryDcustomerrecordendpoint* query = [GTLQueryDcustomerrecordendpoint queryForInsertDCustomerRecordWithObject:newRecord];
[service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLObject *object, NSError *error) {
NSLog(#"Inserted new object");
}];
}
Here is the entity class
#Entity
public class DCustomerRecord {
/**
* #description this is the primary key of the record, it is auto-generated
*/
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
public Key getId() {
return id;
}
/**
* #description this is to store the NRIC of the customer
*/
private String m_sNRIC;
public String getNRIC() {
if(m_sNRIC == null)
m_sNRIC = "";
return m_sNRIC;
}
public void setNRIC(String nric) {
m_sNRIC = new String(nric);
}
/**
* #description this is to store the contact number of the customer
*/
private String m_sContactNumber;
public String getContactNumber() {
if(m_sContactNumber == null)
m_sContactNumber = "";
return m_sContactNumber;
}
public void setContactNumber(String contact) {
m_sContactNumber = new String(contact);
}
/**
* #description this is to store the number of lucky draw chance this customer has
*/
private Integer m_nNumberOfLuckyDraw;
public int getNumberOfLuckyDraw() {
if(m_nNumberOfLuckyDraw == null)
m_nNumberOfLuckyDraw = 0;
return m_nNumberOfLuckyDraw;
}
public void setNumberOfLuckyDraw(int newNumber) {
m_nNumberOfLuckyDraw = new Integer(newNumber);
}
/**
* #description this is to store the number of passcode redemption this customer has made
*/
private Integer m_nNumberOfPasscodeRedemption;
public int getNumberOfPasscodeRedemption() {
if(m_nNumberOfPasscodeRedemption == null)
m_nNumberOfPasscodeRedemption = 0;
return m_nNumberOfPasscodeRedemption;
}
public void setNumberOfPasscodeRedemption(int newNumber) {
m_nNumberOfPasscodeRedemption = new Integer(newNumber);
}
/**
* #description this is to store the number of photo taken by this customer
*/
private Integer m_nNumberOfPhotoTaken;
public int getNumberOfPhotoTaken() {
if(m_nNumberOfPhotoTaken == null)
m_nNumberOfPhotoTaken = 0;
return m_nNumberOfPhotoTaken;
}
public void setNumberOfPhotoTaken(int newNumber) {
m_nNumberOfPhotoTaken = new Integer(newNumber);
}
/**
* #description this is to store the the time stamp in which the record is created
*/
private Long m_nDateCreated;
public long getDateCreated() {
if(m_nDateCreated == null)
m_nDateCreated = 0L;
return m_nDateCreated;
}
public void setDateCreated(long date) {
m_nDateCreated = new Long(date);
}
/**
* #description this is to store the time stamp is which the record last communicate with server
*/
private Long m_nLastUpdated;
public long getLastUpdated() {
if(m_nLastUpdated == null)
m_nLastUpdated = 0L;
return m_nLastUpdated;
}
public void setLastUpdated(long date) {
m_nLastUpdated = new Long(date);
}
/**
* #description the default constructor
* #param nric - NRIC of the customer
* #param contactNumber - the contact number of the customer
*/
public DCustomerRecord(String nric, String contactNumber) {
//Initialization
setNRIC(nric);
setContactNumber(contactNumber);
setNumberOfLuckyDraw(0);
setNumberOfPasscodeRedemption(0);
setNumberOfPhotoTaken(0);
setDateCreated(System.currentTimeMillis());
setLastUpdated(System.currentTimeMillis());
}
}
The error may or may not help, but this is what is shown in the Eclipse console when i run the iOS app connecting to the local version of the backend server.
Aug 16, 2014 7:51:23 PM com.google.api.server.spi.SystemService invokeServiceMethod
INFO: cause={0}
java.lang.NullPointerException
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:318)
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:256)
at com.grg.database.record.DCustomerRecordEndpoint.containsDCustomerRecord(DCustomerRecordEndpoint.java:170)
at com.grg.database.record.DCustomerRecordEndpoint.insertDCustomerRecord(DCustomerRecordEndpoint.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:490)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Aug 16, 2014 7:51:23 PM com.google.api.server.spi.SystemService invokeServiceMethod
SEVERE: null
java.lang.NullPointerException
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:318)
at org.datanucleus.api.jpa.JPAEntityManager.find(JPAEntityManager.java:256)
at com.grg.database.record.DCustomerRecordEndpoint.containsDCustomerRecord(DCustomerRecordEndpoint.java:170)
at com.grg.database.record.DCustomerRecordEndpoint.insertDCustomerRecord(DCustomerRecordEndpoint.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:490)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
To my knowledge, the error is caused by the a dcustomerrecord with all fields set to null that is passed into my insertDCustomerRecord in the backend server. I have tried debugging the server and my assumptions seems to be right.
Has anyone encounter this problem before? Can anyone help with this error? I believe i may have left out something important in the code but I am not sure where to begin. I have been Googling this problem for a few days now but with no luck. Thanks in advance!
Rather than wasting time trying debug the problem, I have instead used JSON objects to communicate with the iOS client which works perfectly so far. This is not the first problem with endpoint libraries I have faced while developing for Android and iOS. 1 other problem was the need to edit the endpoint, specifically the insert and contains functions because the auto-generated code took in the wrong argument when communicating with an Android client. Its also a hassle to ensure each servlet has to be defined properly in the Servlet-Path in the xml files since Google App Engine does not support Servlet 3.0.
Until Google make their endpoint library "smarter", I strongly recommend using JSON passing for Google App Engine development.