How to build your own tabs in MvvmCross? - android-fragments

I'm trying to build my own tabs in MonoDroid and MvvmCross.
The reason for building my own tabs is so that I can have further control over them. I want them on every screen even if they aren't in the tabs, I want to control clicks on certain tabs.
Loading the two Fragments on the page is fine, however when I click a button that is on either the tab fragment or content fragment that navigates to the next content fragment I am getting the error message "An unhandled exception occured." which isn't so helpful.
02-06 10:15:13.947 W/dalvikvm( 2040): JNI WARNING: JNI method called with exception pending
02-06 10:15:13.947 W/dalvikvm( 2040): in Lcirrious/mvvmcross/droid/fragging/MvxEventSourceFragmentActivity;.n_startActivityForResult:(Landroid/content/Intent;I)V (NewString)
In mgmain JNI_OnLoad
02-06 10:15:13.947 W/dalvikvm( 2040): Pending exception is:
02-06 10:15:13.947 I/dalvikvm( 2040): android.content.ActivityNotFoundException: Unable to find explicit activity class {frags.droid/frags.droid.views.frags.ChildTwoView}; have you declared this activity in your AndroidManifest.xml?
02-06 10:15:13.947 I/dalvikvm( 2040): (raw stack trace not found)
02-06 10:15:13.947 I/dalvikvm( 2040): "main" prio=5 tid=1 NATIVE
02-06 10:15:13.947 I/dalvikvm( 2040): | group="main" sCount=0 dsCount=0 obj=0x41aaf710 self=0x41a96210
02-06 10:15:13.957 I/dalvikvm( 2040): | sysTid=2040 nice=0 sched=0/0 cgrp=apps handle=1074675708
02-06 10:15:13.957 I/dalvikvm( 2040): | state=R schedstat=( 0 0 0 ) utm=164 stm=41 core=0
02-06 10:15:13.967 I/dalvikvm( 2040): #00 pc 000012fe /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
02-06 10:15:13.967 I/dalvikvm( 2040): #01 pc 0006324e /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+33)
02-06 10:15:13.967 I/dalvikvm( 2040): #02 pc 000572b8 /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+395)
02-06 10:15:13.967 I/dalvikvm( 2040): #03 pc 00057326 /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
02-06 10:15:13.967 I/dalvikvm( 2040): #04 pc 0003b530 /system/lib/libdvm.so
02-06 10:15:13.967 I/dalvikvm( 2040): #05 pc 0003eef2 /system/lib/libdvm.so
02-06 10:15:13.967 I/dalvikvm( 2040): at cirrious.mvvmcross.droid.fragging.MvxEventSourceFragmentActivity.n_startActivityForResult(Native Method)
02-06 10:15:13.967 I/dalvikvm( 2040): at cirrious.mvvmcross.droid.fragging.MvxEventSourceFragmentActivity.startActivityForResult(MvxEventSourceFragmentActivity.java:110)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.app.Activity.startActivity(Activity.java:3661)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.app.Activity.startActivity(Activity.java:3629)
02-06 10:15:13.967 I/dalvikvm( 2040): at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
02-06 10:15:13.967 I/dalvikvm( 2040): at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.view.View.performClick(View.java:4475)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.view.View$PerformClick.run(View.java:18786)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.os.Handler.handleCallback(Handler.java:730)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.os.Handler.dispatchMessage(Handler.java:92)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.os.Looper.loop(Looper.java:137)
02-06 10:15:13.967 I/dalvikvm( 2040): at android.app.ActivityThread.main(ActivityThread.java:5419)
02-06 10:15:13.967 I/dalvikvm( 2040): at java.lang.reflect.Method.invokeNative(Native Method)
02-06 10:15:13.967 I/dalvikvm( 2040): at java.lang.reflect.Method.invoke(Method.java:525)
02-06 10:15:13.967 I/dalvikvm( 2040): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
02-06 10:15:13.967 I/dalvikvm( 2040): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
02-06 10:15:13.967 I/dalvikvm( 2040): at dalvik.system.NativeStart.main(Native Method)
All my custom code is below.
I have my own CustomPresenter
public class CustomPresenter : MvxAndroidViewPresenter, ICustomPresenter
{
// map between view-model and fragment host which creates and shows the view based on the view-model type
private Dictionary<Type, IFragmentHost> dictionary = new Dictionary<Type, IFragmentHost>();
public override void Show(MvxViewModelRequest request)
{
IFragmentHost host;
if (this.dictionary.TryGetValue(request.ViewModelType, out host))
{
if (host.Show(request))
{
return;
}
}
base.Show(request);
}
public void Register(Type viewModelType, IFragmentHost host)
{
this.dictionary[viewModelType] = host;
}
}
I'm using a MvxFragmentActivity as my host view which will contain the content section at the top and the tabs at the bottom, this also implements IFragmentHost. All pages will be Fragments including the tabs.
public class FirstView : MvxFragmentActivity, IFragmentHost
{
ChildTwoView _childTwo;
public bool Show(Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request)
{
// create view model
var loaderService = Mvx.Resolve<IMvxViewModelLoader>();
var viewModel = loaderService.LoadViewModel(request, null /* saved state */);
_childTwo = (ChildTwoView)SupportFragmentManager.FindFragmentById(Resource.Layout.childtwoview);
var customPresenter = Mvx.Resolve<ICustomPresenter>();
//customPresenter.Register(Type)
// decide which fragment to create based on the view-model type
var fm = this.SupportFragmentManager;
var ft = fm.BeginTransaction();
if (viewModel.GetType().Name == "ChildTwoViewModel")
{
var fragmentView = new ChildTwoView();
ft.Replace(Resource.Id.childViewHost, fragmentView);
}
//var fragmentView = viewModel.GetType().Name;
// load fragment into view
ft.AddToBackStack(null);
ft.Commit();
return true;
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.FirstView);
var childView = new ChildView()
{
ViewModel = new ChildViewModel()
};
var tabView = new TabView()
{
ViewModel = new TabViewModel()
};
var fm = this.SupportFragmentManager;
var ft = fm.BeginTransaction();
//ft.Add(childView, "child");
ft.Replace(Resource.Id.childViewHost, childView, "child");
ft.Replace(Resource.Id.tabViewHost, tabView, "tab");
ft.Commit();
}
}
I am setting up these in the Setup.cs
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var customPresenter = new CustomPresenter();
Mvx.RegisterSingleton<ICustomPresenter>(customPresenter);
return customPresenter;
}
All help is greatly appreciated.
EDIT
I decided against this approach and went with the standard Android TabHost to keep consistency between apps.

