Search Results

Search found 243 results on 10 pages for 'illegalargumentexception'.

Page 10/10 | < Previous Page | 6 7 8 9 10 

  • Binding Contents of a ListBox to Selected Item from Another Listbox w/JSF & Managed Beans

    - by nieltown
    Hi there! I currently have a JSF application that uses two listboxes. The first, say ListBox1, contains a list of manufacturers; each option comes from the database (via a method getManufacturers in a class called QueryUtil), is populated dynamically, and its value is an integer ID. This part works so far. My goal is to populate a second listbox, say ListBox2, with a list of products sold by the manufacturer. This list of products will come from the database as well (products are linked to a manufacturer via a foreign key relationship, via a method getProducts in my QueryUtil class). How do I go about doing this? Please bear in mind that I've been working with JSF for under 24 hours; I'm willing to accept the fact that I'm missing something very rudimentary. Again, I've been able to populate the list of manufacturers just fine; unfortunately, adding the Products component gives me java.lang.IllegalArgumentException: argument type mismatch faces-config.xml <managed-bean> <managed-bean-name>ProductsBean</managed-bean-name> <managed-bean-class>com.nieltown.ProductsBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>manufacturers</property-name> <property-class>java.util.ArrayList</property-class> <value>#{manufacturers}</value> </managed-property> <managed-property> <property-name>selectedManufacturer</property-name> <property-class>java.lang.Integer</property-name> <value>#{selectedManufacturer}</value> </managed-property> <managed-property> <property-name>products</property-name> <property-class>java.util.ArrayList</property-class> <value>#{products}</value> </managed-property> <managed-property> <property-name>selectedProduct</property-name> <property-class>java.lang.Integer</property-name> <value>#{selectedProducts}</value> <managed-property> </managed-bean> com.nieltown.ProductsBean public class ProductsBean { private List<SelectItem> manufacturers; private List<SelectItem> products; private Integer selectedManufacturer; private Integer selectedProduct; public ProductsBean() {} public Integer getSelectedManufacturer(){ return selectedManufacturer; } public void setSelectedManufacturer(Integer m){ selectedManufacturer = m; } public Integer getSelectedProduct(){ return selectedProduct; } public void setSelectedProduct(Integer p){ selectedProduct = p; } public List<SelectItem> getManufacturers(){ if(manufacturers == null){ SelectItem option; plans = new ArrayList<SelectItem>(); QueryUtil qu = new QueryUtil(); Map<Integer, String> manufacturersMap = qu.getManufacturers(); for(Map.Entry<Integer, String> entry : manufacturersMap.entrySet()){ option = new SelectItem(entry.getKey(),entry.getValue()); manufacturers.add(option); } } return manufacturers; } public void setManufacturers(List<SelectItem> l){ manufacturers = l; } public List<SelectItem> getProducts(){ if(products == null){ SelectItem option; products = new ArrayList<SelectItem>(); if(selectedPlan != null){ PMTQueryUtil pqu = new PMTQueryUtil(); Map<Integer, String> productsMap = pqu.getProducts(); for(Map.Entry<Integer, String> entry : productsMap.entrySet()){ option = new SelectItem(entry.getKey(),entry.getValue()); products.add(option); } } } return products; } public void setProducts(List<SelectItem> l){ products = l; } } JSP fragment <h:selectOneListbox id="manufacturerList" value="#{ProductsBean.selectedManufacturer}" size="10"> <f:selectItems value="#{ProductsBean.manufacturers}" /> </h:selectOneListbox> <h:selectOneListbox id="productList" value="#{PendingPlansBean.selectedProduct}" size="10"> <f:selectItems binding="#{ProductsBean.products}" /> </h:selectOneListbox>

    Read the article

  • Android exception i don't understand after loading webpage in a webview

    - by DixieFlatline
    I have a webview that loads a webpage. I also have a reload button. Sometimes it works but sometimes it crashes when i hit reload and i get this exceptions: 05-14 10:08:33.958: ERROR/WindowManager(918): Activity com.poslji.gor.Uvod has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@435da698 that was originally added here 05-14 10:08:33.958: ERROR/WindowManager(918): android.view.WindowLeaked: Activity com.poslji.gor.Uvod has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@435da698 that was originally added here 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewRoot.(ViewRoot.java:217) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.Window$LocalWindowManager.addView(Window.java:392) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.app.Dialog.show(Dialog.java:231) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.app.ProgressDialog.show(ProgressDialog.java:107) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.app.ProgressDialog.show(ProgressDialog.java:90) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.poslji.gor.Odgovori$2.onClick(Odgovori.java:120) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.View.performClick(View.java:2179) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.View.onTouchEvent(View.java:3828) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.widget.TextView.onTouchEvent(TextView.java:6307) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.View.dispatchTouchEvent(View.java:3368) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1752) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1206) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.app.Activity.dispatchTouchEvent(Activity.java:1997) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1736) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1752) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1206) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.app.Activity.dispatchTouchEvent(Activity.java:1997) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1736) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.view.ViewRoot.handleMessage(ViewRoot.java:1761) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.os.Handler.dispatchMessage(Handler.java:99) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.os.Looper.loop(Looper.java:123) 05-14 10:08:33.958: ERROR/WindowManager(918): at android.app.ActivityThread.main(ActivityThread.java:3948) 05-14 10:08:33.958: ERROR/WindowManager(918): at java.lang.reflect.Method.invokeNative(Native Method) 05-14 10:08:33.958: ERROR/WindowManager(918): at java.lang.reflect.Method.invoke(Method.java:521) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 05-14 10:08:33.958: ERROR/WindowManager(918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 05-14 10:08:33.958: ERROR/WindowManager(918): at dalvik.system.NativeStart.main(Native Method) 05-14 10:08:36.768: ERROR/AndroidRuntime(918): Uncaught handler: thread main exiting due to uncaught exception 05-14 10:08:36.778: ERROR/AndroidRuntime(918): java.lang.IllegalArgumentException: View not attached to window manager 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:356) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:201) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.view.Window$LocalWindowManager.removeView(Window.java:400) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.app.Dialog.dismissDialog(Dialog.java:268) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.app.Dialog.access$000(Dialog.java:69) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.app.Dialog$1.run(Dialog.java:103) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.app.Dialog.dismiss(Dialog.java:252) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at com.poslji.gor.Odgovori$HelloWebViewClient.onPageFinished(Odgovori.java:180) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:225) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.os.Handler.dispatchMessage(Handler.java:99) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.os.Looper.loop(Looper.java:123) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at android.app.ActivityThread.main(ActivityThread.java:3948) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at java.lang.reflect.Method.invokeNative(Native Method) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at java.lang.reflect.Method.invoke(Method.java:521) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 05-14 10:08:36.778: ERROR/AndroidRuntime(918): at dalvik.system.NativeStart.main(Native Method) What is going wrong here?

    Read the article

  • Handling android player errors

    - by stack hoss
    I am anew android developer and i made ashoutcast radio player and work good but when i open app it work for afew time but suddenly stop and need to press stop and play again but i need Handling android player errors to automatic restart on errors package com.test.test; import java.io.IOException; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.media.AudioManager; import android.media.AudioManager.OnAudioFocusChangeListener; import android.media.MediaPlayer; import android.os.IBinder; import android.preference.PreferenceManager; import android.util.Log; public class StreamService extends Service { private static final String TAG = "StreamService"; MediaPlayer mp; boolean isPlaying; Intent MainActivity; SharedPreferences prefs; SharedPreferences.Editor editor; Notification n; NotificationManager notificationManager; // Change this int to some number specifically for this app int notifId = 85; private OnAudioFocusChangeListener focusChangeListener = new OnAudioFocusChangeListener() { public void onAudioFocusChange(int focusChange) { switch (focusChange) { case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) : // Lower the volume while ducking. mp.setVolume(0.2f, 0.2f); break; case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) : mp.pause(); break; case (AudioManager.AUDIOFOCUS_LOSS) : mp.stop(); break; case (AudioManager.AUDIOFOCUS_GAIN) : // Return the volume to normal and resume if paused. mp.setVolume(1f, 1f); mp.start(); break; default: break; } } }; @Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @SuppressWarnings("deprecation") @Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate"); // Init the SharedPreferences and Editor prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); editor = prefs.edit(); // Set up the buffering notification notificationManager = (NotificationManager) getApplicationContext() .getSystemService(NOTIFICATION_SERVICE); Context context = getApplicationContext(); String notifTitle = context.getResources().getString(R.string.app_name); String notifMessage = context.getResources().getString(R.string.buffering); n = new Notification(); n.icon = R.drawable.ic_launcher; n.tickerText = "Buffering"; n.when = System.currentTimeMillis(); Intent nIntent = new Intent(context, MainActivity.class); nIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pIntent = PendingIntent.getActivity(context, 0, nIntent, 0); n.setLatestEventInfo(context, notifTitle, notifMessage, pIntent); notificationManager.notify(notifId, n); // It's very important that you put the IP/URL of your ShoutCast stream here // Otherwise you'll get Webcom Radio String url = "http://47.182.19.93:9888/"; mp = new MediaPlayer(); mp.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mp.reset(); mp.setDataSource(url); mp.prepare(); mp.start(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block Log.e(TAG, "SecurityException"); } catch (IllegalStateException e) { // TODO Auto-generated catch block Log.e(TAG, "IllegalStateException"); } catch (IOException e) { // TODO Auto-generated catch block Log.e(TAG, "IOException"); } } @SuppressWarnings("deprecation") @Override public void onStart(Intent intent, int startId) { Log.d(TAG, "onStart"); mp.start(); // Set the isPlaying preference to true editor.putBoolean("isPlaying", true); editor.commit(); Context context = getApplicationContext(); String notifTitle = context.getResources().getString(R.string.app_name); String notifMessage = context.getResources().getString(R.string.now_playing); n.icon = R.drawable.ic_launcher; n.tickerText = notifMessage; n.flags = Notification.FLAG_NO_CLEAR; n.when = System.currentTimeMillis(); Intent nIntent = new Intent(context, MainActivity.class); PendingIntent pIntent = PendingIntent.getActivity(context, 0, nIntent, 0); n.setLatestEventInfo(context, notifTitle, notifMessage, pIntent); // Change 5315 to some nother number notificationManager.notify(notifId, n); AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); // Request audio focus for playback int result = am.requestAudioFocus(focusChangeListener, // Use the music stream. AudioManager.STREAM_MUSIC, // Request permanent focus. AudioManager.AUDIOFOCUS_GAIN); if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { // other app had stopped playing song now , so u can do u stuff now . } } @Override public void onDestroy() { Log.d(TAG, "onDestroy"); mp.stop(); mp.release(); mp = null; editor.putBoolean("isPlaying", false); editor.commit(); notificationManager.cancel(notifId); AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE); am.abandonAudioFocus(focusChangeListener); } }

    Read the article

  • adjust selected File to FileFilter in a JFileChooser

    - by amarillion
    I'm writing a diagram editor in java. This app has the option to export to various standard image formats such as .jpg, .png etc. When the user clicks File-Export, you get a JFileChooser which has a number of FileFilters in it, for .jpg, .png etc. Now here is my question: Is there a way to have the extension of the default adjust to the selected file filter? E.g. if the document is named "lolcat" then the default option should be "lolcat.png" when the png filter is selected, and when the user selects the jpg file filter, the default should change to "lolcat.jpg" automatically. Is this possible? How can I do it? edit: Based on the answer below, I wrote some code. But it doesn't quite work yet. I've added a propertyChangeListener to the FILE_FILTER_CHANGED_PROPERTY, but it seems that within this method getSelectedFile() returns null. Here is the code. package nl.helixsoft; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.filechooser.FileFilter; public class JFileChooserTest { public class SimpleFileFilter extends FileFilter { private String desc; private List<String> extensions; private boolean showDirectories; /** * @param name example: "Data files" * @param glob example: "*.txt|*.csv" */ public SimpleFileFilter (String name, String globs) { extensions = new ArrayList<String>(); for (String glob : globs.split("\\|")) { if (!glob.startsWith("*.")) throw new IllegalArgumentException("expected list of globs like \"*.txt|*.csv\""); // cut off "*" // store only lower case (make comparison case insensitive) extensions.add (glob.substring(1).toLowerCase()); } desc = name + " (" + globs + ")"; } public SimpleFileFilter(String name, String globs, boolean showDirectories) { this(name, globs); this.showDirectories = showDirectories; } @Override public boolean accept(File file) { if(showDirectories && file.isDirectory()) { return true; } String fileName = file.toString().toLowerCase(); for (String extension : extensions) { if (fileName.endsWith (extension)) { return true; } } return false; } @Override public String getDescription() { return desc; } /** * @return includes '.' */ public String getFirstExtension() { return extensions.get(0); } } void export() { String documentTitle = "lolcat"; final JFileChooser jfc = new JFileChooser(); jfc.setDialogTitle("Export"); jfc.setDialogType(JFileChooser.SAVE_DIALOG); jfc.setSelectedFile(new File (documentTitle)); jfc.addChoosableFileFilter(new SimpleFileFilter("JPEG", "*.jpg")); jfc.addChoosableFileFilter(new SimpleFileFilter("PNG", "*.png")); jfc.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { System.out.println ("Property changed"); String extold = null; String extnew = null; if (arg0.getOldValue() == null || !(arg0.getOldValue() instanceof SimpleFileFilter)) return; if (arg0.getNewValue() == null || !(arg0.getNewValue() instanceof SimpleFileFilter)) return; SimpleFileFilter oldValue = ((SimpleFileFilter)arg0.getOldValue()); SimpleFileFilter newValue = ((SimpleFileFilter)arg0.getNewValue()); extold = oldValue.getFirstExtension(); extnew = newValue.getFirstExtension(); String filename = "" + jfc.getSelectedFile(); System.out.println ("file: " + filename + " old: " + extold + ", new: " + extnew); if (filename.endsWith(extold)) { filename.replace(extold, extnew); } else { filename += extnew; } jfc.setSelectedFile(new File (filename)); } }); jfc.showDialog(frame, "export"); } JFrame frame; void run() { frame = new JFrame(); JButton btn = new JButton ("export"); frame.add (btn); btn.addActionListener (new ActionListener() { public void actionPerformed(ActionEvent ae) { export(); } }); frame.setSize (300, 300); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { JFileChooserTest x = new JFileChooserTest(); x.run(); } }); } }

    Read the article

  • Error when call 'qb.query(db, projection, selection, selectionArgs, null, null, orderBy);'

    - by smalltalk1960s
    Hi all, I make a content provider named 'DictionaryProvider' (Based on NotepadProvider). When my program run to command 'qb.query(db, projection, selection, selectionArgs, null, null, orderBy);', error happen. I don't know how to fix. please help me. Below is my code // file main calling DictionnaryProvider @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dictionary); final String[] PROJECTION = new String[] { DicColumns._ID, // 0 DicColumns.KEY_WORD, // 1 DicColumns.KEY_DEFINITION // 2 }; Cursor c = managedQuery(DicColumns.CONTENT_URI, PROJECTION, null, null, DicColumns.DEFAULT_SORT_ORDER); String str = ""; if (c.moveToFirst()) { int wordColumn = c.getColumnIndex("KEY_WORD"); int defColumn = c.getColumnIndex("KEY_DEFINITION"); do { // Get the field values str = ""; str += c.getString(wordColumn); str +="\n"; str +=c.getString(defColumn); } while (c.moveToNext()); } Toast.makeText(this, str, Toast.LENGTH_SHORT).show(); } // file DictionaryProvider.java package com.example.helloandroid; import java.util.HashMap; import android.content.ContentProvider; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.text.TextUtils; import com.example.helloandroid.Dictionary.DicColumns; public class DictionaryProvider extends ContentProvider { //private static final String TAG = "DictionaryProvider"; private DictionaryOpenHelper dbdic; static final int DATABASE_VERSION = 1; static final String DICTIONARY_DATABASE_NAME = "dictionarydb"; static final String DICTIONARY_TABLE_NAME = "dictionary"; private static final UriMatcher sUriMatcher; private static HashMap<String, String> sDicProjectionMap; @Override public int delete(Uri arg0, String arg1, String[] arg2) { // TODO Auto-generated method stub return 0; } @Override public String getType(Uri arg0) { // TODO Auto-generated method stub return null; } @Override public Uri insert(Uri arg0, ContentValues arg1) { // TODO Auto-generated method stub return null; } @Override public boolean onCreate() { // TODO Auto-generated method stub dbdic = new DictionaryOpenHelper(getContext(), DICTIONARY_DATABASE_NAME, null, DATABASE_VERSION); return true; } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); qb.setTables(DICTIONARY_TABLE_NAME); switch (sUriMatcher.match(uri)) { case 1: qb.setProjectionMap(sDicProjectionMap); break; case 2: qb.setProjectionMap(sDicProjectionMap); qb.appendWhere(DicColumns._ID + "=" + uri.getPathSegments().get(1)); break; default: throw new IllegalArgumentException("Unknown URI " + uri); } // If no sort order is specified use the default String orderBy; if (TextUtils.isEmpty(sortOrder)) { orderBy = DicColumns.DEFAULT_SORT_ORDER; } else { orderBy = sortOrder; } // Get the database and run the query SQLiteDatabase db = dbdic.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); // Tell the cursor what uri to watch, so it knows when its source data changes c.setNotificationUri(getContext().getContentResolver(), uri); return c; } @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { // TODO Auto-generated method stub return 0; } static { sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); sUriMatcher.addURI(Dictionary.AUTHORITY, "dictionary", 1); sUriMatcher.addURI(Dictionary.AUTHORITY, "dictionary/#", 2); sDicProjectionMap = new HashMap<String, String>(); sDicProjectionMap.put(DicColumns._ID, DicColumns._ID); sDicProjectionMap.put(DicColumns.KEY_WORD, DicColumns.KEY_WORD); sDicProjectionMap.put(DicColumns.KEY_DEFINITION, DicColumns.KEY_DEFINITION); // Support for Live Folders. /*sLiveFolderProjectionMap = new HashMap<String, String>(); sLiveFolderProjectionMap.put(LiveFolders._ID, NoteColumns._ID + " AS " + LiveFolders._ID); sLiveFolderProjectionMap.put(LiveFolders.NAME, NoteColumns.TITLE + " AS " + LiveFolders.NAME);*/ // Add more columns here for more robust Live Folders. } } // file Dictionary.java package com.example.helloandroid; import android.net.Uri; import android.provider.BaseColumns; /** * Convenience definitions for DictionaryProvider */ public final class Dictionary { public static final String AUTHORITY = "com.example.helloandroid.provider.Dictionary"; // This class cannot be instantiated private Dictionary() {} /** * Dictionary table */ public static final class DicColumns implements BaseColumns { // This class cannot be instantiated private DicColumns() {} /** * The content:// style URL for this table */ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/dictionary"); /** * The MIME type of {@link #CONTENT_URI} providing a directory of notes. */ //public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.note"; /** * The MIME type of a {@link #CONTENT_URI} sub-directory of a single note. */ //public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.google.note"; /** * The default sort order for this table */ public static final String DEFAULT_SORT_ORDER = "modified DESC"; /** * The key_word of the dictionary * <P>Type: TEXT</P> */ public static final String KEY_WORD = "KEY_WORD"; /** * The key_definition of word * <P>Type: TEXT</P> */ public static final String KEY_DEFINITION = "KEY_DEFINITION"; } } thanks so much

    Read the article

  • why my application sometimes got error in early launch?

    - by Hendra
    I have some problem. sometimes when I just try to run my application, it is going to be force close. I don't know why it is going to be happened. here are my source code. AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setCancelable(false); //AlertDialog.Builder alert = new AlertDialog.Builder(this); ..... alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { no_pasien = no_pas.getText().toString(); new LoginProses().execute(); ..... alert.show(); class LoginProses extends AsyncTask<String, String, String> { protected void onPreExecute() { super.onPreExecute(); ...... } protected String doInBackground(String... args) { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("no_pasien", no)); JSONObject json = jsonParser.makeHttpRequest(url_login, "POST", params); try { int success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully created product pasien = json.getJSONArray("pasien"); JSONObject c = pasien.getJSONObject(0); int id = c.getInt("id"); new Temporary().setIdPasien(id); Intent goMainAct = new Intent(); // goMainAct.putExtra("id", id); goMainAct.setClass(Login.this, MainActivity.class); finish(); startActivity(goMainAct); } else { // failed to create product Intent getReload = getIntent(); getReload.putExtra("status", 1); finish(); startActivity(getReload); } } catch (JSONException e) { if(pDialog.isShowing()){ pDialog.dismiss(); } } return null; } protected void onPostExecute(String file_url) { // dismiss the dialog once done pDialog.dismiss(); } } here is the log error for my problem: //HERE IS THE LOG: 06-25 22:57:23.836: E/WindowManager(7630): Activity com.iteadstudio.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41939850 that was originally added here 06-25 22:57:23.836: E/WindowManager(7630): android.view.WindowLeaked: Activity com.iteadstudio.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41939850 that was originally added here 06-25 22:57:23.836: E/WindowManager(7630): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:344) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.Window$LocalWindowManager.addView(Window.java:537) 06-25 22:57:23.836: E/WindowManager(7630): at android.app.Dialog.show(Dialog.java:278) 06-25 22:57:23.836: E/WindowManager(7630): at com.iteadstudio.Login$LoginProses.onPreExecute(Login.java:122) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.AsyncTask.execute(AsyncTask.java:511) 06-25 22:57:23.836: E/WindowManager(7630): at com.iteadstudio.Login$3.onClick(Login.java:95) 06-25 22:57:23.836: E/WindowManager(7630): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.Handler.dispatchMessage(Handler.java:99) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.Looper.loop(Looper.java:137) 06-25 22:57:23.836: E/WindowManager(7630): at android.app.ActivityThread.main(ActivityThread.java:4441) 06-25 22:57:23.836: E/WindowManager(7630): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 22:57:23.836: E/WindowManager(7630): at java.lang.reflect.Method.invoke(Method.java:511) 06-25 22:57:23.836: E/WindowManager(7630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 06-25 22:57:23.836: E/WindowManager(7630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 06-25 22:57:23.836: E/WindowManager(7630): at dalvik.system.NativeStart.main(Native Method) 06-25 22:57:23.946: D/dalvikvm(7630): GC_CONCURRENT freed 782K, 6% free 14319K/15203K, paused 4ms+3ms 06-25 22:57:23.976: D/AndroidRuntime(7630): Shutting down VM 06-25 22:57:23.976: W/dalvikvm(7630): threadid=1: thread exiting with uncaught exception (group=0x40ab4210) 06-25 22:57:23.986: E/AndroidRuntime(7630): FATAL EXCEPTION: main 06-25 22:57:23.986: E/AndroidRuntime(7630): java.lang.IllegalArgumentException: View not attached to window manager 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:587) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:324) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:151) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.Dialog.dismissDialog(Dialog.java:321) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.Dialog$1.run(Dialog.java:119) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.Dialog.dismiss(Dialog.java:306) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.iteadstudio.Login$LoginProses.onPostExecute(Login.java:177) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.iteadstudio.Login$LoginProses.onPostExecute(Login.java:1) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.AsyncTask.finish(AsyncTask.java:602) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.AsyncTask.access$600(AsyncTask.java:156) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.Handler.dispatchMessage(Handler.java:99) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.Looper.loop(Looper.java:137) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.ActivityThread.main(ActivityThread.java:4441) 06-25 22:57:23.986: E/AndroidRuntime(7630): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 22:57:23.986: E/AndroidRuntime(7630): at java.lang.reflect.Method.invoke(Method.java:511) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 06-25 22:57:23.986: E/AndroidRuntime(7630): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • setting up linked list Java

    - by erp
    I'm working on some basic linked list stuff, like insert, delete, go to the front or end of the list, and basically i understand the concept of all of that stuff once i have the list i guess but im having trouble setting up the list. I was wondering of you guys could tell me if im going in the right direction. (mostly just the setup) this is what i have so far: public class List { private int size; private List linkedList; List head; List cur; List next; /** * Creates an empty list. * @pre * @post */ public List(){ linkedList = new List(); this.head = null; cur = head; } /** * Delete the current element from this list. The element after the deleted element becomes the new current. * If that's not possible, then the element before the deleted element becomes the new current. * If that is also not possible, then you need to recognize what state the list is in and define current accordingly. * Nothing should be done if a delete is not possible. * @pre * @post */ public void delete(){ // delete size--; } /** * Get the value of the current element. If this is not possible, throw an IllegalArgumentException. * @pre the list is not empty * @post * @return value of the current element. */ public char get(){ return getItem(cur); } /** * Go to the last element of the list. If this is not possible, don't change the cursor. * @pre * @post */ public void goLast(){ while (cur.next != null){ cur = cur.next; } } /** * Advance the cursor to the next element. If this is not possible, don't change the cursor. * @pre * @post */ public void goNext(){ if(cur.next != null){ cur = cur.next;} //else do nothing } /** * Retreat the cursor to the previous element. If this is not possible, don't change the cursor. * @pre * @post */ public void goPrev(){ } /** * Go to top of the list. This is the position before the first element. * @pre * @post */ public void goTop(){ } /** * Go to first element of the list. If this is not possible, don't change the cursor. * @pre * @post */ public void goFirst(){ } /** * Insert the given parameter after the current element. The newly inserted element becomes the current element. * @pre * @post * @param newVal : value to insert after the current element. */ public void insert(char newVal){ cur.setItem(newVal); size++; } /** * Determines if this list is empty. Empty means this list has no elements. * @pre * @post * @return true if the list is empty. */ public boolean isEmpty(){ return head == null; } /** * Determines the size of the list. The size of the list is the number of elements in the list. * @pre * @post * @return size which is the number of elements in the list. */ public int size(){ return size; } public class Node { private char item; private Node next; public Node() { } public Node(char item) { this.item = item; } public Node(char item, Node next) { this.item = item; this.next = next; } public char getItem() { return this.item; } public void setItem(char item) { this.item = item; } public Node getNext() { return this.next; } public void setNext(Node next) { this.next = next; } } } I got the node class alright (well i think it works alright), but is it necessary to even have that class? or can i go about it without even using it (just curious). And for example on the method get() in the list class can i not call that getItem() method from the node class because it's getting an error even though i thought that was the whole point for the node class. bottom line i just wanna make sure im setting up the list right. Thanks for any help guys, im new to linked list's so bear with me!

    Read the article

  • Java error starting with "log4j:WARN No appenders could be found for logger" in ZuckerReports SugarC

    - by Tom McDonnell
    Greetings all. I apologise for posting this problem here, but I do so in desperation after receiving no response on the SugarCRM forums. Even if a reader is unfamiliar with ZuckerReports or SugarCRM some general advice on Java may be of use to me. I have installed ZuckerReports v1.12 in SugarCRM 5.5.1. When I attempt to run a report I get the following error message. cmdline: javaw -classpath "custom/ZuckerReports/resources/;custom/ZuckerReports/resources/contact_counts_by_first_name.jasper_files/;modules/ZuckerReports/jasper/ant-1.7.1.jar;modules/ZuckerReports/jasper/antlr-2.7.6.jar;modules/ZuckerReports/jasper/asm-attrs.jar;modules/ZuckerReports/jasper/asm.jar;modules/ZuckerReports/jasper/barbecue-1.5-beta1.jar;modules/ZuckerReports/jasper/barcode4j-2.0.jar;modules/ZuckerReports/jasper/batik-anim.jar;modules/ZuckerReports/jasper/batik-awt-util.jar;modules/ZuckerReports/jasper/batik-bridge.jar;modules/ZuckerReports/jasper/batik-css.jar;modules/ZuckerReports/jasper/batik-dom.jar;modules/ZuckerReports/jasper/batik-ext.jar;modules/ZuckerReports/jasper/batik-gvt.jar;modules/ZuckerReports/jasper/batik-parser.jar;modules/ZuckerReports/jasper/batik-script.jar;modules/ZuckerReports/jasper/batik-svg-dom.jar;modules/ZuckerReports/jasper/batik-svggen.jar;modules/ZuckerReports/jasper/batik-util.jar;modules/ZuckerReports/jasper/batik-xml.jar;modules/ZuckerReports/jasper/bcel-5.2.jar;modules/ZuckerReports/jasper/bsh-2.0b4.jar;modules/ZuckerReports/jasper/castor-1.2.jar;modules/ZuckerReports/jasper/cglib-2.1.jar;modules/ZuckerReports/jasper/cincom-jr-xmla.jar;modules/ZuckerReports/jasper/commons-beanutils-1.8.2.jar;modules/ZuckerReports/jasper/commons-collections-3.2.1.jar;modules/ZuckerReports/jasper/commons-dbcp-1.2.2.jar;modules/ZuckerReports/jasper/commons-digester-1.7.jar;modules/ZuckerReports/jasper/commons-javaflow-20060411.jar;modules/ZuckerReports/jasper/commons-logging-1.1.jar;modules/ZuckerReports/jasper/commons-math-1.0.jar;modules/ZuckerReports/jasper/commons-pool-1.3.jar;modules/ZuckerReports/jasper/commons-vfs-1.0.jar;modules/ZuckerReports/jasper/dom4j-1.6.jar;modules/ZuckerReports/jasper/ehcache-1.1.jar;modules/ZuckerReports/jasper/eigenbase-properties-1.1.0.10924.jar;modules/ZuckerReports/jasper/eigenbase-resgen-1.3.0.11873.jar;modules/ZuckerReports/jasper/eigenbase-xom-1.3.0.11999.jar;modules/ZuckerReports/jasper/ejb3-persistence.jar;modules/ZuckerReports/jasper/groovy-all-1.5.5.jar;modules/ZuckerReports/jasper/hibernate-annotations.jar;modules/ZuckerReports/jasper/hibernate-commons-annotations.jar;modules/ZuckerReports/jasper/hibernate3.jar;modules/ZuckerReports/jasper/hsqldb-1.8.0-10.jar;modules/ZuckerReports/jasper/iText-2.1.0.jar;modules/ZuckerReports/jasper/iTextAsian.jar;modules/ZuckerReports/jasper/jakarta-bcel-20050813.jar;modules/ZuckerReports/jasper/jasperreports-3.7.1.jar;modules/ZuckerReports/jasper/jasperreports-chart-themes-3.6.2.jar;modules/ZuckerReports/jasper/jasperreports-extensions-3.5.3.jar;modules/ZuckerReports/jasper/jasperreports-fonts-3.6.1.jar;modules/ZuckerReports/jasper/javacup.jar;modules/ZuckerReports/jasper/javassist-3.4.GA.jar;modules/ZuckerReports/jasper/jaxen-1.1.1.jar;modules/ZuckerReports/jasper/jcommon-1.0.15.jar;modules/ZuckerReports/jasper/jdt-compiler-3.1.1.jar;modules/ZuckerReports/jasper/jfreechart-1.0.12.jar;modules/ZuckerReports/jasper/jpa.jar;modules/ZuckerReports/jasper/js_activation-1.1.jar;modules/ZuckerReports/jasper/js_axis-1.4patched.jar;modules/ZuckerReports/jasper/js_commons-codec-1.3.jar;modules/ZuckerReports/jasper/js_commons-discovery-0.2.jar;modules/ZuckerReports/jasper/js_commons-httpclient-3.1.jar;modules/ZuckerReports/jasper/js_jasperserver-common-ws-3.5.0.jar;modules/ZuckerReports/jasper/js_jaxrpc.jar;modules/ZuckerReports/jasper/js_mail-1.4.jar;modules/ZuckerReports/jasper/js_saaj-api-1.3.jar;modules/ZuckerReports/jasper/js_wsdl4j-1.5.1.jar;modules/ZuckerReports/jasper/jta.jar;modules/ZuckerReports/jasper/jxl-2.6.jar;modules/ZuckerReports/jasper/log4j-1.2.15.jar;modules/ZuckerReports/jasper/mondrian-3.1.1.12687-Jaspersoft.jar;modules/ZuckerReports/jasper/mysql-connector-java-3.1.11-bin.jar;modules/ZuckerReports/jasper/olap4j-0.9.7.145.jar;modules/ZuckerReports/jasper/png-encoder-1.5.jar;modules/ZuckerReports/jasper/poi-3.2-FINAL-20081019.jar;modules/ZuckerReports/jasper/rex-20080421.jar;modules/ZuckerReports/jasper/rhino-1.7R1.jar;modules/ZuckerReports/jasper/saaj-api-1.3.jar;modules/ZuckerReports/jasper/slf4j-api.jar;modules/ZuckerReports/jasper/slf4j-log4j12.jar;modules/ZuckerReports/jasper/spring.jar;modules/ZuckerReports/jasper/sqleonardo-2007.03.jar;modules/ZuckerReports/jasper/swingx-2007_10_07.jar;modules/ZuckerReports/jasper/xml-apis-ext.jar;modules/ZuckerReports/jasper/xml-apis.jar;modules/ZuckerReports/jasper/zuckerreports-1.0.jar" at.go_mobile.zuckerreports.JasperBatchMain custom/ZuckerReports/temp/aff882c1-684b-d2de-403e-4be367bc2f5f/cmd.properties 2&1 JasperBatchMain :: loading jasper design custom/ZuckerReports/resources/contact_counts_by_first_name.jasper JasperBatchMain :: getParameterValue(REPORT_PARAMETERS_MAP, java.util.Map) = null JasperBatchMain :: getParameterValue(JASPER_REPORT, net.sf.jasperreports.engine.JasperReport) = null JasperBatchMain :: getParameterValue(REPORT_CONNECTION, java.sql.Connection) = null JasperBatchMain :: getParameterValue(REPORT_MAX_COUNT, java.lang.Integer) = null JasperBatchMain :: getParameterValue(REPORT_DATA_SOURCE, net.sf.jasperreports.engine.JRDataSource) = null JasperBatchMain :: getParameterValue(REPORT_SCRIPTLET, net.sf.jasperreports.engine.JRAbstractScriptlet) = null JasperBatchMain :: getParameterValue(REPORT_LOCALE, java.util.Locale) = null JasperBatchMain :: getParameterValue(REPORT_RESOURCE_BUNDLE, java.util.ResourceBundle) = null JasperBatchMain :: getParameterValue(REPORT_TIME_ZONE, java.util.TimeZone) = null JasperBatchMain :: getParameterValue(REPORT_FORMAT_FACTORY, net.sf.jasperreports.engine.util.FormatFactory) = null JasperBatchMain :: getParameterValue(REPORT_CLASS_LOADER, java.lang.ClassLoader) = null JasperBatchMain :: getParameterValue(REPORT_URL_HANDLER_FACTORY, java.net.URLStreamHandlerFactory) = null JasperBatchMain :: getParameterValue(REPORT_FILE_RESOLVER, net.sf.jasperreports.engine.util.FileResolver) = null JasperBatchMain :: getParameterValue(REPORT_VIRTUALIZER, net.sf.jasperreports.engine.JRVirtualizer) = null JasperBatchMain :: getParameterValue(IS_IGNORE_PAGINATION, java.lang.Boolean) = null JasperBatchMain :: getParameterValue(REPORT_TEMPLATES, java.util.Collection) = null log4j:WARN No appenders could be found for logger (net.sf.jasperreports.extensions.ExtensionsEnviron ment). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" java.lang.IllegalArgumentException: Null 'key' argument. at org.jfree.data.DefaultKeyedValues.setValue(Default KeyedValues.java:229) at org.jfree.data.DefaultKeyedValues2D.setValue(Defau ltKeyedValues2D.java:337) at org.jfree.data.DefaultKeyedValues2D.addValue(Defau ltKeyedValues2D.java:303) at org.jfree.data.category.DefaultCategoryDataset.add Value(DefaultCategoryDataset.java:222) at net.sf.jasperreports.charts.fill.JRFillCategoryDat aset.customIncrement(JRFillCategoryDataset.java:14 3) at net.sf.jasperreports.engine.fill.JRFillElementData set.increment(JRFillElementDataset.java:175) at net.sf.jasperreports.engine.fill.JRCalculator.calc ulateVariables(JRCalculator.java:148) at net.sf.jasperreports.engine.fill.JRVerticalFiller. fillDetail(JRVerticalFiller.java:736) at net.sf.jasperreports.engine.fill.JRVerticalFiller. fillReportContent(JRVerticalFiller.java:272) at net.sf.jasperreports.engine.fill.JRVerticalFiller. fillReport(JRVerticalFiller.java:114) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill (JRBaseFiller.java:923) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill (JRBaseFiller.java:826) at net.sf.jasperreports.engine.fill.JRFiller.fillRepo rt(JRFiller.java:59) at at.go_mobile.zuckerreports.JasperBatchMain.main(Ja sperBatchMain.java:126) The same report runs correctly in another SugarCRM installation on the same server. The installation in which the report runs correctly is of the same version, and has the same version of the ZuckerReports module. The report previously ran correctly on both installations. I think that the only changes that have been made on the installation in which the report now does not work since the report was last successfully run are the additions of a few custom fields in the Contacts module. These changes should have nothing to do with ZuckerReports. I have tried uninstalling and reinstalling the ZuckerReports module, but the problem remains. A google search for the warnings given in the error message ie. * log4j:WARN No appenders could be found for logger (net.sf.jasperreports.extensions.ExtensionsEnviron ment). * log4j:WARN Please initialize the log4j system properly. Returns a few links (not specific to ZuckerReports) with tips similar to the following: * log4j.properties or log4j.xml needs to be on the classpath where log4j can find it. I cannot find a file with either of those names anywhere on my server, and yet the report can be run successfully on one of my SugarCRM installations. So I figure log4j must be being configured another way. Can anyone suggest a way to solve this problem? Or explain how I might discover how log4j is configured in ZuckerReports? Or explain how I might compare the working with the non-working installation in order to help find a solution? (I have tried searching for files containing "log4j" in both installations and comparing but all I can find are .jar files (nothing I can read with a text editor), and the .jar files found in each installation appear to be the same.)

    Read the article

  • selectOneMenu - java.lang.NullPointerException when adding record to the database (JSF2 and JPA2-OpenJPA)

    - by rogie
    Good day to all; I'm developing a program using JSF2 and JPA2 (OpenJPA). Im also using IBM Rapid App Dev't v8 with WebSphere App Server v8 test server. I have two simple entities, Employee and Department. Each Department has many Employees and each Employee belongs to a Department (using deptno and workdept). My problem occurs when i tried to add a new employee and selecting a department from a combo box (using selectOneMenu - populated from Department table): when i run the program, the following error messages appeared: An Error Occurred: java.lang.NullPointerException Caused by: java.lang.NullPointerException - java.lang.NullPointerException I also tried to make another program using Deptno and Workdept as String instead of integer, still doesn't work. Pls help. Im also a newbie. Tnx and God bless. Below are my codes, configurations and setup. Just tell me if there are some codes that I forgot to include. Im also using Derby v10.5 as my database: CREATE SCHEMA RTS; CREATE TABLE RTS.DEPARTMENT (DEPTNO INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), DEPTNAME VARCHAR(30)); ALTER TABLE RTS.DEPARTMENT ADD CONSTRAINT PK_DEPARTMNET PRIMARY KEY (DEPTNO); CREATE TABLE RTS.EMPLOYEE (EMPNO INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), NAME VARCHAR(50), WORKDEPT INTEGER); ALTER TABLE RTS.EMPLOYEE ADD CONSTRAINT PK_EMPLOYEE PRIMARY KEY (EMPNO); Employee and Department Entities package rts.entities; import java.io.Serializable; import javax.persistence.*; @Entity public class Employee implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int empno; private String name; //bi-directional many-to-one association to Department @ManyToOne @JoinColumn(name="WORKDEPT") private Department department; ....... getter and setter methods package rts.entities; import java.io.Serializable; import javax.persistence.*; import java.util.List; @Entity public class Department implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int deptno; private String deptname; //bi-directional many-to-one association to Employee @OneToMany(mappedBy="department") private List<Employee> employees; ....... getter and setter methods JSF 2 snipet using combo box (populated from Department table) <tr> <td align="left">Department</td> <td style="width: 5px">&#160;</td> <td><h:selectOneMenu styleClass="selectOneMenu" id="department1" value="#{pc_EmployeeAdd.employee.department}"> <f:selectItems value="#{DepartmentManager.departmentSelectList}" id="selectItems1"></f:selectItems> </h:selectOneMenu></td> </tr> package rts.entities.controller; import com.ibm.jpa.web.JPAManager; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import com.ibm.jpa.web.NamedQueryTarget; import com.ibm.jpa.web.Action; import javax.persistence.PersistenceUnit; import javax.annotation.Resource; import javax.transaction.UserTransaction; import rts.entities.Department; import java.util.List; import javax.persistence.Query; import java.util.ArrayList; import java.text.MessageFormat; import javax.faces.model.SelectItem; @SuppressWarnings("unchecked") @JPAManager(targetEntity = rts.entities.Department.class) public class DepartmentManager { ....... public List<SelectItem> getDepartmentSelectList() { List<Department> departmentList = getDepartment(); List<SelectItem> selectList = new ArrayList<SelectItem>(); MessageFormat mf = new MessageFormat("{0}"); for (Department department : departmentList) { selectList.add(new SelectItem(department, mf.format( new Object[] { department.getDeptname() }, new StringBuffer(), null).toString())); } return selectList; } Converter: package rts.entities.converter; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import rts.entities.Department; import rts.entities.controller.DepartmentManager; import com.ibm.jpa.web.TypeCoercionUtility; public class DepartmentConverter implements Converter { public Object getAsObject(FacesContext facesContext, UIComponent arg1, String entityId) { DepartmentManager departmentManager = (DepartmentManager) facesContext .getApplication().createValueBinding("#{DepartmentManager}") .getValue(facesContext); int deptno = (Integer) TypeCoercionUtility.coerceType("int", entityId); Department result = departmentManager.findDepartmentByDeptno(deptno); return result; } public String getAsString(FacesContext arg0, UIComponent arg1, Object object) { if (object instanceof Department) { return "" + ((Department) object).getDeptno(); } else { throw new IllegalArgumentException("Invalid object type:" + object.getClass().getName()); } } } Method for Add button: public String createEmployeeAction() { EmployeeManager employeeManager = (EmployeeManager) getManagedBean("EmployeeManager"); try { employeeManager.createEmployee(employee); } catch (Exception e) { logException(e); } return ""; } faces-conf.xml <converter> <converter-for-class>rts.entities.Department</converter-for-class> <converter-class>rts.entities.converter.DepartmentConverter</converter-class> </converter> Stack trace javax.faces.FacesException: java.lang.NullPointerException at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241) at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1147) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:722) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:886) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1655) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1650) Caused by: java.lang.NullPointerException at rts.entities.converter.DepartmentConverter.getAsString(DepartmentConverter.java:29) at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:656) at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(HtmlRendererUtils.java:444) at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:421) at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:359) at org.apache.myfaces.shared_impl.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:76) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:622) at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1320) at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263) at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239) ... 24 more

    Read the article

  • What would be a correct implemantation of JSF Converter if I need to get an Integer to run a query?

    - by Ignacio
    HI here's my code: List.xhmtl <h:selectOneMenu value="#{produtosController.items}"> <f:selectItems value="#{produtosController.itemsAvailableSelectOne}"/> </h:selectOneMenu> <h:commandButton action="#{produtosController.createByCodigos}" value="Buscar" /> My Controller Class with innner Converter implemantation @ManagedBean (name="produtosController") @SessionScoped public class ProdutosController { private Produtos current; private DataModel items = null; @EJB private controladores.ProdutosFacade ejbFacade; private PaginationHelper pagination; private int selectedItemIndex; public ProdutosController() { } public Produtos getSelected() { if (current == null) { current = new Produtos(); selectedItemIndex = -1; } return current; } private ProdutosFacade getFacade() { return ejbFacade; } public PaginationHelper getPagination() { if (pagination == null) { pagination = new PaginationHelper(10) { @Override public int getItemsCount() { return getFacade().count(); } @Override public DataModel createPageDataModel() { return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem()+getPageSize()})); } }; } return pagination; } public String prepareList() { recreateModel(); return "List"; } public String prepareView() { current = (Produtos)getItems().getRowData(); selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex(); return "View"; } public String prepareCreate() { current = new Produtos(); selectedItemIndex = -1; return "Create"; } public String create() { try { getFacade().create(current); JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("ProdutosCreated")); return prepareCreate(); } catch (Exception e) { JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured")); return null; } } public String createByMarcas() { items = new ListDataModel(ejbFacade.findByMarcas(current.getIdMarca())); updateCurrentItem(); return "List"; } public String createByModelos() { items = new ListDataModel(ejbFacade.findByModelos(current.getIdModelo())); updateCurrentItem(); return "List"; } public String createByCodigos(){ items = new ListDataModel(ejbFacade.findByCodigo(current.getCodigo())); updateCurrentItem(); return "List"; } public String prepareEdit() { current = (Produtos)getItems().getRowData(); selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex(); return "Edit"; } public String update() { try { getFacade().edit(current); JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("ProdutosUpdated")); return "View"; } catch (Exception e) { JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured")); return null; } } public String destroy() { current = (Produtos)getItems().getRowData(); selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex(); performDestroy(); recreateModel(); return "List"; } public String destroyAndView() { performDestroy(); recreateModel(); updateCurrentItem(); if (selectedItemIndex >= 0) { return "View"; } else { // all items were removed - go back to list recreateModel(); return "List"; } } private void performDestroy() { try { getFacade().remove(current); JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("ProdutosDeleted")); } catch (Exception e) { JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured")); } } private void updateCurrentItem() { int count = getFacade().count(); if (selectedItemIndex >= count) { // selected index cannot be bigger than number of items: selectedItemIndex = count-1; // go to previous page if last page disappeared: if (pagination.getPageFirstItem() >= count) { pagination.previousPage(); } } if (selectedItemIndex >= 0) { current = getFacade().findRange(new int[]{selectedItemIndex, selectedItemIndex+1}).get(0); } } public DataModel getItems() { if (items == null) { items = getPagination().createPageDataModel(); } return items; } private void recreateModel() { items = null; } public String next() { getPagination().nextPage(); recreateModel(); return "List"; } public String previous() { getPagination().previousPage(); recreateModel(); return "List"; } public SelectItem[] getItemsAvailableSelectMany() { return JsfUtil.getSelectItems(ejbFacade.findAll(), false); } public SelectItem[] getItemsAvailableSelectOne() { return JsfUtil.getSelectItems(ejbFacade.findAll(), true); } @FacesConverter(forClass=Produtos.class) public static class ProdutosControllerConverter implements Converter{ public Object getAsObject(FacesContext facesContext, UIComponent component, String value) { if (value == null || value.length() == 0) { return null; } ProdutosController controller = (ProdutosController)facesContext.getApplication().getELResolver(). getValue(facesContext.getELContext(), null, "produtosController"); return controller.ejbFacade.find(getKey(value)); } java.lang.Integer getKey(String value) { java.lang.Integer key; key = Integer.decode(value); return key; } String getStringKey(java.lang.Integer value) { StringBuffer sb = new StringBuffer(); sb.append(value); return sb.toString(); } public String getAsString(FacesContext facesContext, UIComponent component, Object object) { if (object == null) { return null; } if (object instanceof Produtos) { Produtos o = (Produtos) object; return getStringKey(o.getCodigo()); } else { throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: "+ProdutosController.class.getName()); } } } } and my EJB @Entity @ViewScoped @Table(name = "produtos") @NamedQueries({ @NamedQuery(name = "Produtos.findAll", query = "SELECT p FROM Produtos p"), @NamedQuery(name = "Produtos.findById", query = "SELECT p FROM Produtos p WHERE p.id = :id"), @NamedQuery(name = "Produtos.findByCodigo", query = "SELECT p FROM Produtos p WHERE p.codigo = :codigo"), @NamedQuery(name = "Produtos.findByDescripcion", query = "SELECT p FROM Produtos p WHERE p.descripcion = :descripcion"), @NamedQuery(name = "Produtos.findByImagen", query = "SELECT p FROM Produtos p WHERE p.imagen = :imagen"), @NamedQuery(name = "Produtos.findByMarcas", query="SELECT m FROM Produtos m WHERE m.idMarca.id = :idMarca"), @NamedQuery(name = "Produtos.findByModelos", query="SELECT m FROM Produtos m WHERE m.idModelo.id = :idModelo")}) public class Produtos implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private Integer id; @Column(name = "codigo") private Integer codigo; @Column(name = "descripcion") private String descripcion; @Column(name = "imagen") private String imagen; @JoinColumn(name = "id_modelo", referencedColumnName = "id") @ManyToOne(optional = false) private Modelos idModelo; @JoinColumn(name = "id_marca", referencedColumnName = "id") @ManyToOne(optional = false) private Marcas idMarca; public Produtos() { } public Produtos(Integer id) { this.id = id; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getCodigo() { return codigo; } public void setCodigo(Integer codigo) { this.codigo = codigo; } public String getDescripcion() { return descripcion; } public void setDescripcion(String descripcion) { this.descripcion = descripcion; } public String getImagen() { return imagen; } public void setImagen(String imagen) { this.imagen = imagen; } public Modelos getIdModelo() { return idModelo; } public void setIdModelo(Modelos idModelo) { this.idModelo = idModelo; } public Marcas getIdMarca() { return idMarca; } public void setIdMarca(Marcas idMarca) { this.idMarca = idMarca; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Produtos)) { return false; } Produtos other = (Produtos) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "" + codigo + ""; } }

    Read the article

  • Where should I put zoomIn in my MapActivity?

    - by Johny
    I'm writing an Android app, and I'd like to zoomIn as soon as the map has been loaded. I get the following error: java.lang.IllegalArgumentException: width and height must be > 0 This MapActivity - width and height must be > 0 question suggests the problem is the zoomIn() method is in the onCreate() method. But I get same error when I put it in the onResume() method. I've been searching for hours and I can't find anything about it at http://developer.android.com or anywhere else... Also I can't find a way to get the time point the map has been loaded. A "MapLoadedListener" or something like that... EDIT Here is my code: public class AMap extends MapActivity{ private final String LOG_TAG = this.getClass().getSimpleName(); private Context mContext; private Chronometer timer; private TextView tvCountdown; private RelativeLayout rl; private MapView mapView; private MapController mapController; private List<Overlay> mapOverlays; private PlayersOverlay playersOverlay; private Drawable drawable; private Builder endDialog; private ContextThemeWrapper ctw; private Handler mHandler = new Handler(); private Player player = new Player(); private StartTask startTask; private EndTask endTask; private MyDBAdapter mdba; private Cursor playersCursor; private UpdateBroadcastReceiver r; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_view); mContext = AMap.this; // set map mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapView.setFocusable(true); // find the relative layout rl = (RelativeLayout) findViewById(R.id.rl); // set the chronometer timer = (Chronometer) findViewById(R.id.tv_timer); timer.setBackgroundColor(Color.DKGRAY); // set the countdown textview tvCountdown = (TextView) findViewById(R.id.tv_countdown); // Open DB connection and get players Cursor mdba = new MyDBAdapter(mContext); mdba.open(); playersCursor = mdba.getGame(); // Get this player's id and location Intent starter = this.getIntent(); player.setId(starter.getIntExtra("id", 0)); player.setLatitude(starter.getDoubleExtra("lat", 0)); player.setLongitude(starter.getDoubleExtra("lon", 0)); // Set this player's location as map's center GeoPoint geoPoint = new GeoPoint((int) (player.getLatitude()*1E6), (int) (player.getLongitude()*1E6)); mapController = mapView.getController(); mapController.setCenter(geoPoint); mapController.setZoom(15); Log.d(LOG_TAG, "My playersCursor has "+playersCursor.getCount()+" rows"); // drawable is needed but not used drawable = this.getResources().getDrawable(R.drawable.ic_launcher); // set PlayersOverlay (locations and statuses) playersOverlay = new PlayersOverlay(player.getId(), playersCursor, drawable, this); mapOverlays = mapView.getOverlays(); mapOverlays.add(playersOverlay); mHandler.postDelayed(mUpdateTimeTask, 100); } private Runnable mUpdateTimeTask = new Runnable() { public void run() { int h = mapView.getLayoutParams().height; int w = mapView.getLayoutParams().width; Log.d(LOG_TAG, "w = "+w+" , h = "+h); mHandler.postAtTime(this, System.currentTimeMillis() + 1000); } }; @Override public void onAttachedToWindow(){ Log.d(LOG_TAG, "Attached to Window"); int h = mapView.getLayoutParams().height; int w = mapView.getLayoutParams().width; Log.d(LOG_TAG, " Attached to window: w = "+w+" , h = "+h); //mapController.zoomInFixing(screenPoint.x, screenPoint.y); } public void onWindowFocusChanged(boolean hasFocus){ Log.d(LOG_TAG, "Focus changed to: "+hasFocus); int h = mapView.getLayoutParams().height; int w = mapView.getLayoutParams().width; Log.d(LOG_TAG, " Window focus changed: w = "+w+" , h = "+h); //mapController.zoomInFixing(screenPoint.x, screenPoint.y); } @Override protected void onStart(){ super.onStart(); // Create and register the broadcast receiver for messages from service IntentFilter filter = new IntentFilter(AppConstants.iGAME_UPDATE); r = new UpdateBroadcastReceiver(); registerReceiver(r, filter); // Create the dialog for end of game ctw = new ContextThemeWrapper(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); endDialog = new AlertDialog.Builder(ctw); endDialog.setMessage("End of Game"); endDialog.setCancelable(false); endDialog.setNeutralButton("OK", new OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { Intent highScores = new Intent(AMap.this, HighScores.class); startActivity(highScores); playersCursor.close(); finish(); } }); } @Override protected void onStop() { if(!playersCursor.isClosed()) playersCursor.close(); unregisterReceiver(r); mdba.close(); super.onStop(); } @Override protected boolean isRouteDisplayed() { return false; } // Receives signal from NetworkService that DB has been updated public class UpdateBroadcastReceiver extends BroadcastReceiver { boolean startSignal, update, endSignal; @Override public void onReceive(Context context, Intent intent) { endSignal = intent.getBooleanExtra("endSignal", false); if(endSignal){ Log.d(LOG_TAG, "Game Update BroadcastReceiver received End Signal"); endTask = new EndTask(); endTask.execute(); return; } update = intent.getBooleanExtra("update", false); if(update){ Log.d(LOG_TAG, "Game Update BroadcastReceiver received game update"); playersCursor.requery(); mapView.invalidate(); return; } startSignal = intent.getBooleanExtra("startSignal", false); if(startSignal){ Log.d(LOG_TAG, "Game Update BroadcastReceiver received Start Signal"); startTask = new StartTask(); startTask.execute(); return; } } } class StartTask extends AsyncTask<Void,Integer,Void>{ private final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); private final long DELAY = 1200; @Override protected Void doInBackground(Void... params) { int i = 3; while(i>=0){ publishProgress(i); try { Thread.sleep(DELAY); } catch (InterruptedException e) { e.printStackTrace(); } i--; } return null; } @Override protected void onProgressUpdate(Integer... progress){ tg.startTone(ToneGenerator.TONE_PROP_PROMPT); tvCountdown.setText(""+progress[0]); } @Override protected void onPostExecute(Void result) { rl.removeView(tvCountdown); timer.setBase(SystemClock.elapsedRealtime()); timer.start(); //enable screen touches playersOverlay.setGameStarted(true); } } class EndTask extends AsyncTask<Void,Void,Void>{ @Override protected void onPreExecute(){ //disable screen touches playersOverlay.setEndOfGame(true); timer.stop(); } @Override protected Void doInBackground(Void... params) { return null; } @Override protected void onPostExecute(Void result) { try{ endDialog.show(); }catch(Exception e){ Toast.makeText(mContext, "End of game", Toast.LENGTH_LONG); Intent highScores = new Intent(AMap.this, HighScores.class); startActivity(highScores); playersCursor.close(); finish(); } mHandler.removeCallbacks(mUpdateTimeTask); } } }

    Read the article

  • Multiple database with Spring+Hibernate+JPA

    - by ziftech
    Hi everybody! I'm trying to configure Spring+Hibernate+JPA for work with two databases (MySQL and MSSQL) my datasource-context.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"> <!-- Data Source config --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${local.jdbc.driver}" p:url="${local.jdbc.url}" p:username="${local.jdbc.username}" p:password="${local.jdbc.password}"> </bean> <bean id="dataSourceRemote" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${remote.jdbc.driver}" p:url="${remote.jdbc.url}" p:username="${remote.jdbc.username}" p:password="${remote.jdbc.password}" /> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entity-manager-factory-ref="entityManagerFactory" /> <!-- JPA config --> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"> <property name="persistenceXmlLocations"> <list value-type="java.lang.String"> <value>classpath*:config/persistence.local.xml</value> <value>classpath*:config/persistence.remote.xml</value> </list> </property> <property name="dataSources"> <map> <entry key="localDataSource" value-ref="dataSource" /> <entry key="remoteDataSource" value-ref="dataSourceRemote" /> </map> </property> <property name="defaultDataSource" ref="dataSource" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:showSql="true" p:generateDdl="true"> </bean> </property> <property name="persistenceUnitManager" ref="persistenceUnitManager" /> <property name="persistenceUnitName" value="localjpa"/> </bean> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> </beans> each persistence.xml contains one unit, like this: <persistence-unit name="remote" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultNamingStrategy" /> <property name="hibernate.dialect" value="${remote.hibernate.dialect}" /> <property name="hibernate.hbm2ddl.auto" value="${remote.hibernate.hbm2ddl.auto}" /> </properties> </persistence-unit> PersistenceUnitManager cause following exception: Cannot resolve reference to bean 'persistenceUnitManager' while setting bean property 'persistenceUnitManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceUnitManager' defined in class path resource [config/datasource-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.lang.String] for property 'persistenceXmlLocation'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.util.ArrayList] to required type [java.lang.String] for property 'persistenceXmlLocation': no matching editors or conversion strategy found If left only one persistence.xml without list, every works fine but I need 2 units... I also try to find alternative solution for work with two databases in Spring+Hibernate context, so I would appreciate any solution new error after changing to persistenceXmlLocations No single default persistence unit defined in {classpath:config/persistence.local.xml, classpath:config/persistence.remote.xml} UPDATE: I add persistenceUnitName, it works, but only with one unit, still need help UPDATE: thanks, ChssPly76 I changed config files: datasource-context.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${local.jdbc.driver}" p:url="${local.jdbc.url}" p:username="${local.jdbc.username}" p:password="${local.jdbc.password}"> </bean> <bean id="dataSourceRemote" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${remote.jdbc.driver}" p:url="${remote.jdbc.url}" p:username="${remote.jdbc.username}" p:password="${remote.jdbc.password}"> </bean> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"> <property name="defaultPersistenceUnitName" value="pu1" /> </bean> <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"> <property name="persistenceXmlLocation" value="${persistence.xml.location}" /> <property name="defaultDataSource" ref="dataSource" /> <!-- problem --> <property name="dataSources"> <map> <entry key="local" value-ref="dataSource" /> <entry key="remote" value-ref="dataSourceRemote" /> </map> </property> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:showSql="true" p:generateDdl="true"> </bean> </property> <property name="persistenceUnitManager" ref="persistenceUnitManager" /> <property name="persistenceUnitName" value="pu1" /> <property name="dataSource" ref="dataSource" /> </bean> <bean id="entityManagerFactoryRemote" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:showSql="true" p:generateDdl="true"> </bean> </property> <property name="persistenceUnitManager" ref="persistenceUnitManager" /> <property name="persistenceUnitName" value="pu2" /> <property name="dataSource" ref="dataSourceRemote" /> </bean> <tx:annotation-driven /> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entity-manager-factory-ref="entityManagerFactory" /> <bean id="transactionManagerRemote" class="org.springframework.orm.jpa.JpaTransactionManager" p:entity-manager-factory-ref="entityManagerFactoryRemote" /> </beans> persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="pu1" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultNamingStrategy" /> <property name="hibernate.dialect" value="${local.hibernate.dialect}" /> <property name="hibernate.hbm2ddl.auto" value="${local.hibernate.hbm2ddl.auto}" /> </properties> </persistence-unit> <persistence-unit name="pu2" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultNamingStrategy" /> <property name="hibernate.dialect" value="${remote.hibernate.dialect}" /> <property name="hibernate.hbm2ddl.auto" value="${remote.hibernate.hbm2ddl.auto}" /> </properties> </persistence-unit> </persistence> Now it builds two entityManagerFactory, but both are for Microsoft SQL Server [main] INFO org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [ name: pu1 ...] [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: Microsoft SQL Server [main] INFO org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [ name: pu2 ...] [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: Microsoft SQL Server (but must MySQL) I suggest, that use only dataSource, dataSourceRemote (no substitution) is not worked. That's my last problem

    Read the article

  • JPA 2 and Hibernate 3.5.1 MEMBER OF query doesnt work.

    - by Ed_Zero
    I'm trying the following JPQL and it fails misserably: Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' MEMBER OF u.roles"); List users = query.query.getResultList(); I get the following exception: ERROR [main] PARSER.error(454) | <AST>:0:0: unexpected end of subtree java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT u FROM com.online.data.User u WHERE 'admin' MEMBER OF u.roles] ERROR [main] PARSER.error(454) | <AST>:0:0: expecting "from", found '<ASTNULL>' ... ... Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT u FROM com.online.data.User u WHERE 'admin' MEMBER OF u.roles] I have Spring 3.0.1.RELEASE, Hibernate 3.5.1-Final and maven to glue dependencies. User class: @Entity public class User { @Id @Column(name = "USER_ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(unique = true, nullable = false) private String username; private boolean enabled; @ElementCollection private Set<String> roles = new HashSet<String>(); ... } Spring configuration: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/tx/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <!-- Reading annotation driven configuration --> <tx:annotation-driven transaction-manager="transactionManager" /> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="maxActive" value="100" /> <property name="maxWait" value="1000" /> <property name="poolPreparedStatements" value="true" /> <property name="defaultAutoCommit" value="true" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> <property name="dataSource" ref="dataSource" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="true" /> <property name="databasePlatform" value="${hibernate.dialect}" /> </bean> </property> <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /> </property> <property name="jpaProperties"> <props> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.current_session_context_class">thread</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">false</prop> <prop key="hibernate.show_comments">true</prop> </props> </property> <property name="persistenceUnitName" value="punit" /> </bean> <bean id="JpaTemplate" class="org.springframework.orm.jpa.JpaTemplate"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> </beans> Persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence"> <persistence-unit name="punit" transaction-type="RESOURCE_LOCAL" /> </persistence> pom.xml maven dependencies. <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>${hibernate.version}</version> <type>pom</type> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.2.2</version> <type>jar</type> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-acl</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>jsr250-api</artifactId> <version>1.0</version> </dependency> <properties> <!-- Application settings --> <spring.version>3.0.1.RELEASE</spring.version> <hibernate.version>3.5.1-Final</hibernate.version> Im running a unit test to check the configuration and I am able to run other JPQL queries the only ones that I am unable to run are the IS EMPTY, MEMBER OF conditions. The complete unit test is as follows: TestIntegration @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/spring/dataLayer.xml"}) @Transactional @TransactionConfiguration public class TestUserDaoImplIntegration { @PersistenceContext private EntityManager em; @Test public void shouldTest() throws Exception { try { //WORKS Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' in elements(u.roles)"); List users = query.query.getResultList(); //DOES NOT WORK } catch (Exception e) { e.printStackTrace(); throw e; } try { Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' MEMBER OF u.roles"); List users = query.query.getResultList(); } catch (Exception e) { e.printStackTrace(); throw e; } } }

    Read the article

  • how to solve the error in GWT ?

    - by megala
    I created one GWT project in eclipse.It contained the following codings Program 1:Creategroup package com.crimson.creategroup; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import com.google.appengine.api.datastore.Key; import com.google.appengine.api.users.User; @Entity(name="CreateGroup") public class Creategroup { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key key; @Basic private User author; @Basic private String groupname; @Basic private String groupid; @Basic private String groupdesc; @Basic private String emailper; public Key getKey() { return key; } public void setAuthor(User author) { this.author = author; } public User getAuthor() { return author; } public void setGroupname(String groupname) { this.groupname = groupname; } public String getGroupname() { return groupname; } public void setGroupid(String groupid) { this.groupid = groupid; } public String getGroupid() { return groupid; } public void setGroupdesc(String groupdesc) { this.groupdesc = groupdesc; } public String getGroupdesc() { return groupdesc; } public void setEmailper(String emailper) { this.emailper = emailper; } public String getEmailper() { return emailper; } public Creategroup(String groupname,String groupid,String groupdesc ,String emailper) { this.groupname = groupname; this.groupid = groupid; this.groupdesc = groupdesc; this.emailper=emailper; } } Program 2:Creategroupservlet package com.crimson.creategroup; import java.io.IOException; import javax.persistence.EntityManager; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.google.appengine.api.users.User; import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserServiceFactory; import java.util.logging.Logger; public class Creategroupservlet extends HttpServlet{ private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(Creategroupservlet.class.getName()); public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); String groupname=req.getParameter("gname"); String groupid=req.getParameter("groupdesc"); String groupdesc=req.getParameter("gdesc"); String email=req.getParameter("eperm"); if (groupname == null) { System.out.println("Complete all the details"); } if (user != null) { log.info("Greeting posted by user " + user.getNickname() + "\n " + groupname+"\n" + groupid + "\n" + groupdesc + "\n" + email); final EntityManager em = EMF.get(); try { Creategroup group = new Creategroup(groupname,groupid,groupdesc,email); em.persist(group); } finally { em.close(); } } else { throw new IllegalArgumentException("anonymous posts not permitted!"); } resp.sendRedirect("/group.jsp"); } } Program 3:EMF package com.crimson.creategroup; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; public class EMF { private static final EntityManagerFactory emfInstance = Persistence.createEntityManagerFactory("transactions-optional"); private EMF() { } public static EntityManager get() { return emfInstance.createEntityManager(); } } Program 4:index.jsp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="com.google.appengine.api.users.User" %> <%@ page import="com.google.appengine.api.users.UserService" %> <%@ page import="com.google.appengine.api.users.UserServiceFactory" %> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href="Group.css"> <title>Add Group into DataStore</title> </head> <body> <div id="nav"> <% UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { response.sendRedirect("/group.jsp"); %> <% } else { %> <a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a> <% } %> </div> <h1>Create Group</h1> <table> <tr> <td colspan="2" style="font-weight:bold;"> This demo uses secured resources, so you need to be logged into your Gmail account.</td> </tr> </table> </body> </html> program 5:group.jsp <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="java.util.List" %> <%@ page import="javax.persistence.EntityManager" %> <%@ page import="com.google.appengine.api.users.User" %> <%@ page import="com.google.appengine.api.users.UserService" %> <%@ page import="com.google.appengine.api.users.UserServiceFactory" %> <%@ page import="com.crimson.creategroup.Creategroup" %> <%@ page import="com.crimson.creategroup.EMF" %> <html> <body> <% UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { %> <p>Hello, <%= user.getNickname() %>! (You can <a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p> <% } else { response.sendRedirect("/index.jsp"); } %> <% final EntityManager em = EMF.get(); try { String query = "select from " + Creategroup.class.getName(); List<Creategroup> groups = (List<Creategroup>) em.createQuery(query).getResultList(); if (groups.isEmpty()) { %> <p>This table not having any group</p> <% } else { for (Creategroup g : groups) { %> <p><b><%= g.getAuthor().getNickname() %></b> wrote:</p> <blockquote><%= g. getGroupname() %></blockquote> <blockquote><%= g. getGroupid() %></blockquote> <blockquote><%= g. getGroupdesc() %></blockquote> <blockquote><%= g. getEmailper() %></blockquote> <% } } } finally { em.close(); } %> <form action="/sign" method="post"> <input type="text" name="Groupname" size="25"> <input type="text" name="Groupid" size="25"> <input type="text" name="Groupdesc" size="250"> <input type="text" name="Emaildesc" size="25"> <div><input type="submit" value="CREATE GROUP" /></div> </form> </body> </html> Program 6:Web.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!-- Servlets --> <servlet> <servlet-name>Creategroupservlet</servlet-name> <servlet-class>com.crimson.creategroup.Creategroupservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Creategroupservlet</servlet-name> <url-pattern>sign in</url-pattern> </servlet-mapping> <!-- Default page to serve --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> Program 7:persistence.xml <?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="transactions-optional"> <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider> <properties> <property name="datanucleus.NontransactionalRead" value="true"/> <property name="datanucleus.NontransactionalWrite" value="true"/> <property name="datanucleus.ConnectionURL" value="appengine"/> </properties> </persistence-unit> </persistence but is shows the following error Missing required argument 'module[s]' Google Web Toolkit 2.0.0 DevMode [-noserver] [-port port-number | "auto"] [-whitelist whitelist-string] [-blacklist blacklist-string] [-logdir directory] [-logLevel level] [-gen dir] [-codeServerPort port-number | "auto"] [-server servletContainerLauncher] [-startupUrl url] [-war dir] [-extra dir] [-workDir dir] module[s] How to solve this thanks in advance?

    Read the article

  • Slowdowns when reading from an urlconnection's inputstream (even with byte[] and buffers)

    - by user342677
    Ok so after spending two days trying to figure out the problem, and reading about dizillion articles, i finally decided to man up and ask to for some advice(my first time here). Now to the issue at hand - I am writing a program which will parse api data from a game, namely battle logs. There will be A LOT of entries in the database(20+ million) and so the parsing speed for each battle log page matters quite a bit. The pages to be parsed look like this: http://api.erepublik.com/v1/feeds/battle_logs/10000/0. (see source code if using chrome, it doesnt display the page right). It has 1000 hit entries, followed by a little battle info(lastpage will have <1000 obviously). On average, a page contains 175000 characters, UTF-8 encoding, xml format(v 1.0). Program will run locally on a good PC, memory is virtually unlimited(so that creating byte[250000] is quite ok). The format never changes, which is quite convenient. Now, I started off as usual: //global vars,class declaration skipped public WebObject(String url_string, int connection_timeout, int read_timeout, boolean redirects_allowed, String user_agent) throws java.net.MalformedURLException, java.io.IOException { // Open a URL connection java.net.URL url = new java.net.URL(url_string); java.net.URLConnection uconn = url.openConnection(); if (!(uconn instanceof java.net.HttpURLConnection)) { throw new java.lang.IllegalArgumentException("URL protocol must be HTTP"); } conn = (java.net.HttpURLConnection) uconn; conn.setConnectTimeout(connection_timeout); conn.setReadTimeout(read_timeout); conn.setInstanceFollowRedirects(redirects_allowed); conn.setRequestProperty("User-agent", user_agent); } public void executeConnection() throws IOException { try { is = conn.getInputStream(); //global var l = conn.getContentLength(); //global var } catch (Exception e) { //handling code skipped } } //getContentStream and getLength methods which just return'is' and 'l' are skipped Here is where the fun part began. I ran some profiling (using System.currentTimeMillis()) to find out what takes long ,and what doesnt. The call to this method takes only 200ms on avg public InputStream getWebPageAsStream(int battle_id, int page) throws Exception { String url = "http://api.erepublik.com/v1/feeds/battle_logs/" + battle_id + "/" + page; WebObject wobj = new WebObject(url, 10000, 10000, true, "Mozilla/5.0 " + "(Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"); wobj.executeConnection(); l = wobj.getContentLength(); // global variable return wobj.getContentStream(); //returns 'is' stream } 200ms is quite expected from a network operation, and i am fine with it. BUT when i parse the inputStream in any way(read it into string/use java XML parser/read it into another ByteArrayStream) the process takes over 1000ms! for example, this code takes 1000ms IF i pass the stream i got('is') above from getContentStream() directly to this method: public static Document convertToXML(InputStream is) throws ParserConfigurationException, IOException, SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(is); doc.getDocumentElement().normalize(); return doc; } this code too, takes around 920ms IF the initial InputStream 'is' is passed in(dont read into the code itself - it just extracts the data i need by directly counting the characters, which can be done thanks to the rigid api feed format): public static parsedBattlePage convertBattleToXMLWithoutDOM(InputStream is) throws IOException { // Point A BufferedReader br = new BufferedReader(new InputStreamReader(is)); LinkedList ll = new LinkedList(); String str = br.readLine(); while (str != null) { ll.add(str); str = br.readLine(); } if (((String) ll.get(1)).indexOf("error") != -1) { return new parsedBattlePage(null, null, true, -1); } //Point B Iterator it = ll.iterator(); it.next(); it.next(); it.next(); it.next(); String[][] hits_arr = new String[1000][4]; String t_str = (String) it.next(); String tmp = null; int j = 0; for (int i = 0; t_str.indexOf("time") != -1; i++) { hits_arr[i][0] = t_str.substring(12, t_str.length() - 11); tmp = (String) it.next(); hits_arr[i][1] = tmp.substring(14, tmp.length() - 9); tmp = (String) it.next(); hits_arr[i][2] = tmp.substring(15, tmp.length() - 10); tmp = (String) it.next(); hits_arr[i][3] = tmp.substring(18, tmp.length() - 13); it.next(); it.next(); t_str = (String) it.next(); j++; } String[] b_info_arr = new String[9]; int[] space_nums = {13, 10, 13, 11, 11, 12, 5, 10, 13}; for (int i = 0; i < space_nums.length; i++) { tmp = (String) it.next(); b_info_arr[i] = tmp.substring(space_nums[i] + 4, tmp.length() - space_nums[i] - 1); } //Point C return new parsedBattlePage(hits_arr, b_info_arr, false, j); } I have tried replacing the default BufferedReader with BufferedReader br = new BufferedReader(new InputStreamReader(is), 250000); This didnt change much. My second try was to replace the code between A and B with: Iterator it = IOUtils.lineIterator(is, "UTF-8"); Same result, except this time A-B was 0ms, and B-C was 1000ms, so then every call to it.next() must have been consuming some significant time.(IOUtils is from apache-commons-io library). And here is the culprit - the time taken to parse the stream to string, be it by an iterator or BufferedReader in ALL cases was about 1000ms, while the rest of the code took 0ms(e.g. irrelevant). This means that parsing the stream to LinkedList, or iterating over it, for some reason was eating up a lot of my system resources. question was - why? Is it just the way java is made...no...thats just stupid, so I did another experiment. In my main method I added after the getWebPageAsStream(): //Point A ba = new byte[l]; // 'l' comes from wobj.getContentLength above bytesRead = is.read(ba); //'is' is our URLConnection original InputStream offset = bytesRead; while (bytesRead != -1) { bytesRead = is.read(ba, offset - 1, l - offset); offset += bytesRead; } //Point B InputStream is2 = new ByteArrayInputStream(ba); //Now just working with 'is2' - the "copied" stream The InputStream-byte[] conversion took again 1000ms - this is the way many ppl suggested to read an InputStream, and stil it is slow. And guess what - the 2 parser methods above (convertToXML() and convertBattlePagetoXMLWithoutDOM(), when passed 'is2' instead of 'is' took, in all 4 cases, under 50ms to complete. I read a suggestion that the stream waits for connection to close before unblocking, so i tried using HttpComponentsClient 4.0 (http://hc.apache.org/httpcomponents-client/index.html) instead, but the initial InputStream took just as long to parse. e.g. this code: public InputStream getWebPageAsStream2(int battle_id, int page) throws Exception { String url = "http://api.erepublik.com/v1/feeds/battle_logs/" + battle_id + "/" + page; HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(url); HttpParams p = new BasicHttpParams(); HttpConnectionParams.setSocketBufferSize(p, 250000); HttpConnectionParams.setStaleCheckingEnabled(p, false); HttpConnectionParams.setConnectionTimeout(p, 5000); httpget.setParams(p); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); l = (int) entity.getContentLength(); return entity.getContent(); } took even longer to process(50ms more for just the network) and the stream parsing times remained the same. Obviously it can be instantiated so as to not create HttpClient and properties every time(faster network time), but the stream issue wont be affected by that. So we come to the center problem - why does the initial URLConnection InputStream(or HttpClient InputStream) take so long to process, while any stream of same size and content created locally is orders of magnitude faster? I mean, the initial response is already somewhere in RAM, and I cant see any good reasong why it is processed so slowly compared to when a same stream is just created from a byte[]. Considering I have to parse million of entries and thousands of pages like that, a total processing time of almost 1.5s/page seems WAY WAY too long. Any ideas? P.S. Please ask in any more code is required - the only thing I do after parsing is make a PreparedStatement and put the entries into JavaDB in packs of 1000+, and the perfomance is ok ~ 200ms/1000entries, prb could be optimized with more cache but I didnt look into it much.

    Read the article

  • GWT Deserialisation of Persistent Entities (JPA)

    - by slartidan
    Hi everyone, I am currently developing Java/GWT-application which is hosted on a weblogic application server. I am using EJB3.0 with EclipseLink as persistence layer. Sadly my GWT has problems to deserialize persistent entities. It might be helpful for you to know, that I have the EclipseLink-Library in my classpath (including javax.persistence.Entity) am not recieving the persistence objects from a database or persistence-manager - I am creating the objects with standard java code use Eclipse IDE for Java EE Developers for development and deploying and I am compiling my GWT code with the GWT-Plugin (GWT 2.1.0) - my source code is split up in several projects am pretty sure, that the problems occures on client side, since the HTTP response of my server is the same in my working and in my not working example tried to patch javax.persistence.Entity and tried to include several libraries which included javax.persistence.Entity but nothing was helping In my server provides a list of instances of class SerialClass; the interface looks like this: public interface GreetingService extends RemoteService { List<SerialClass> greetServer(); } My onModuleLoad()-Method gets those instances and creates a browser-popup with the information: public void onModuleLoad() { GreetingServiceAsync server = (GreetingServiceAsync) GWT.create(GreetingService.class); server.greetServer(new AsyncCallback<List<SerialClass>>() { public void onFailure(Throwable caught) { } public void onSuccess(List<SerialClass> result) { String resultString = ""; try { for (SerialClass serial : result) { if (serial == null) { resultString += "null "; } else { resultString += ">" + serial.id + "< "; } } } catch (Throwable t) { Window.alert("failed to process"); } Window.alert("success:" + resultString); } }); } My server is looking like this: public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService { public List<SerialClass> greetServer() throws IllegalArgumentException { List<SerialClass> list = new ArrayList<SerialClass>(); for (int i = 0; i < 100; i++) { list.add(new SerialClass()); } return list; } } Case 1 = everything works fine I am using this SerialClass (either without any annotation, or with any annotation other than Entity - for example javax.persistence.PersistenceContext works fine): //@Entity public class SerialClass implements Serializable, IsSerializable { public int id = 4711; } The popup contains (as expected): success:>4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< >4711< The data sent over HTTP looks like this: //OK[4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,100,1,["java.util.ArrayList/3821976829","serial.shared.SerialClass/10650133"],0,6] Case 2 = its not working at all I am using this SerialClass: @Entity public class SerialClass implements Serializable, IsSerializable { public int id = 4711; } My popup contains (THIS IS MY PROBLEM): success:>2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null >2< null The data sent over HTTP looks like this (exactly the same!): //OK[4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,4711,2,100,1,["java.util.ArrayList/3821976829","serial.shared.SerialClass/10650133"],0,6] There is no suspicious logging output - neither on server, nor on client. All HTTP-responses have return code 200. My current workaround I am going to try to create transfer objects as a copy of my SerialClass - those transfer objects will look exactly the same, but will not have the @Entity annotation. Alternatively I could try to use the RequestFactory (thanks to @Hilbrand for the hint). I really don't know how to solve that problem and I'm really thankful about any suggestions, hints, tips, links, etc.

    Read the article

  • StackOverFlowError while creating Mac object on AS400/Java

    - by Prasanna K Rao
    Hello all, I am a newbie to AS400-Java programming. I am trying to create my first program to test the implementation of Message Authentication Code (MAC). I am trying to use the HMACSHA1 hash function. My (Java 1.4) program runs fine on a dev box (V5R4).But fails terribly on the QA box (V5R3). My program is as below: ===================================================== import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Security; import java.security.Provider; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import javax.crypto.SecretKey; public class Test01 { private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; public static void main (String [] arguments) { byte[] key = { 1,2,3,4,5,6,7,8}; SecretKeySpec SHA1key = new SecretKeySpec(key, "HmacSHA1"); Mac hmac; String strFinalRslt = ""; try { hmac = Mac.getInstance("HmacSHA1"); hmac.init(SHA1key); byte[] result = hmac.doFinal(); strFinalRslt = toHexString(result); }catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (InvalidKeyException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch(StackOverflowError e){ e.printStackTrace(); } System.out.println(strFinalRslt); System.out.println("All done!!!"); } public static byte[] fromHexString ( String s ) { int stringLength = s.length(); if ( (stringLength & 0x1) != 0 ) { throw new IllegalArgumentException ( "fromHexString requires an even number of hex characters" ); } byte[] b = new byte[stringLength / 2]; for ( int i=0,j=0; i 4] ); //look up low nibble char sb.append( hexChar [b[i] & 0x0f] ); } return sb.toString(); } static char[] hexChar = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f'}; } This program compiles fine and gets the correct response on my win-xp client and also my dev box. But, fails with the following error on the QA box: java.lang.StackOverflowError at java.lang.Throwable.(Throwable.java:180) at java.lang.Error.(Error.java:37) at java.lang.StackOverflowError.(StackOverflowError.java:24) at java.io.Os400FileSystem.list(Native method) at java.io.File.list(File.java:922) at javax.crypto.b.e(Unknown source) at javax.crypto.b.a(Unknown source) at javax.crypto.b.c(Unknown source) at javax.crypto.b£0.run(Unknown source) at javax.crypto.b.(Unknown source) at javax.crypto.Mac.getInstance(Unknown source) I have verified the java.security file and entry corresponding to the jce files are all ok. The DMPJVM command gives me the following response: Thu Jun 03 12:25:34 E Java Virtual Machine Information 016822/QPGMR/11111 ........................................................................ . Classpath . ........................................................................ java.version=1.4 sun.boot.class.path=/QIBM/ProdData/OS400/Java400/jdk/lib/jdkptf14.zip:/QIBM /ProdData/OS400/Java400/ext/ibmjssefw.jar:/QIBM/ProdData/CAP/ibmjsseprovide r.jar:/QIBM/ProdData/OS400/Java400/ext/ibmjsseprovider2.jar:/QIBM/ProdData/ OS400/Java400/ext/ibmpkcs11impl.jar:/QIBM/ProdData/CAP/ibmjssefips.jar:/QIB M/ProdData/OS400/Java400/jdk/lib/IBMiSeriesJSSE.jar:/QIBM/ProdData/OS400/Ja va400/jdk/lib/jce.jar:/QIBM/ProdData/OS400/Java400/jdk/lib/jaas.jar:/QIBM/P rodData/OS400/Java400/jdk/lib/ibmcertpathfw.jar:/QIBM/ProdData/OS400/Java40 0/jdk/lib/ibmcertpathprovider.jar:/QIBM/ProdData/OS400/Java400/ext/ibmpkcs. jar:/QIBM/ProdData/OS400/Java400/jdk/lib/ibmjgssfw.jar:/QIBM/ProdData/OS400 /Java400/jdk/lib/ibmjgssprovider.jar:/QIBM/ProdData/OS400/Java400/jdk/lib/s ecurity.jar:/QIBM/ProdData/OS400/Java400/jdk/lib/charsets.jar:/QIBM/ProdDat a/OS400/Java400/jdk/lib/resources.jar:/QIBM/ProdData/OS400/Java400/jdk/lib/ rt.jar:/QIBM/ProdData/OS400/Java400/jdk/lib/sunrsasign.jar:/QIBM/ProdData/O S400/Java400/ext/IBMmisc.jar:/QIBM/ProdData/Java400/ java.class.path=/myhome/lib/commons-codec-1.3.jar:/myhome/lib/commons-httpc lient-3.1.jar:/myhome/lib/commons-logging-1.1.jar:/myhome/lib/log4j-1.2.15.jar:/myhome/lib/log4j-core.jar ; java.ext.dirs=/QIBM/ProdData/OS400/Java400/jdk/lib/ext:/QIBM/UserData/Java4 00/ext:/QIBM/ProdData/Java400/jdk14/lib/ext java.library.path=/QSYS.LIB/ROBOTLIB.LIB:/QSYS.LIB/QTEMP.LIB:/QSYS.LIB/ODIP GM.LIB:/QSYS.LIB/QGPL.LIB ........................................................................ . Garbage Collection . ........................................................................ Garbage collector parameters Initial size: 16384 K Max size: 240000000 K Current values Heap size: 437952 K Garbage collections: 58 Additional values JIT heap size: 53824 K JVM heap size: 55752 K Last GC cycle time: 1333 ms ........................................................................ . Thread information . ........................................................................ Information for 4 thread(s) of 4 thread(s) processed Thread: 00000004 Thread-0 TDE: B00380000BAA0000 Thread priority: 5 Thread status: Running Thread group: main Runnable: java/lang/Thread Stack: java/io/Os400FileSystem.list(Ljava/io/File;)[Ljava/lang/String;+0 (Os400FileSystem.java:0) java/io/File.list()[Ljava/lang/String;+19 (File.java:922) javax/crypto/b.e()[B+127 (:0) javax/crypto/b.a(Ljava/security/cert/X509Certificate;)V+7 (:0) javax/crypto/b.access$500(Ljava/security/cert/X509Certificate;)V+1 (:0) javax/crypto/b$0.run()Ljava/lang/Object;+98 (:0) javax/crypto/b.()V+507 (:0) javax/crypto/Mac.getInstance(Ljava/lang/String;)Ljavax/crypto/Mac;+10 (:0) Locks: None Thread: 00000007 jitcompilethread TDE: B00380000BD58000 Thread priority: 5 Thread status: Java wait Thread group: system Runnable: java/lang/Thread Stack: None Locks: None Thread: 00000005 Reference Handler TDE: B00380000BAAC000 Thread priority: 10 Thread status: Waiting Wait object: java/lang/ref/Reference$Lock Thread group: system Runnable: java/lang/ref/Reference$ReferenceHandler Stack: java/lang/Object.wait()V+1 (Object.java:452) java/lang/ref/Reference$ReferenceHandler.run()V+47 (Reference.java:169) Locks: None Thread: 00000006 Finalizer TDE: B00380000BAB3000 Thread priority: 8 Thread status: Waiting Wait object: java/lang/ref/ReferenceQueue$Lock Thread group: system Runnable: java/lang/ref/Finalizer$FinalizerThread Stack: java/lang/ref/ReferenceQueue.remove(J)Ljava/lang/ref/Reference;+43 (ReferenceQueue.java:111) java/lang/ref/ReferenceQueue.remove()Ljava/lang/ref/Reference;+1 (ReferenceQueue.java:127) java/lang/ref/Finalizer$FinalizerThread.run()V+3 (Finalizer.java:171) Locks: None ........................................................................ . Class loader information . ........................................................................ 0 Default class loader 1 sun/reflect/DelegatingClassLoader 2 sun/misc/Launcher$ExtClassLoader ........................................................................ . GC heap information . ........................................................................ Loader Objects Class name ------ ------- ---------- 0 1493 [C 0 2122181 java/lang/String 0 47 [Ljava/util/Hashtable$Entry; 0 68 [Ljava/lang/Object; 0 1016 java/lang/Class 0 31 java/util/HashMap 0 37 java/util/Hashtable 0 2 java/lang/ThreadGroup 0 2 java/lang/RuntimePermission 0 2 java/lang/ref/ReferenceQueue$Null 0 5 java/lang/ref/ReferenceQueue 0 50 java/util/Vector 0 4 java/util/Stack 0 3 sun/misc/SoftCache 0 1 [Ljava/lang/ThreadGroup; 0 5 [Ljava/io/ObjectStreamField; 0 1 sun/reflect/ReflectionFactory 0 7 java/lang/ref/ReferenceQueue$Lock 0 10 java/lang/Object 0 1 java/lang/String$CaseInsensitiveComparator 0 1 java/util/Hashtable$EmptyEnumerator 0 1 java/util/Hashtable$EmptyIterator 0 33 [Ljava/util/HashMap$Entry; 0 19210 [J 0 1 sun/nio/cs/StandardCharsets 0 5 java/util/TreeMap 0 1075 java/util/TreeMap$Entry 0 469 [Ljava/lang/String; 0 1 java/lang/StringBuffer 0 2 java/io/FileInputStream 0 2 java/io/FileOutputStream 0 2 java/io/BufferedOutputStream 0 1 java/lang/reflect/ReflectPermission 0 1 [[Ljava/lang/ref/SoftReference; 0 2 [Ljava/lang/ref/SoftReference; 0 2 sun/nio/cs/Surrogate$Parser 0 3 sun/misc/Signal 0 1 [Ljava/io/File; 0 6 java/io/File 0 1 java/util/BitSet 0 17 sun/reflect/NativeConstructorAccessorImpl 0 2 java/net/URLClassLoader$ClassFinder 0 12 java/util/ArrayList 0 32 java/io/RandomAccessFile 0 16 java/lang/Thread 0 1 java/lang/ref/Reference$ReferenceHandler 0 1 java/lang/ref/Finalizer$FinalizerThread 0 266 [B 0 2 java/util/Properties 0 71 java/lang/ref/Finalizer 0 2 com/ibm/nio/cs/DirectEncoder 0 38 java/lang/reflect/Constructor 0 33 java/util/jar/JarFile 0 19200 java/lang/StackOverflowError 0 5 java/security/AccessControlContext 0 2 [Ljava/lang/Thread; 0 4 java/lang/OutOfMemoryError 0 1065 java/util/Hashtable$Entry 0 1 java/io/BufferedInputStream 0 2 java/io/PrintStream 0 2 java/io/OutputStreamWriter 0 428 [I 0 3 java/lang/ClassLoader$NativeLibrary 0 25 java/util/Locale 0 3 sun/misc/URLClassPath 0 30 java/util/zip/Inflater 0 612 java/util/HashMap$Entry 0 2 java/io/FilePermission 0 10 java/io/ObjectStreamField 0 1 java/security/BasicPermissionCollection 0 2 java/security/ProtectionDomain 0 1 java/lang/Integer$1 0 1 java/lang/ref/Reference$Lock 0 1 java/lang/Shutdown$Lock 0 1 java/lang/Runtime 0 36 java/io/FileDescriptor 0 1 java/lang/Long$1 0 202 java/lang/Long 0 3 java/lang/ThreadLocal 0 3 java/nio/charset/CodingErrorAction 0 2 java/nio/charset/CoderResult 0 1 java/nio/charset/CoderResult$1 0 1 java/nio/charset/CoderResult$2 0 1 sun/misc/Unsafe 0 2 java/nio/ByteOrder 0 1 java/io/Os400FileSystem 0 3 java/lang/Boolean 0 1 java/lang/Terminator$1 0 23 java/lang/Integer 0 2 sun/misc/NativeSignalHandler 0 1 sun/misc/Launcher$Factory 0 1 sun/misc/Launcher 0 53 [Ljava/lang/Class; 0 1 java/lang/reflect/ReflectAccess 0 18 sun/reflect/DelegatingConstructorAccessorImpl 0 1 sun/net/www/protocol/file/Handler 0 3 java/util/HashSet 0 3 sun/net/www/protocol/jar/Handler 0 1 java/util/jar/JavaUtilJarAccessImpl 0 1 java/net/UnknownContentHandler 0 2 [Ljava/security/Principal; 0 10 [Ljava/security/cert/Certificate; 0 2 sun/misc/AtomicLongCSImpl 0 3 sun/reflect/DelegatingMethodAccessorImpl 0 1 sun/security/util/ByteArrayLexOrder 0 1 sun/security/util/ByteArrayTagOrder 0 7 sun/security/x509/CertificateVersion 0 7 sun/security/x509/CertificateSerialNumber 0 7 sun/security/x509/SerialNumber 0 7 sun/security/x509/CertificateAlgorithmId 0 7 sun/security/x509/CertificateIssuerName 0 60 sun/security/x509/RDN 0 60 [Lsun/security/x509/AVA; 0 67 sun/security/util/DerInputStream 0 3 [Ljava/math/BigInteger; 0 2 com/ibm/nio/cs/Converter 0 2 sun/nio/cs/StreamEncoder$CharsetSE 0 35 java/lang/ref/SoftReference 0 2 java/nio/HeapByteBuffer 0 2 java/io/BufferedWriter 0 33 sun/misc/URLClassPath$JarLoader 0 4 java/lang/ThreadLocal$ThreadLocalMap$Entry 0 76 java/net/URL 0 1 sun/misc/Launcher$ExtClassLoader 0 1 sun/misc/Launcher$AppClassLoader 0 4 java/lang/Throwable 0 7 java/lang/reflect/Method 0 2 sun/misc/URLClassPath$FileLoader 0 2 java/security/CodeSource 0 2 java/security/Permissions 0 2 java/io/FilePermissionCollection 0 1 java/lang/ThreadLocal$ThreadLocalMap 0 1 javax/crypto/spec/SecretKeySpec 0 17 java/util/jar/Attributes$Name 0 1 [Ljava/lang/ThreadLocal$ThreadLocalMap$Entry; 0 1 java/security/SecureRandom 0 2 sun/security/provider/Sun 0 1 java/util/jar/JarFile$JarFileEntry 0 1 java/util/jar/JarVerifier 0 3 sun/reflect/NativeMethodAccessorImpl 0 116 sun/security/util/ObjectIdentifier 0 1 java/lang/Package 0 2 [S 0 104 java/math/BigInteger 0 20 sun/security/x509/AlgorithmId 0 14 sun/security/x509/X500Name 0 14 [Lsun/security/x509/RDN; 0 60 sun/security/x509/AVA 0 67 sun/security/util/DerValue 0 67 sun/security/util/DerInputBuffer 0 21 sun/security/x509/AVAKeyword 0 6 sun/security/x509/X509CertImpl 0 7 sun/security/x509/X509CertInfo 0 1 [Lsun/security/util/ObjectIdentifier; 0 1 [[Ljava/lang/Byte; 0 3 [[B 0 7 sun/security/provider/DSAPublicKey 0 7 sun/security/x509/AuthorityKeyIdentifierExtension 0 12 [Ljava/lang/Byte; 0 14 java/lang/Byte 0 7 sun/security/x509/CertificateSubjectName 0 7 sun/security/x509/CertificateX509Key 0 14 sun/security/x509/KeyIdentifier 0 4 [Z 0 5 sun/text/Normalizer$Mode 0 7 sun/security/x509/CertificateValidity 0 14 java/util/Date 0 7 sun/security/provider/DSAParameters 0 7 sun/security/util/BitArray 0 7 sun/security/x509/CertificateExtensions 0 7 java/security/AlgorithmParameters 0 7 sun/security/x509/SubjectKeyIdentifierExtension 0 5 sun/security/x509/BasicConstraintsExtension 0 2 sun/security/x509/KeyUsageExtension 0 1 sun/text/CompactCharArray 0 1 sun/text/CompactByteArray 0 1 sun/net/www/protocol/jar/JarFileFactory 0 1 java/util/Collections$EmptySet 0 1 java/util/Collections$EmptyList 0 1 java/util/Collections$ReverseComparator 0 1 com/ibm/security/jgss/i18n/PropertyResource 0 1 javax/crypto/b$0 0 1 sun/security/provider/X509Factory 0 1 sun/reflect/BootstrapConstructorAccessorImpl 1 1 sun/reflect/GeneratedConstructorAccessor3202134454 2 1 com/ibm/crypto/provider/IBMJCE 0 6 java/util/ResourceBundle$LoaderReference 0 1 [Lsun/security/x509/NetscapeCertTypeExtension$MapEntry; 0 1 com/sun/rsajca/Provider 0 1 com/ibm/security/cert/IBMCertPath 0 1 com/ibm/as400/ibmonly/net/ssl/Provider 0 1 com/ibm/jsse/IBMJSSEProvider 0 1 com/ibm/security/jgss/IBMJGSSProvider 0 5 org/ietf/jgss/Oid 0 1 java/util/PropertyResourceBundle 0 7 java/util/ResourceBundle$ResourceCacheKey 0 2 sun/net/www/protocol/jar/URLJarFile 0 6 sun/misc/SoftCache$ValueCell 0 1 java/util/Random 0 1 java/util/Collections$EmptyMap 0 112 com/ibm/security/util/ObjectIdentifier 0 5 java/security/Security$ProviderProperty 0 1 java/security/cert/CertificateFactory 0 1 sun/security/provider/SecureRandom 0 2 java/security/MessageDigest$Delegate 0 2 sun/security/provider/SHA 0 1 sun/util/calendar/ZoneInfo 0 4 com/ibm/security/x509/X500Name 0 2 [Ljava/security/cert/X509Certificate; 0 1 sun/reflect/DelegatingClassLoader 0 1 sun/security/x509/NetscapeCertTypeExtension 0 7 sun/security/x509/NetscapeCertTypeExtension$MapEntry 0 3 [[Ljava/lang/String; 0 3 java/util/Arrays$ArrayList 0 7 com/ibm/security/x509/NetscapeCertTypeExtension$MapEntry 0 1 com/ibm/security/validator/EndEntityChecker 0 1 java/util/AbstractList$Itr 0 1 com/ibm/security/util/ByteArrayLexOrder 0 1 com/ibm/security/util/ByteArrayTagOrder 0 18 [Lcom/ibm/security/x509/AVA; 0 18 com/ibm/security/util/DerInputStream 0 5 com/ibm/security/util/text/Normalizer$Mode 0 1 com/ibm/security/validator/SimpleValidator 0 1 [Lcom/ibm/security/x509/NetscapeCertTypeExtension$MapEntry; 0 4 [Lcom/ibm/security/x509/RDN; 0 1 java/util/Hashtable$Enumerator 0 4 java/util/LinkedHashMap$Entry 0 1 sun/text/resources/LocaleElements 0 1 sun/text/resources/LocaleElements_en 0 22 com/ibm/security/x509/AVAKeyword 0 4 javax/security/auth/x500/X500Principal 0 18 com/ibm/security/x509/RDN 0 18 com/ibm/security/x509/AVA 0 18 com/ibm/security/util/DerInputBuffer 0 18 com/ibm/security/util/DerValue 0 1 com/ibm/security/util/text/CompactCharArray 0 1 com/ibm/security/util/text/CompactByteArray 0 2 java/util/LinkedHashMap 0 1 java/net/InetAddress$1 0 2 [Ljava/net/InetAddress; 0 2 java/net/InetAddress$Cache 0 1 java/net/Inet4AddressImpl 0 3 java/net/Inet4Address 0 2 java/net/InetAddress$CacheEntry ........................................................................ . Global registry information . ........................................................................ Loader Objects Class name ------ ------- ---------- 0 23 [C 0 1017 java/lang/Class 0 1 java/lang/ref/Reference$ReferenceHandler 0 1 java/lang/ref/Finalizer$FinalizerThread 0 1 sun/misc/Launcher$AppClassLoader 0 32 java/io/RandomAccessFile 0 32 [B Can someone please advise me? Thanks a lot, Prasanna

    Read the article

  • Trying to convert simple midlet application to Android application but running into problems.

    - by chobo2
    Hi I am trying to do some threading in Android so I took an old threading assignment I had done fora midlet and took out the midlet code and replaced it with android code(such as textview). package com.assignment1; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class Threading extends Activity { private TextView tortose; private TextView hare; private Thread hareThread; private Thread torotoseThread; private int num = 0; private int num2 = 0; public Threading() { } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tortose = (TextView) findViewById(R.id.TextView01); hare = (TextView) findViewById(R.id.TextView02); Hare newHare = new Hare(); hareThread = new Thread(newHare); hareThread.start(); Torotose newTortose = new Torotose(); torotoseThread = new Thread(newTortose); torotoseThread.start(); //updateDisplay(); } private synchronized void check(int value1, int value2) { if((value1-value2) >= 10) { try { wait(); } catch(Exception ex) { System.out.println(ex); } } } private synchronized void getGoing(int value1, int value2) { if((value1-value2) == 0) { try { notify(); } catch(Exception ex) { System.out.println(ex); } } } private class Hare extends Thread { public void run() { while(true) { num++; hare.setText(Integer.toString(num)); check(num, num2); try { // are threads different in andriod apps? Thread.sleep(100); // hareThread.sleep(100); } catch(Exception ex) { System.out.println(ex); } } } } private class Torotose extends Thread { public void run() { while(true) { num2++; tortose.setText(Integer.toString(num2)); getGoing(num,num2); try { Thread.sleep(200); //torotoseThread.sleep(200); } catch(Exception ex) { System.out.println(ex); } } } } } First it wanted me to change my threads to like static threads.So is this just how Android does it? Next when I run this code it just crashes with some unexpected error. I am not sure what the error is but when I try to debug it and goes to like to create a new "hare" object it shows me this. // Compiled from ClassLoader.java (version 1.5 : 49.0, super bit) public abstract class java.lang.ClassLoader { // Method descriptor #8 ()V // Stack: 3, Locals: 1 protected ClassLoader(); 0 aload_0 [this] 1 invokespecial java.lang.Object() [1] 4 new java.lang.RuntimeException [2] 7 dup 8 ldc <String "Stub!"> [3] 10 invokespecial java.lang.RuntimeException(java.lang.String) [4] 13 athrow Line numbers: [pc: 0, line: 4] Local variable table: [pc: 0, pc: 14] local: this index: 0 type: java.lang.ClassLoader // Method descriptor #14 (Ljava/lang/ClassLoader;)V // Stack: 3, Locals: 2 protected ClassLoader(java.lang.ClassLoader parentLoader); 0 aload_0 [this] 1 invokespecial java.lang.Object() [1] 4 new java.lang.RuntimeException [2] 7 dup 8 ldc <String "Stub!"> [3] 10 invokespecial java.lang.RuntimeException(java.lang.String) [4] 13 athrow Line numbers: [pc: 0, line: 5] Local variable table: [pc: 0, pc: 14] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 14] local: parentLoader index: 1 type: java.lang.ClassLoader // Method descriptor #17 ()Ljava/lang/ClassLoader; // Stack: 3, Locals: 0 public static java.lang.ClassLoader getSystemClassLoader(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 6] // Method descriptor #19 (Ljava/lang/String;)Ljava/net/URL; // Stack: 3, Locals: 1 public static java.net.URL getSystemResource(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 7] Local variable table: [pc: 0, pc: 10] local: resName index: 0 type: java.lang.String // Method descriptor #23 (Ljava/lang/String;)Ljava/util/Enumeration; // Signature: (Ljava/lang/String;)Ljava/util/Enumeration<Ljava/net/URL;>; // Stack: 3, Locals: 1 public static java.util.Enumeration getSystemResources(java.lang.String resName) throws java.io.IOException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 8] Local variable table: [pc: 0, pc: 10] local: resName index: 0 type: java.lang.String // Method descriptor #29 (Ljava/lang/String;)Ljava/io/InputStream; // Stack: 3, Locals: 1 public static java.io.InputStream getSystemResourceAsStream(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 9] Local variable table: [pc: 0, pc: 10] local: resName index: 0 type: java.lang.String // Method descriptor #31 ([BII)Ljava/lang/Class; // Signature: ([BII)Ljava/lang/Class<*>; // Stack: 3, Locals: 4 protected final java.lang.Class defineClass(byte[] classRep, int offset, int length) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 10] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: classRep index: 1 type: byte[] [pc: 0, pc: 10] local: offset index: 2 type: int [pc: 0, pc: 10] local: length index: 3 type: int // Method descriptor #39 (Ljava/lang/String;[BII)Ljava/lang/Class; // Signature: (Ljava/lang/String;[BII)Ljava/lang/Class<*>; // Stack: 3, Locals: 5 protected final java.lang.Class defineClass(java.lang.String className, byte[] classRep, int offset, int length) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 11] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String [pc: 0, pc: 10] local: classRep index: 2 type: byte[] [pc: 0, pc: 10] local: offset index: 3 type: int [pc: 0, pc: 10] local: length index: 4 type: int // Method descriptor #42 (Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class; // Signature: (Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class<*>; // Stack: 3, Locals: 6 protected final java.lang.Class defineClass(java.lang.String className, byte[] classRep, int offset, int length, java.security.ProtectionDomain protectionDomain) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 12] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String [pc: 0, pc: 10] local: classRep index: 2 type: byte[] [pc: 0, pc: 10] local: offset index: 3 type: int [pc: 0, pc: 10] local: length index: 4 type: int [pc: 0, pc: 10] local: protectionDomain index: 5 type: java.security.ProtectionDomain // Method descriptor #46 (Ljava/lang/String;Ljava/nio/ByteBuffer;Ljava/security/ProtectionDomain;)Ljava/lang/Class; // Signature: (Ljava/lang/String;Ljava/nio/ByteBuffer;Ljava/security/ProtectionDomain;)Ljava/lang/Class<*>; // Stack: 3, Locals: 4 protected final java.lang.Class defineClass(java.lang.String name, java.nio.ByteBuffer b, java.security.ProtectionDomain protectionDomain) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 13] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: name index: 1 type: java.lang.String [pc: 0, pc: 10] local: b index: 2 type: java.nio.ByteBuffer [pc: 0, pc: 10] local: protectionDomain index: 3 type: java.security.ProtectionDomain // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 protected java.lang.Class findClass(java.lang.String className) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 14] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 protected final java.lang.Class findLoadedClass(java.lang.String className); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 15] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 protected final java.lang.Class findSystemClass(java.lang.String className) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 16] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #17 ()Ljava/lang/ClassLoader; // Stack: 3, Locals: 1 public final java.lang.ClassLoader getParent(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 17] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader // Method descriptor #19 (Ljava/lang/String;)Ljava/net/URL; // Stack: 3, Locals: 2 public java.net.URL getResource(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 18] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #23 (Ljava/lang/String;)Ljava/util/Enumeration; // Signature: (Ljava/lang/String;)Ljava/util/Enumeration<Ljava/net/URL;>; // Stack: 3, Locals: 2 public java.util.Enumeration getResources(java.lang.String resName) throws java.io.IOException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 19] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #29 (Ljava/lang/String;)Ljava/io/InputStream; // Stack: 3, Locals: 2 public java.io.InputStream getResourceAsStream(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 20] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 public java.lang.Class loadClass(java.lang.String className) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 21] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #62 (Ljava/lang/String;Z)Ljava/lang/Class; // Signature: (Ljava/lang/String;Z)Ljava/lang/Class<*>; // Stack: 3, Locals: 3 protected java.lang.Class loadClass(java.lang.String className, boolean resolve) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 22] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String [pc: 0, pc: 10] local: resolve index: 2 type: boolean // Method descriptor #67 (Ljava/lang/Class;)V // Signature: (Ljava/lang/Class<*>;)V // Stack: 3, Locals: 2 protected final void resolveClass(java.lang.Class clazz); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 23] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: clazz index: 1 type: java.lang.Class Local variable type table: [pc: 0, pc: 10] local: clazz index: 1 type: java.lang.Class<?> // Method descriptor #19 (Ljava/lang/String;)Ljava/net/URL; // Stack: 3, Locals: 2 protected java.net.URL findResource(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 24] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #23 (Ljava/lang/String;)Ljava/util/Enumeration; // Signature: (Ljava/lang/String;)Ljava/util/Enumeration<Ljava/net/URL;>; // Stack: 3, Locals: 2 protected java.util.Enumeration findResources(java.lang.String resName) throws java.io.IOException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 25] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #76 (Ljava/lang/String;)Ljava/lang/String; // Stack: 3, Locals: 2 protected java.lang.String findLibrary(java.lang.String libName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 26] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: libName index: 1 type: java.lang.String // Method descriptor #79 (Ljava/lang/String;)Ljava/lang/Package; // Stack: 3, Locals: 2 protected java.lang.Package getPackage(java.lang.String name); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 27] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: name index: 1 type: java.lang.String // Method descriptor #81 ()[Ljava/lang/Package; // Stack: 3, Locals: 1 protected java.lang.Package[] getPackages(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 28] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader // Method descriptor #83 (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/net/URL;)Ljava/lang/Package; // Stack: 3, Locals: 9 protected java.lang.Package definePackage(java.lang.String name, java.lang.String specTitle, java.lang.String specVersion, java.lang.String specVendor, java.lang.String implTitle, java.lang.String implVersion, java.lang.String implVendor, java.net.URL sealBase) throws java.lang.IllegalArgumentException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 29] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: name index: 1 type: java.lang.String [pc: 0, pc: 10] local: specTitle index: 2 type: java.lang.String [pc: 0, pc: 10] local: specVersion index: 3 type: java.lang.String [pc: 0, pc: 10] local: specVendor index: 4 type: java.lang.String [pc: 0, pc: 10] local: implTitle index: 5 type: java.lang.String [pc: 0, pc: 10] local: implVersion index: 6 type: java.lang.String [pc: 0, pc: 10] local: implVendor index: 7 type: java.lang.String [pc: 0, pc: 10] local: sealBase index: 8 type: java.net.URL // Method descriptor #94 (Ljava/lang/Class;[Ljava/lang/Object;)V // Signature: (Ljava/lang/Class<*>;[Ljava/lang/Object;)V // Stack: 3, Locals: 3 protected final void setSigners(java.lang.Class c, java.lang.Object[] signers); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 30] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: c index: 1 type: java.lang.Class [pc: 0, pc: 10] local: signers index: 2 type: java.lang.Object[] Local variable type table: [pc: 0, pc: 10] local: c index: 1 type: java.lang.Class<?> // Method descriptor #100 (Ljava/lang/String;Z)V // Stack: 3, Locals: 3 public void setClassAssertionStatus(java.lang.String cname, boolean enable); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 31] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: cname index: 1 type: java.lang.String [pc: 0, pc: 10] local: enable index: 2 type: boolean // Method descriptor #100 (Ljava/lang/String;Z)V // Stack: 3, Locals: 3 public void setPackageAssertionStatus(java.lang.String pname, boolean enable); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 32] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: pname index: 1 type: java.lang.String [pc: 0, pc: 10] local: enable index: 2 type: boolean // Method descriptor #106 (Z)V // Stack: 3, Locals: 2 public void setDefaultAssertionStatus(boolean enable); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 33] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: enable index: 1 type: boolean // Method descriptor #8 ()V // Stack: 3, Locals: 1 public void clearAssertionStatus(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 34] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader } So I am not sure where I went wrong. Thanks

    Read the article

< Previous Page | 6 7 8 9 10