I am getting null arraylist "rev_arr" despite adding item in onProgressupdate.
I passed String in publishprogress method.
But it is not working.
For easiness I had not written import statements here.
Here is my code -
public class det_movFragment extends Fragment {
public String revmovieJsonStr;
public ArrayList<String > rev_arr = new ArrayList<String>();
public det_movFragment() {
}
#Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootview = inflater.inflate(R.layout.fragment_det_mov, container, false);
Intent intent = getActivity().getIntent();
final Bundle extras = intent.getExtras();
if (intent != null ) {
String put_ext_tit = extras.getString("title");
String put_ext_rel_date = extras.getString("rel_date");
String url_pos = extras.getString("url_pos");
int posit = extras.getInt("posit");
String over = extras.getString("over_ex");
final String id = extras.getString("id_ex");
if(put_ext_tit!=null && id!=null) {
((TextView) rootview.findViewById(R.id.title_mov))
.setText(put_ext_tit);
((TextView) rootview.findViewById(R.id.rel_date_mov))
.setText(put_ext_rel_date);
ImageView im2= ((ImageView) rootview.findViewById(R.id.pos_im));
Picasso.with(getActivity()).load(url_pos)
.centerCrop()
.resize(400, 400)
.into(im2);
((TextView) rootview.findViewById(R.id.over))
.setText(over);
Button b = (Button) rootview.findViewById(R.id.rev);
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
new getrev().execute(id);
String[] revi_arr = rev_arr.toArray(new String[rev_arr.size()]);
Log.e("mayank1",revi_arr[1]);
Intent intent_rev = new Intent(getActivity(),det_mov_rev.class);
Bundle ex_rev = new Bundle();
ex_rev.putStringArrayList("rev_list",rev_arr);
intent_rev.putExtras(ex_rev);
startActivity(intent_rev);
}
});
}
else {((TextView) rootview.findViewById(R.id.title_mov)).setText("mayank");}
}
return rootview;
}
public class getrev extends AsyncTask<String, String, Void> {
private final String LOG_TAG = getrev.class.getSimpleName();
public int count;
String[] sin_rev;
String[] aut_rev;
#Override
protected Void doInBackground(String... params) {
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
try {
final String movie_rev_url_str = "http://api.themoviedb.org/3/movie/"+ params[0] +"/reviews?api_key=8d7a48043ba1d3348181e2b6615cedc7";
Log.v("url",movie_rev_url_str);
URL movie_rev_url = new URL(movie_rev_url_str);
urlConnection = (HttpURLConnection) movie_rev_url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
StringBuffer buffer = new StringBuffer();
if (inputStream == null) {
return null;
}
reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line + "\n");
}
if (buffer.length() == 0) {
return null;
}
revmovieJsonStr = buffer.toString();
JSONObject revmovieJson = new JSONObject(revmovieJsonStr);
JSONArray revmovieJsonarray = revmovieJson.getJSONArray("results");
count = revmovieJsonarray.length();
aut_rev = new String[count];
sin_rev = new String[count];
for(int i=0;i<count;i++){
JSONObject sin_rev_json = revmovieJsonarray.getJSONObject(i);
sin_rev[i] = sin_rev_json.getString("content");
Log.e("mayank",sin_rev[i]);
publishProgress((String) sin_rev[i]);
}
} catch (IOException | JSONException e) {
Log.e(LOG_TAG, "Error ", e);
return null;
}
finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
if (reader != null) {
try {
reader.close();
} catch (final IOException e) {
Log.e(LOG_TAG, "Error closing stream", e);
}
}
}
return null;
}
#Override
protected void onProgressUpdate(String... values) {
rev_arr.add(values[0]);
}
}
}
This is my logcat -
07-03 22:34:54.370 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc V/Zygote﹕ Switching descriptor 34 to /dev/null
07-03 22:34:54.370 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc V/Zygote﹕ Switching descriptor 9 to /dev/null
07-03 22:34:54.370 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ Late-enabling CheckJNI
07-03 22:34:54.450 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/ActivityThread﹕ handleBindApplication:jindal5.mayank.popular_movies_14ce10032_gsc
07-03 22:34:54.450 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/ActivityThread﹕ setTargetHeapUtilization:0.75
07-03 22:34:54.450 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/ActivityThread﹕ setTargetHeapMinFree:4194304
07-03 22:34:54.480 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/os/PersistableBundle;)
07-03 22:34:54.480 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.support.v7.app.ActionBarActivity.onSaveInstanceState, referenced from method jindal5.mayank.popular_movies_14ce10032_gsc.MainActivity.onSaveInstanceState
07-03 22:34:54.480 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 8240: Landroid/support/v7/app/ActionBarActivity;.onSaveInstanceState (Landroid/os/Bundle;Landroid/os/PersistableBundle;)V
07-03 22:34:54.480 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 12275: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 12281: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 9846: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
07-03 22:34:54.510 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 407: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 429: Landroid/content/res/TypedArray;.getType (I)I
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 370: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ VFY: unable to resolve virtual method 372: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
07-03 22:34:54.520 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
07-03 22:34:54.590 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/Settings﹕ Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
07-03 22:34:54.610 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: ()
OpenGL ES Shader Compiler Version: E031.24.02.07
Build Date: 11/03/14 Mon
Local Branch:
Remote Branch:
Local Patches:
Reconstruct Branch:
07-03 22:34:54.630 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/qdutils﹕ PartialUpdate status: Disabled
07-03 22:34:54.630 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/qdutils﹕ Width Align: 0
07-03 22:34:54.630 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/qdutils﹕ Top Align: 0
07-03 22:34:54.630 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/qdutils﹕ Height Align: 0
07-03 22:34:54.630 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/qdutils﹕ Min ROI Width: 0
07-03 22:34:54.630 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/qdutils﹕ Min ROI Height: 0
07-03 22:34:54.640 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/OpenGLRenderer﹕ Enabling debug mode 0
07-03 22:34:54.780 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy#41c1b028 time:41024935
07-03 22:34:55.810 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ method Landroid/support/v7/internal/widget/ListViewCompat;.lookForSelectablePosition incorrectly overrides package-private method with same name in Landroid/widget/ListView;
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 135397
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 87101
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 76341
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 254128
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 214756
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 76757
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 198184
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 157336
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 99861
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 118340
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 177572
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 207703
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 122917
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 205596
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 158852
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 245891
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 150689
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 150540
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 241554
07-03 22:34:58.370 21092-21217/jindal5.mayank.popular_movies_14ce10032_gsc V/getimage﹕ Forecast string: 131631
07-03 22:35:01.230 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc V/mayank﹕ San Andreas
07-03 22:35:01.230 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/Timeline﹕ Timeline: Activity_launch_request id:jindal5.mayank.popular_movies_14ce10032_gsc time:41031383
07-03 22:35:01.500 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy#41f68a28 time:41031650
07-03 22:35:02.760 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc D/AndroidRuntime﹕ Shutting down VM
07-03 22:35:02.760 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41629db8)
07-03 22:35:02.760 21092-21645/jindal5.mayank.popular_movies_14ce10032_gsc V/url﹕ http://api.themoviedb.org/3/movie/135397/reviews?api_key=8d7a48043ba1d3348181e2b6615cedc7
07-03 22:35:02.770 21092-21092/jindal5.mayank.popular_movies_14ce10032_gsc E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: jindal5.mayank.popular_movies_14ce10032_gsc, PID: 21092
java.lang.ArrayIndexOutOfBoundsException: length=0; index=1
at jindal5.mayank.popular_movies_14ce10032_gsc.det_movFragment$1.onClick(det_movFragment.java:78)
at android.view.View.performClick(View.java:4445)
at android.view.View$PerformClick.run(View.java:18446)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
at dalvik.system.NativeStart.main(Native Method)
07-03 22:35:03.050 21092-21645/jindal5.mayank.popular_movies_14ce10032_gsc E/mayank﹕ I was a huge fan of the original 3 movies, they were out when I was younger, and I grew up loving dinosaurs because of them. This movie was awesome, and I think it can stand as a testimonial piece towards the capabilities that Christopher Pratt has. He nailed it. The graphics were awesome, the supporting cast did great and the t rex saved the child in me. 10\5 stars, four thumbs up, and I hope that star wars episode VII doesn't disappoint,
07-03 22:35:03.050 21092-21645/jindal5.mayank.popular_movies_14ce10032_gsc E/mayank﹕ Overall action packed movie... But there should be more puzzles in the climax... But I really love the movie.... Excellent...
try this,
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
getrev task=new getrev(){
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
String[] revi_arr = rev_arr.toArray(new String[rev_arr.size()]);
Log.e("mayank1", revi_arr[1]);
Intent intent_rev = new Intent(getActivity(), det_mov_rev.class);
Bundle ex_rev = new Bundle();
ex_rev.putStringArrayList("rev_list", rev_arr);
intent_rev.putExtras(ex_rev);
startActivity(intent_rev);
}
};
task.execute(id);
}
});
Related
I have a table called symbols and symbol history,
Symbols
symbols(Pk)
SymbolsHistorical
id
symbols
Forign key name - symbols_fk (FK)
I created my HibernateMapping and in my DTO classes,
In SymbolsHistorical,
#OneToOne
#JoinColumn(foreignKey = #ForeignKey(name = "symbols_fk"))
private Symbols symbol;
I did in Symbols class,
#OneToOne(mappedBy = "symbol")
private SymbolsHistorical symbolsHistorical;
Whenever I need to read symbols, I need its symbolsHistorical as well,
Iam using findBySymbol method to get symbolsData. Whenever I do the above mapping, am getting,
Unknown column 'symbols0_.symbols_historical_id' in 'field list'
What am doing wrong?
Update:
Error
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:755)
[2m2021-07-05 15:31:29.458[0;39m [31mERROR[0;39m [35m76390[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36ms.e.ErrorMvcAutoConfiguration$StaticView[0;39m [2m:[0;39m Cannot render error page for request [/symbols/A] and exception [] as the response has already been committed. As a result, the response may have the wrong status code.
Taken from your tables the foreign key name is symbols.
So the mapping must be in Symbols class:
#OneToOne
#JoinColumn(name="symbols")
private Symbols symbol;
As you are using JSON serialization you will get a StackOverflowError because of the bi-directional mapping.
So you have to add an annotation to the Symbol or SymbolsHistorical class (depending on what you want to serialize) to break the loop.
For example
#JsonBackReference // this property will not be serialized
#OneToOne(mappedBy = "symbol")
private SymbolsHistorical symbolsHistorical;
I am working on a Spring Batch requirement. I am writing a converter class as a utility class in a separate util package in my project. I am reading the CSV file writing to MySQL database.
But I am facing issues like rejected value for field?
Domain Class
public class Customer implements Serializable {
private Integer id_type;
private String id_number;
private String customer_name;
private String email_address;
private LocalDate birthday;
private String citizenship;
private String address;
private Long msisdn;
private LocalDateTime kyc_date;
private String kyc_level;
private String goalscore;
private String mobile_network;
}
Utility Class
public final class StringToLocalDateConversion {
private StringToLocalDateConversion() {
}
static ConversionService createLocalDateConversionServicve() {
DefaultConversionService stringToLocalDateconversionService = new DefaultConversionService();
DefaultConversionService.addDefaultConverters(stringToLocalDateconversionService);
stringToLocalDateconversionService.addConverter(new Converter<String, LocalDate>() {
#Override
public LocalDate convert(String text) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-mm-dd");
return LocalDate.parse(text, formatter);
}
});
return stringToLocalDateconversionService;
}
}
public final class StringToLocalDateTimeConversion {
public StringToLocalDateTimeConversion() {
}
static ConversionService stringToLocalDateTimeConversionService() {
DefaultConversionService stringToLocalDateTimeConversion = new DefaultConversionService();
DefaultConversionService.addDefaultConverters(stringToLocalDateTimeConversion);
stringToLocalDateTimeConversion.addConverter(new Converter<String, LocalDateTime>() {
#Override
public LocalDateTime convert(String source) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss");
return LocalDateTime.parse(source, dateTimeFormatter);
}
});
return stringToLocalDateTimeConversion;
}
}
BatchConfiguration Class
#Configuration
#EnableBatchProcessing
public class BatchConfiguration {
#Autowired
public JobBuilderFactory jobBuilderFactory;
#Autowired
public StepBuilderFactory stepBuilderFactory;
#Value("classPath:/data/gcash.csv")
private Resource inputResource;
#Autowired
public DataSource dataSource;
#Bean
public Job readCSVFilesJob() {
return jobBuilderFactory.get("readCSVFilesJob").incrementer(new RunIdIncrementer()).start(step1()).build();
}
#Bean
public Step step1() {
return stepBuilderFactory.get("step1").<Customer, Customer>chunk(10).reader(itemReader()).processor(processor())
.writer(writer()).build();
}
/*
* #Bean public DataSource dataSource() { final DriverManagerDataSource
* dataSource = new DriverManagerDataSource();
* dataSource.setDriverClassName("com.mysql.jdbc.Driver");
* dataSource.setUrl("jdbc:mysql://localhost:3306/springbatch");
* dataSource.setUsername("root"); dataSource.setPassword("123456");
*
* return dataSource; }
*/
#Bean
public ItemReader<Customer> itemReader() {
FlatFileItemReader<Customer> customerItemReader = new FlatFileItemReader<>();
customerItemReader.setName("CUSTOMER_READER");
customerItemReader.setLineMapper(linemapper());
customerItemReader.setLinesToSkip(1);
customerItemReader.setResource(inputResource);
return customerItemReader;
}
#Bean
public LineMapper<Customer> linemapper() {
DefaultLineMapper<Customer> linemapper = new DefaultLineMapper<>();
final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
tokenizer.setDelimiter(";");
tokenizer.setStrict(false);
tokenizer.setNames(new String[] { "id_type", "id_number", "customer_name", "email_address", "birthday",
"citizenship", "address", "msisdn", "kyc_date", "kyc_level", "goalscore", "mobile_network" });
linemapper.setLineTokenizer(tokenizer);
BeanWrapperFieldSetMapper<Customer> fieldSetMapper = new BeanWrapperFieldSetMapper<>();
fieldSetMapper.setTargetType(Customer.class);
ConversionService localDateConversionService = StringToLocalDateConversion.createLocalDateConversionServicve();
ConversionService localDateTimeConversionService = StringToLocalDateTimeConversion
.stringToLocalDateTimeConversionService();
fieldSetMapper.setConversionService(localDateConversionService);
fieldSetMapper.setConversionService(localDateTimeConversionService);
linemapper.setFieldSetMapper(fieldSetMapper);
return linemapper;
}
#Bean
public CustomerItemProcessor processor() {
return new CustomerItemProcessor();
}
#Bean
public JdbcBatchItemWriter<Customer> writer() {
JdbcBatchItemWriter<Customer> writer = new JdbcBatchItemWriter<>();
writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Customer>());
writer.setSql(
"INSERT INTO people (id_type, id_number,customer_name,email_address,birthday,citizenship,address,msisdn,kyc_date,kyc_level,goalscore,mobile_network) VALUES (:id_type, :id_number, :customer_name, :email_address, :birthday, :citizenship, :address, :msisdn, :kyc_date, :goalscore, :mobile_network)");
writer.setDataSource(this.dataSource);
return writer;
}
}
StackTrace
org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 2 in resource=[URL [classpath:/data/gcash.csv]], input=["LISONDRA, MARIA MINI, JUCOM",MJLISONDRA71#GMAIL.COM,1971-02-12,FILIPINO,2,06-1401967-8,"M L QUEZON CABANCALAN, QUEZON, MANDAUE",9052100646,2019-10-10 11:45:18,FULL KYC,525_549,Globe Prepaid]
at org.springframework.batch.item.file.FlatFileItemReader.doRead(FlatFileItemReader.java:189) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read(AbstractItemCountingItemStreamItemReader.java:93) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:99) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:180) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:126) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:118) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:71) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.3.4.jar:5.3.4]
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:258) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:208) ~[spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:411) [spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:136) [spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:320) [spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:147) [spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) [spring-core-5.3.4.jar:5.3.4]
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:140) [spring-batch-core-4.3.1.jar:4.3.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_271]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_271]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_271]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_271]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) [spring-aop-5.3.4.jar:5.3.4]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) [spring-aop-5.3.4.jar:5.3.4]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) [spring-aop-5.3.4.jar:5.3.4]
at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:128) [spring-batch-core-4.3.1.jar:4.3.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.3.4.jar:5.3.4]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) [spring-aop-5.3.4.jar:5.3.4]
at com.sun.proxy.$Proxy104.run(Unknown Source) [na:na]
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.execute(JobLauncherApplicationRunner.java:199) [spring-boot-autoconfigure-2.4.3.jar:2.4.3]
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.executeLocalJobs(JobLauncherApplicationRunner.java:173) [spring-boot-autoconfigure-2.4.3.jar:2.4.3]
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.launchJobFromProperties(JobLauncherApplicationRunner.java:160) [spring-boot-autoconfigure-2.4.3.jar:2.4.3]
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:155) [spring-boot-autoconfigure-2.4.3.jar:2.4.3]
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:150) [spring-boot-autoconfigure-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795) [spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:785) [spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) [spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.4.3.jar:2.4.3]
at com.gcash.milo.GCashMiloApplication.main(GCashMiloApplication.java:10) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_271]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_271]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_271]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_271]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.4.3.jar:2.4.3]
Caused by: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 3 errors
Field error in object 'target' on field 'id_type': rejected value ["LISONDRA, MARIA MINI, JUCOM",MJLISONDRA71#GMAIL.COM,1971-02-12,FILIPINO,2,06-1401967-8,"M L QUEZON CABANCALAN, QUEZON, MANDAUE",9052100646,2019-10-10 11:45:18,FULL KYC,525_549,Globe Prepaid]; codes [typeMismatch.target.id_type,typeMismatch.id_type,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.id_type,id_type]; arguments []; default message [id_type]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'id_type'; nested exception is java.lang.NumberFormatException: For input string: ""LISONDRA,MARIAMINI,JUCOM",MJLISONDRA71#GMAIL.COM,1971-02-12,FILIPINO,2,06-1401967-8,"MLQUEZONCABANCALAN,QUEZON,MANDAUE",9052100646,2019-10-1011:45:18,FULLKYC,525_549,GlobePrepaid"]
Field error in object 'target' on field 'kyc_date': rejected value []; codes [typeMismatch.target.kyc_date,typeMismatch.kyc_date,typeMismatch.java.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.kyc_date,kyc_date]; arguments []; default message [kyc_date]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDateTime' for property 'kyc_date'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.time.LocalDateTime] for value ''; nested exception is java.time.format.DateTimeParseException: Text '' could not be parsed at index 0]
Field error in object 'target' on field 'birthday': rejected value []; codes [typeMismatch.target.birthday,typeMismatch.birthday,typeMismatch.java.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.birthday,birthday]; arguments []; default message [birthday]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'birthday'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'birthday': no matching editors or conversion strategy found]
at org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper.mapFieldSet(BeanWrapperFieldSetMapper.java:201) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.item.file.mapping.DefaultLineMapper.mapLine(DefaultLineMapper.java:43) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
at org.springframework.batch.item.file.FlatFileItemReader.doRead(FlatFileItemReader.java:185) ~[spring-batch-infrastructure-4.3.1.jar:4.3.1]
... 53 common frames omitted
[2m2021-04-27 22:45:46.085[0;39m [32m INFO[0;39m [35m7456[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.batch.core.step.AbstractStep [0;39m [2m:[0;39m Step: [step1] executed in 25ms
[2m2021-04-27 22:45:46.097[0;39m [32m INFO[0;39m [35m7456[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.c.l.support.SimpleJobLauncher [0;39m [2m:[0;39m Job: [SimpleJob: [name=readCSVFilesJob]] completed with the following parameters: [{run.id=17}] and the following status: [FAILED] in 49ms
[2m2021-04-27 22:45:46.097[0;39m [32m INFO[0;39m [35m7456[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.ConditionEvaluationDeltaLoggingListener[0;39m [2m:[0;39m Condition evaluation unchanged
Well if you see my domain class three fields id_type,birthday,kyc_date, have taken them as Integer, LocalDate, LocalDateTime. For this i have also written Converter class. but i am getting three different errors.
Caused by: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 3 errors
Field error in object 'target' on field 'id_type': rejected value ["LISONDRA, MARIA MINI, JUCOM",MJLISONDRA71#GMAIL.COM,1971-02-12,FILIPINO,2,06-1401967-8,"M L QUEZON CABANCALAN, QUEZON, MANDAUE",9052100646,2019-10-10 11:45:18,FULL KYC,525_549,Globe Prepaid]; codes [typeMismatch.target.id_type,typeMismatch.id_type,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.id_type,id_type]; arguments []; default message [id_type]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'id_type'; nested exception is java.lang.NumberFormatException: For input string: ""LISONDRA,MARIAMINI,JUCOM",MJLISONDRA71#GMAIL.COM,1971-02-12,FILIPINO,2,06-1401967-8,"MLQUEZONCABANCALAN,QUEZON,MANDAUE",9052100646,2019-10-1011:45:18,FULLKYC,525_549,GlobePrepaid"]
Field error in object 'target' on field 'kyc_date': rejected value []; codes [typeMismatch.target.kyc_date,typeMismatch.kyc_date,typeMismatch.java.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.kyc_date,kyc_date]; arguments []; default message [kyc_date]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDateTime' for property 'kyc_date'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.time.LocalDateTime] for value ''; nested exception is java.time.format.DateTimeParseException: Text '' could not be parsed at index 0]
Field error in object 'target' on field 'birthday': rejected value []; codes [typeMismatch.target.birthday,typeMismatch.birthday,typeMismatch.java.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [target.birthday,birthday]; arguments []; default message [birthday]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'birthday'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'birthday': no matching editors or conversion strategy found]
I am having trouble understanding this error:
[Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'id_type'
In my model class , id_type is of type Integer, then why it is saying "Failed to convert property value string to Integer?"
This is because you have line where some fields contain the delimiter (,) inside a quoted field:
"LISONDRA, MARIA MINI, JUCOM",MJLISONDRA71#GMAIL.COM,1971-02-12,FILIPINO,2,06-1401967-8,"M L QUEZON CABANCALAN, QUEZON, MANDAUE",9052100646,2019-10-10 11:45:18,FULL KYC,525_549,Globe Prepaid
Since you are using the DelimitedLineTokenizer in which the default quote character is ", the fields "LISONDRA, MARIA MINI, JUCOM" and "M L QUEZON CABANCALAN, QUEZON, MANDAUE" are not considered as a single value. Hence, the entire line as a String is attempted to be converted to the first field which type_id of type Integer. There is an open issue for that here: https://github.com/spring-projects/spring-batch/issues/1822.
You need to use a different quote character or create a custom FieldSetMapper that is able to handle this case.
EDIT: add example for conversion service
conversionService.addConverter(new Converter<String, LocalDate>() { .. });
conversionService.addConverter(new Converter<String, LocalDatTime>() { .. });
fieldSetMapper.setConversionService(conversionService);
after updating my app to NativeScript 5.1/tns-core-modules to 5.1.2, I am having this messages once the app starts:
01-30 09:59:57.001 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[]) (Runtime.java:-2)
01-30 09:59:57.001 12223 12223 I art : at java.lang.Object com.tns.Runtime.dispatchCallJSMethodNative(int, java.lang.String, boolean, long, java.lang.Class, java.lang.Object[]) (Runtime.java:1120)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethodImpl(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:1000)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:987)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, java.lang.Object[]) (Runtime.java:967)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object[]) (Runtime.java:959)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[]) (Runtime.java:-2)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.dispatchCallJSMethodNative(int, java.lang.String, boolean, long, java.lang.Class, java.lang.Object[]) (Runtime.java:1120)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethodImpl(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:1000)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, long, java.lang.Object[]) (Runtime.java:987)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, boolean, java.lang.Object[]) (Runtime.java:967)
01-30 09:59:57.002 12223 12223 I art : at java.lang.Object com.tns.Runtime.callJSMethod(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object[]) (Runtime.java:959)
I have removed the /core_modules, /hooks, /platforms/android folders and the messages are still showing.
Any clue whats going on?
Thanks!
These are only warnings and you don't have to worry about it. Still, if you are interested in what is causing them and how to (possibly) remove them, see the discussion in the opened issue here:
https://github.com/NativeScript/nativescript-cli/issues/4300#issuecomment-439092313
Sometimes we get error System.OutOfMemoryException . complete error is
FATAL 2017-12-24 17:01:45,360 [39 ] Abp.AbpBootstrapper - System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at Abp.Modules.AbpModule.FindDependedModuleTypes(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 108
at Abp.Modules.AbpModule.AddModuleAndDependenciesRecursively(List1 modules, Type module) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 143
at Abp.Modules.AbpModule.FindDependedModuleTypesRecursivelyIncludingGivenModule(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 124
at Abp.Modules.AbpModuleManager.FindAllModuleTypes(List1& plugInModuleTypes) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 86
at Abp.Modules.AbpModuleManager.LoadAllModules() in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 67
at Abp.Modules.AbpModuleManager.Initialize(Type startupModule) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 40
at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 146
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at Abp.Modules.AbpModule.FindDependedModuleTypes(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 108
at Abp.Modules.AbpModule.AddModuleAndDependenciesRecursively(List1 modules, Type module) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 143
at Abp.Modules.AbpModule.FindDependedModuleTypesRecursivelyIncludingGivenModule(Type moduleType) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModule.cs:line 124
at Abp.Modules.AbpModuleManager.FindAllModuleTypes(List1& plugInModuleTypes) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 86
at Abp.Modules.AbpModuleManager.LoadAllModules() in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 67
at Abp.Modules.AbpModuleManager.Initialize(Type startupModule) in D:\Github\aspnetboilerplate\src\Abp\Modules\AbpModuleManager.cs:line 40
at Abp.AbpBootstrapper.Initialize() in D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs:line 146
we use ASPNetBoilerplate, AngularJs and entity framework
looks like you've misconfigured ABP dependencies. FindDependedModuleTypesRecursivelyIncludingGivenModule() method recursively loads dependent modules and it might go into infinite loop. check all the [DependsOn(typeof(XXXX))] attributes!
I have an asp.net mvc web application working fine before I upgraded nreco.pdfgenerator to version 1.1.10. After upgrading to version 1.1.10, whenever a pdf file is generated, the application stops working and just displays the message
Server Error in '/' Application.
Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
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.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'file:///C:\Projects\bin\msvcp120.dll' could not be loaded.
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Projects\bin\msvcp120.dll
LOG: Appbase = file:///C:/Projects/
LOG: Initial PrivatePath = C:\Projects\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Projects\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Projects/bin/msvcp120.dll.
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +102
System.Reflection.Assembly.LoadFrom(String assemblyFile) +34
WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:11
[InvalidOperationException: The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +613
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +141
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531
[HttpException (0x80004005): The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'file:///C:\Projects\bin\msvcp120.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9942412
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
I've tried googling the error and found no solution anywhere.
Any help will be very much appreciated.
Not sure how to resolve the error, but I have found a workaround.
Simply set the "PdfToolPath" to a different folder to keep those bad dlls out of bin:
var pdfGenerator = new NReco.PdfGenerator.HtmlToPdfConverter
{
PdfToolPath = Path.Combine(HttpRuntime.AppDomainAppPath, "PdfTool")
};
This would cause NReco.PdfGenerator to copy the wkhtmltopdf.exe program and the 2 required dlls to the folder "PdfTool" instead.