The error says it all. You have most likely forgot to add a Activity attribute to your ChildTwoView like:
[Activity]
public class ChildTwoView : Activity { ... }
Oh wait, your ChildTwoView is not an Activity, when then you can't use the built in Show method in the presenter. It does not support Fragments.

Related

NetworkOnMainThread RxJava + Retrofit + Lollipop+

I'm getting reports of a NetworkOnMainThread exception on Lollipop+ when running an https api call using Retrofit and RxAndroid.
I have isolated the code and created the following example that still fails.
Here's the build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.bug"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'io.reactivex:rxandroid:1.0.1'
}
Here's the sole activity:
public class HomeActivity extends Activity {
private static final String URL_BASE = "https://some.https.api.com/";
private static final String ENDPOINT = "some/endpoint";
#Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setConnectTimeout(15, TimeUnit.SECONDS);
okHttpClient.setReadTimeout(15, TimeUnit.SECONDS);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL_BASE)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create(new Gson()))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
MyApi mService = retrofit.create(MyApi.class);
setContentView(R.layout.home_activity);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(v->
mService.whatever(new ParamObject())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
response -> Log.d("BUG", response.status),
error -> Log.d("BUG", error.toString()))
);
}
interface MyApi {
#POST(ENDPOINT)
Observable<ResponseObject> whatever( #Body ParamObject requirements);
}
class ResponseObject {
public String status;
}
class ParamObject {
}
}
Here's the exception stacktrace:
E/AndroidRuntime(28345): FATAL EXCEPTION: main
E/AndroidRuntime(28345): Process: com.example.bug, PID: 28345
E/AndroidRuntime(28345): java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
E/AndroidRuntime(28345): at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
E/AndroidRuntime(28345): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(28345): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(28345): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(28345): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(28345): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(28345): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(28345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(28345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime(28345): Caused by: android.os.NetworkOnMainThreadException
E/AndroidRuntime(28345): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
E/AndroidRuntime(28345): at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:724)
E/AndroidRuntime(28345): at okio.Okio$1.write(Okio.java:80)
E/AndroidRuntime(28345): at okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
E/AndroidRuntime(28345): at okio.RealBufferedSink.flush(RealBufferedSink.java:221)
E/AndroidRuntime(28345): at com.squareup.okhttp.internal.framed.Http2$Writer.rstStream(Http2.java:475)
E/AndroidRuntime(28345): at com.squareup.okhttp.internal.framed.FramedConnection.writeSynReset(FramedConnection.java:356)
E/AndroidRuntime(28345): at com.squareup.okhttp.internal.framed.FramedStream.close(FramedStream.java:222)
E/AndroidRuntime(28345): at com.squareup.okhttp.internal.http.FramedTransport.disconnect(FramedTransport.java:215)
E/AndroidRuntime(28345): at com.squareup.okhttp.internal.http.HttpEngine.disconnect(HttpEngine.java:573)
E/AndroidRuntime(28345): at com.squareup.okhttp.Call.cancel(Call.java:122)
E/AndroidRuntime(28345): at retrofit.OkHttpCall.cancel(OkHttpCall.java:162)
E/AndroidRuntime(28345): at retrofit.RxJavaCallAdapterFactory$CallOnSubscribe$1.call(RxJavaCallAdapterFactory.java:102)
E/AndroidRuntime(28345): at rx.subscriptions.BooleanSubscription.unsubscribe(BooleanSubscription.java:72)
E/AndroidRuntime(28345): at rx.internal.util.SubscriptionList.unsubscribeFromAll(SubscriptionList.java:124)
E/AndroidRuntime(28345): at rx.internal.util.SubscriptionList.unsubscribe(SubscriptionList.java:113)
E/AndroidRuntime(28345): at rx.Subscriber.unsubscribe(Subscriber.java:98)
E/AndroidRuntime(28345): at rx.internal.util.SubscriptionList.unsubscribeFromAll(SubscriptionList.java:124)
E/AndroidRuntime(28345): at rx.internal.util.SubscriptionList.unsubscribe(SubscriptionList.java:113)
E/AndroidRuntime(28345): at rx.Subscriber.unsubscribe(Subscriber.java:98)
E/AndroidRuntime(28345): at rx.internal.util.SubscriptionList.unsubscribeFromAll(SubscriptionList.java:124)
E/AndroidRuntime(28345): at rx.internal.util.SubscriptionList.unsubscribe(SubscriptionList.java:113)
E/AndroidRuntime(28345): at rx.Subscriber.unsubscribe(Subscriber.java:98)
E/AndroidRuntime(28345): at rx.observers.SafeSubscriber.onCompleted(SafeSubscriber.java:90)
E/AndroidRuntime(28345): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:201)
E/AndroidRuntime(28345): at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:170)
E/AndroidRuntime(28345): at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
E/AndroidRuntime(28345): ... 8 more
A few things:
This code example works just fine in Android 4.x
I have tried this example (with minor changes) against the GitHub API and it works just fine.
The API is running on Google's app engine.
Note that the observable is being subscribe on Schedulers.io() and observed on AndroidSchedulers.mainThread()
Any ideas?
Edit
After taking a closer look at the stacktrace I figure there was something about http2.
Although not the same issue reported here, the following line to restrict the OkHttp available protocols made it work again.
okHttpClient.setProtocols(Collections.singletonList(Protocol.HTTP_1_1));
It's a known bug in OkHttp that canceling a call does I/O on the canceling thread. Will be fixed in a future release.
Until this issue has been fixed add unsubscribeOn(Schedulers.io()) to the RX call chain. See this commit for an example if you need some more context.

Ebay Java SDK with JBoss - Interceptor for eBayAPIInterfaceService has thrown exception,unwinding now:java.lang.RuntimeException:Couldn't parse stream

I am creating a web application using Ebay Java SDK. I have created a code to get session id using credentials. now it is working file if I run the java file. but if I want to call it from Servlet and deploy it on JBoss, then the same method stop working and give the parse stream exception nested by character conversion.
Regarding code following is the code I am using.
ApiContext apiContext = new ApiContext();
ApiCredential cred = apiContext.getApiCredential();
ApiAccount apiAccount = cred.getApiAccount();
apiAccount.setApplication(LabelConstants.PROD_APP_ID);
apiAccount.setCertificate(LabelConstants.PROD_CERT_ID);
apiAccount.setDeveloper(LabelConstants.PROD_DEV_ID);
apiContext.setApiServerUrl(LabelConstants.PROD_API_URL);
apiContext.setRuName(LabelConstants.PROD_RU_NAME);
GetSessionIDCall gsic = new GetSessionIDCall(apiContext);
gsic.setRuName(apiContext.getRuName());
try {
sessionId = gsic.getSessionID();
System.out.println(sessionId);
} catch (ApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SdkException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
17:22:23,255 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-localhost-127.0.0.1-8080-1) Interceptor for {urn:ebay:apis:eBLBaseComponents}eBayAPIInterfaceService#{urn:ebay:apis:eBLBaseComponents}GetSessionID has thrown exception, unwinding now: java.lang.RuntimeException: Couldn't parse stream.
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1178)
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:795)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1493)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1401)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:648)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:461)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:364)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:317)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at com.sun.proxy.$Proxy44.getSessionID(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_67]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_67]
at com.ebay.sdk.ApiCall.callSOAP(Unknown Source) [ebaysdkcore.jar:]
at com.ebay.sdk.ApiCall.executeByApiName(Unknown Source) [ebaysdkcore.jar:]
at com.ebay.sdk.ApiCall.execute(Unknown Source) [ebaysdkcore.jar:]
at com.ebay.sdk.call.GetSessionIDCall.getSessionID(GetSessionIDCall.java:76) [ebaycalls.jar:]
at com.ba.label.conf.GetApiContext.getSessionId(GetApiContext.java:73) [classes:]
at com.ba.label.servlet.AuthServlet.doGet(AuthServlet.java:43) [classes:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte 0x8b (at char #2, byte #-1)
at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:536)
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:585)
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:610)
at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:316)
at __redirected.__XMLInputFactory.createXMLStreamReader(__XMLInputFactory.java:139) [jboss-modules.jar:1.1.1.GA]
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1176)
... 42 more
Caused by: java.io.CharConversionException: Invalid UTF-8 start byte 0x8b (at char #2, byte #-1)
at com.ctc.wstx.io.UTF8Reader.reportInvalidInitial(UTF8Reader.java:303)
at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:189)
at com.ctc.wstx.io.ReaderBootstrapper.initialLoad(ReaderBootstrapper.java:250)
at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:133)
at com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:531)
... 47 more
Can anyone explain how can I run the Ebay SDK on Servlet and container?
I had the same issue
yourcall.setEnableCompression(false);
worked for me

updating array adapter onActivityResult after getting data from dialogfragment

My dilema is that i am coming from a dialogfragment to my weighInFragment with two pieces of information: a date and an int. I want to be able to use these two pieces of information and construct a newEntry which needs to be added to an existing Arrayadapter. The arraylist is displayed on the weighInFragment and i use the dialogfragment to capture information for new entries. However, when i try to add the new entry to the adapter i get a nullpointer exception which i believe is due to the adapter being null. So i am wondering how could i get this adapter and be able to add the new entry?
Here is y onActivityResult which is where i land after i hit "save" on my dialog:
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case DATEPICKER_FRAGMENT:
if (resultCode == Activity.RESULT_OK) {
Bundle bundle=data.getExtras();
Date date = (Date) bundle.getSerializable("date");
int weight = (Integer) bundle.getSerializable("weight");
Log.d("NewEntry", "Date is: " + date + "Weight: " +weight );
WeighInAdapter adapter = (WeighInAdapter)getListAdapter();
WeighInEntry newEntry = new WeighInEntry();
newEntry.setDate(date);
newEntry.setWeight(weight);
adapter.add(newEntry);
adapter.notifyDataSetChanged();
} else if (resultCode == Activity.RESULT_CANCELED){
}
break;
}
}
This is where i get my data in the dialogadapter:
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
// LayoutInflater inflater = getActivity().getLayoutInflater();
final View v = getActivity().getLayoutInflater()
.inflate(R.layout.weigh_in_dialog, null);
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(v)
// Add action buttons
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
DatePicker datePicker = (DatePicker)v.findViewById(R.id.datePicker1);
EditText weightAmount = (EditText) v.findViewById(R.id.weight);
mDate = getDateFromDatePicket(datePicker);
mWeight = Integer.parseInt(weightAmount.getText().toString());
Intent i = new Intent();
Bundle extras=new Bundle();
extras.putSerializable("date", mDate); //putString("date",Month);
extras.putInt("weight",mWeight);
i.putExtras(extras);
getTargetFragment().onActivityResult(getTargetRequestCode(),Activity.RESULT_OK,i);
dismiss() ;
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
NewEntryDialogFragment.this.getDialog().cancel();
Log.d("CANCEL WAS PRESSED:", "!!!!!!!!!!!!");
}
});
return builder.create();
}
This is the logcat error:
11-17 17:42:51.050: D/NewEntry(2593): Date is: Tue Nov 17 17:42:51 EST 2015Weight: 200
11-17 17:42:51.060: D/AndroidRuntime(2593): Shutting down VM
11-17 17:42:51.060: W/dalvikvm(2593): threadid=1: thread exiting with uncaught exception (group=0xb1ae9b90)
11-17 17:42:51.070: E/AndroidRuntime(2593): FATAL EXCEPTION: main
11-17 17:42:51.070: E/AndroidRuntime(2593): Process: edu.bu.juanl.finalproject, PID: 2593
11-17 17:42:51.070: E/AndroidRuntime(2593): java.lang.NullPointerException
11-17 17:42:51.070: E/AndroidRuntime(2593): at edu.bu.juanl.finalproject.WeighInFragment.onActivityResult(WeighInFragment.java:141)
11-17 17:42:51.070: E/AndroidRuntime(2593): at edu.bu.juanl.finalproject.NewEntryDialogFragment$1.onClick(NewEntryDialogFragment.java:84)
11-17 17:42:51.070: E/AndroidRuntime(2593): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
11-17 17:42:51.070: E/AndroidRuntime(2593): at android.os.Handler.dispatchMessage(Handler.java:102)
11-17 17:42:51.070: E/AndroidRuntime(2593): at android.os.Looper.loop(Looper.java:137)
11-17 17:42:51.070: E/AndroidRuntime(2593): at android.app.ActivityThread.main(ActivityThread.java:4998)
11-17 17:42:51.070: E/AndroidRuntime(2593): at java.lang.reflect.Method.invokeNative(Native Method)
11-17 17:42:51.070: E/AndroidRuntime(2593): at java.lang.reflect.Method.invoke(Method.java:515)
11-17 17:42:51.070: E/AndroidRuntime(2593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
11-17 17:42:51.070: E/AndroidRuntime(2593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
11-17 17:42:51.070: E/AndroidRuntime(2593): at dalvik.system.NativeStart.main(Native Method)
11-17 17:42:53.440: I/Process(2593): Sending signal. PID: 2593 SIG: 9
ive tried multiple things and i cant figure it out!
The DialogPickerFragment inputs data from the user and this needs to be reflected in a different dialog fragment that contains a listview.
The data is being passed to the parent activity and it is trying to access an element belonging to the listview fragment. Herein lies the problem. The activity will not have access to the fragments list adapter.
What you should instead do is implement an interface between the activity and the listview fragment and pass in the data.Check out the android developer guide: http://developer.android.com/training/basics/fragments/communicating.html

App crashing when hitting the send button?

I would like to post data from an edit text to a database/php script and have that data automatically displayed in a list view in the same fragment as the edit text but when clicking the send button my app crashes. Can anyone help?
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ListFragment;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import com.truevision.cypher.library.JSONParser;
public class FragmentOne extends ListFragment {
public static final String IMAGE_RESOURCE_ID = "iconResourceID";
public static final String ITEM_NAME = "itemName";
ListView listView;
EditText editText;
Button sendBtn;
// Progress Dialog
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
// url to create new post
private static final String url_post_message = "http://example.com/myscript.php";
// JSON Node names
private static final String TAG_SUCCESS = "success";
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_layout_one,container, false);
sendBtn = (Button) view.findViewById(R.id.sendBtn);
// button click event
sendBtn.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
// creating new post in background thread
new Post().execute("");
}
});
return view;
}
/**
* Background Async Task to Create new post
* */
class Post extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(getActivity());
pDialog.setMessage("Posting..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating post
* */
protected String doInBackground(String... args) {
String messages = editText.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("messages", messages));
// getting JSON Object
// Note that create post url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_post_message,
"POST", params);
// check log cat fro response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created post
} else {
// failed to create post
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
}
PHP Code
<?php
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['messages'])) {
$messages = $_POST['messages'];
// include db connect class
require_once 'DB_Connect.php';
// connecting to db
$db = new DB_Connect();
// mysql inserting a new row
$result = mysql_query("INSERT INTO post(messages) VALUES('$messages')");
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Post successfully added.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
Logcat:
07-26 17:37:53.489: D/OpenGLRenderer(28074): Flushing caches (mode 0)
07-26 17:38:01.046: I/Adreno200-EGLSUB(28589): <ConfigWindowMatch:2218>: Format RGBA_8888.
07-26 17:38:01.056: D/memalloc(28589): /dev/pmem: Mapped buffer base:0x5bd46000 size:13352960 offset:11816960 fd:55
07-26 17:38:01.056: D/OpenGLRenderer(28589): Enabling debug mode 0
07-26 17:38:01.256: D/memalloc(28589): /dev/pmem: Mapped buffer base:0x5cb02000 size:21319680 offset:19783680 fd:58
07-26 17:38:02.187: D/memalloc(28589): /dev/pmem: Mapped buffer base:0x5e057000 size:11816960 offset:10280960 fd:61
07-26 17:38:14.429: I/Adreno200-EGLSUB(28589): <ConfigWindowMatch:2218>: Format RGBA_8888.
07-26 17:38:14.429: D/memalloc(28589): /dev/pmem: Mapped buffer base:0x5ed9c000 size:16711680 offset:16404480 fd:64
07-26 17:38:14.459: D/memalloc(28589): /dev/pmem: Mapped buffer base:0x5fd8c000 size:13762560 offset:13455360 fd:70
07-26 17:38:14.499: D/memalloc(28589): /dev/pmem: Mapped buffer base:0x60aac000 size:14069760 offset:13762560 fd:73
07-26 17:38:14.650: W/dalvikvm(28589): threadid=11: thread exiting with uncaught exception (group=0x40cc31f8)
07-26 17:38:15.010: E/AndroidRuntime(28589): FATAL EXCEPTION: AsyncTask #1
07-26 17:38:15.010: E/AndroidRuntime(28589): java.lang.RuntimeException: An error occured while executing doInBackground()
07-26 17:38:15.010: E/AndroidRuntime(28589): at android.os.AsyncTask$3.done(AsyncTask.java:278)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-26 17:38:15.010: E/AndroidRuntime(28589): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.lang.Thread.run(Thread.java:856)
07-26 17:38:15.010: E/AndroidRuntime(28589): Caused by: java.lang.NullPointerException
07-26 17:38:15.010: E/AndroidRuntime(28589): at com.truevision.cypher.FragmentOne$Post.doInBackground(FragmentOne.java:85)
07-26 17:38:15.010: E/AndroidRuntime(28589): at com.truevision.cypher.FragmentOne$Post.doInBackground(FragmentOne.java:1)
07-26 17:38:15.010: E/AndroidRuntime(28589): at android.os.AsyncTask$2.call(AsyncTask.java:264)
07-26 17:38:15.010: E/AndroidRuntime(28589): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-26 17:38:15.010: E/AndroidRuntime(28589): ... 5 more
07-26 17:38:15.310: D/OpenGLRenderer(28589): Flushing caches (mode 0)
07-26 17:38:15.310: D/memalloc(28589): /dev/pmem: Unmapping buffer base:0x5bd46000 size:13352960 offset:11816960
07-26 17:38:15.310: D/memalloc(28589): /dev/pmem: Unmapping buffer base:0x5cb02000 size:21319680 offset:19783680
07-26 17:38:15.310: D/memalloc(28589): /dev/pmem: Unmapping buffer base:0x5e057000 size:11816960 offset:10280960
07-26 17:38:15.330: D/OpenGLRenderer(28589): Flushing caches (mode 0)
07-26 17:38:15.340: D/memalloc(28589): /dev/pmem: Unmapping buffer base:0x5ed9c000 size:16711680 offset:16404480
07-26 17:38:15.340: D/memalloc(28589): /dev/pmem: Unmapping buffer base:0x5fd8c000 size:13762560 offset:13455360
07-26 17:38:15.340: D/memalloc(28589): /dev/pmem: Unmapping buffer base:0x60aac000 size:14069760 offset:13762560
07-26 17:38:15.841: D/OpenGLRenderer(28589): Flushing caches (mode 1)
07-26 17:38:16.591: E/WindowManager(28589): Activity com.truevision.cypher.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#41689f50 that was originally added here
07-26 17:38:16.591: E/WindowManager(28589): android.view.WindowLeaked: Activity com.truevision.cypher.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#41689f50 that was originally added here
07-26 17:38:16.591: E/WindowManager(28589): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:344)
07-26 17:38:16.591: E/WindowManager(28589): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267)
07-26 17:38:16.591: E/WindowManager(28589): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
07-26 17:38:16.591: E/WindowManager(28589): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
07-26 17:38:16.591: E/WindowManager(28589): at android.view.Window$LocalWindowManager.addView(Window.java:537)
07-26 17:38:16.591: E/WindowManager(28589): at android.app.Dialog.show(Dialog.java:278)
07-26 17:38:16.591: E/WindowManager(28589): at com.truevision.cypher.FragmentOne$Post.onPreExecute(FragmentOne.java:78)
07-26 17:38:16.591: E/WindowManager(28589): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
07-26 17:38:16.591: E/WindowManager(28589): at android.os.AsyncTask.execute(AsyncTask.java:511)
07-26 17:38:16.591: E/WindowManager(28589): at com.truevision.cypher.FragmentOne$1.onClick(FragmentOne.java:56)
07-26 17:38:16.591: E/WindowManager(28589): at android.view.View.performClick(View.java:3511)
07-26 17:38:16.591: E/WindowManager(28589): at android.view.View$PerformClick.run(View.java:14111)
07-26 17:38:16.591: E/WindowManager(28589): at android.os.Handler.handleCallback(Handler.java:605)
07-26 17:38:16.591: E/WindowManager(28589): at android.os.Handler.dispatchMessage(Handler.java:92)
07-26 17:38:16.591: E/WindowManager(28589): at android.os.Looper.loop(Looper.java:137)
07-26 17:38:16.591: E/WindowManager(28589): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-26 17:38:16.591: E/WindowManager(28589): at java.lang.reflect.Method.invokeNative(Native Method)
07-26 17:38:16.591: E/WindowManager(28589): at java.lang.reflect.Method.invoke(Method.java:511)
07-26 17:38:16.591: E/WindowManager(28589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
07-26 17:38:16.591: E/WindowManager(28589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
07-26 17:38:16.591: E/WindowManager(28589): at dalvik.system.NativeStart.main(Native Method)
The problem is NullPointerException, so something is not initialized. Looking the code seems
that inside doInBackground you use editText, but is not initialized. Use view.findViewById to initialize it first.

How to blank out a datetime field in a SOAP web service?

I have a web service with which a user can update his/her profile.
Now the problem is if a user wants to blank out any date field in their profile (say DOB or registration date) and the user sends , then the response is as follows
<faultcode>ns1:Client</faultcode>
<faultstring>Unmarshalling Error:</faultstring>
How can I blank out date through soapUI?
I have searched a lot, tried nillable but in vain.
Technology: jaxb
The following is the application console output:
16:05:39,508 INFO [WSCallbackHandler] WSPasswordCallback attempt: rd
16:05:39,534 INFO [STDOUT] DefaultValidationEventHandler: [ERROR]:
Location: line 0
16:05:39,534 WARNING [PhaseInterceptorChain] Interceptor for {http://abc.com/services/}ProfileUpdateService#{http://abc.com/services/}updateProfile has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error:
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:773)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:624)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:128)
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)
at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:178)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException:
- with linked exception:
[java.lang.IllegalArgumentException: ]]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:755)
... 33 more
Caused by: javax.xml.bind.UnmarshalException:
- with linked exception:
[java.lang.IllegalArgumentException: ]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:671)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:667)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.handleParseConversionException(Loader.java:267)
at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:65)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:494)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:89)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.processText(StAXStreamConnector.java:334)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleEndElement(StAXStreamConnector.java:212)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:181)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
... 35 more
Caused by: javax.xml.bind.UnmarshalException:
- with linked exception:
[java.lang.IllegalArgumentException: ]
... 46 more
Caused by: java.lang.IllegalArgumentException:
at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseYear(Unknown Source)
at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(Unknown Source)
at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)
at com.sun.xml.bind.DatatypeConverterImpl._parseDateTime(DatatypeConverterImpl.java:397)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$4.parse(RuntimeBuiltinLeafInfoImpl.java:280)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$4.parse(RuntimeBuiltinLeafInfoImpl.java:282)
at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:243)
at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:61)
... 41 more
Use XmlAdapter
public class Foo
{
#XmlJavaTypeAdapter(DateAdapter.class)
YourDateTimeType hashmap;
...
}
and adaptor
public class DateAdapter extends XmlAdapter<YourDateTimeType, String>
{
#Override
public String unmarshal(YourDateTimeType v) throws Exception
{
// your date time to string
}
#Override
public YourDateTimeType marshal(String v) throws Exception
{
// string to your date time
}
}
in adaptor you can check, is field empty or not

Resources