|
Hello.
I try to use com.sun.jersey.api.client.Client; com.sun.jersey.api.client.WebResource; on Android and get java.lang.NullPointerException on this simple code: Client client = Client.create(); String url = "http://google.com"; WebResource webResource = client.resource(url); if (webResource == null) { return; } String s = webResource.get(String.class); //java.lang.NullPointerException! Log.i("Test", s); return; the same works perfectly from PC. could you please take a look as you get a minute and help me? thank you, Nick |
|
Administrator
|
Hi Nick,
I need more details. What version of Jersey are you using? What is the stack trace? What JVM implementation are you using on the Android platform? Paul. On Dec 23, 2009, at 9:42 PM, Николай Панфилов wrote: Hello. |
|
Administrator
|
On Dec 29, 2009, at 8:01 PM, Николай Панфилов wrote: > Hello, Paul > >> Hi Nick, >> >> I need more details. >> >> What version of Jersey are you using? > 1.1.4.1 >> >> What is the stack trace? >> > java.lang.NullPointerException > at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119) > at > com.sun.jersey.api.client.ClientResponse.getType(ClientResponse.java: > 593) > at > com > .sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java: > 516) > at > com > .sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java: > 491) > at com.sun.jersey.api.client.WebResource.handle(WebResource.java: > 561) > at com.sun.jersey.api.client.WebResource.get(WebResource.java:179) > at > com.pnv.android.testjersey1.TestJersey1.onClick(TestJersey1.java:93) > at android.view.View.performClick(View.java:2364) > at android.view.View.onTouchEvent(View.java:4179) > at android.widget.TextView.onTouchEvent(TextView.java:6534) > at android.view.View.dispatchTouchEvent(View.java:3709) > at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) > at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) > at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) > at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) > at com.android.internal.policy.impl.PhoneWindow > $DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) > at > com > .android > .internal > .policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java: > 1107) > at android.app.Activity.dispatchTouchEvent(Activity.java:2061) > at com.android.internal.policy.impl.PhoneWindow > $DecorView.dispatchTouchEvent(PhoneWindow.java:1643) > at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) > at android.os.Handler.dispatchMessage(Handler.java:99) > at android.os.Looper.loop(Looper.java:123) > at android.app.ActivityThread.main(ActivityThread.java:4338) > at java.lang.reflect.Method.invokeNative(Native Method) > at java.lang.reflect.Method.invoke(Method.java:521) > at com.android.internal.os.ZygoteInit > $MethodAndArgsCaller.run(ZygoteInit.java:860) > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) > at dalvik.system.NativeStart.main(Native Method) > This implies that META-INF/services files are not being loaded. Could you try creating the Client as described in the following: http://markmail.org/search/?q=list %3Anet.java.dev.jersey.users#query:list%3Anet.java.dev.jersey.users +page:2+mid:ewm6lh2zuop6rcde+state:results >> What JVM implementation are you using on the Android platform? >> > > Android has its own custom JVM implementation called Dalvik. > Does Android require you to compile the Jersey source into something other than Java byte code and package it up a little differently? Paul. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Hi!
I'm also trying to use Jersey on Android. I've used the 1.1.5.1 version of the lib, but I receive the same error. About your last question Yes, it does. It recompiles the .class files into .dex files (Dalvik Virtual Machine specific bytecode). Is there any problem? What it is supposed to do with the META-INF/services files? Thanks! |
|
Administrator
|
On Apr 9, 2010, at 8:39 PM, Lucas Ventura wrote: > > Hi! > I'm also trying to use Jersey on Android. > I've used the 1.1.5.1 version of the lib, but I receive the same > error. > > About your last question > > Paul Sandoz wrote: >> >> >> On Dec 29, 2009, at 8:01 PM, Николай Панфилов wrote: >> >> Does Android require you to compile the Jersey source into something >> other than Java byte code and package it up a little differently? >> > Yes, it does. It recompiles the .class files into .dex files (Dalvik > Virtual > Machine specific bytecode). > Is there any problem? Not sure. It may be that you just need to package up the META-INF/ services files. > What it is supposed to do with the META-INF/services files? > Are you including those files in the android equivalent of a jar file? Also if you are merging say jersey-core, jersey-server etc together you may need to merge the contents of any META-INF/services of the same name. Jersey requires those files because they declare components for Jersey to function. Those files are really just a convention to define implementations of specific interfaces, the implementations of which Jersey requires to function correctly. Jersey attempts to class load those files. Paul. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Hi,
After some time, I'm retrying, with the v1.2 of the Jersey. I've included in the project, the *.jars: jersey-bundle.jar (http://download.java.net/maven/2/com/sun/jersey/jersey-bundle/1.2/jersey-bundle-1.2.jar) jsr311-api.jar (http://download.java.net/maven/2/javax/ws/rs/jsr311-api/1.1/jsr311-api-1.1.jar) as told in the user guide (https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#core_client) I'm including the *.jar as is. There is no specific *.jar. As far as I've readed, the precompiler doesn't reads the non-classes files, so I think that it is not reading the META-INF/services files. Is there anyway to define that implementations in code, not in that files? Thanks! |
|
Administrator
|
On May 28, 2010, at 11:21 AM, Lucas Ventura wrote:
<snip>
I would be surprised if ClassLoader.getResources ceased to function correctly to load resources (that method is used to load the META-INF/services files). But a quick search does indicate others are having similar issues with packaging and META-INF/services.
There might be a way. It is possible to override the META-INF/services lookup by using the following method: https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/service/ServiceFinder.html#setIteratorProvider%28com.sun.jersey.spi.service.ServiceFinder.ServiceIteratorProvider%29 So you could provide your own implementation. Paul. |
The problem after inspecting a little bit, is that the ClassLoader created by Google neither can't find services files, nor the class implementations. So I've provided a hardcoded implementation with the names of the classes indicateds in the META-INF/services files. The question is: when I should do this call to serIteratorProvider()? Because if I do before the Client creation it is looking for service jersey-client-components. If I do after, it works, but... will be called again with a that kind of serviceName?
Thanks a lot :)
|
|
Administrator
|
On Jun 9, 2010, at 9:16 AM, Lucas Ventura wrote: > Paul Sandoz wrote: > On May 28, 2010, at 11:21 AM, Lucas Ventura wrote: I would be > surprised if ClassLoader.getResources ceased to function correctly > to load resources (that method is used to load the META-INF/ > services files). But a quick search does indicate others are having > similar issues with packaging and META-INF/services. > The problem after inspecting a little bit, is that the ClassLoader > created by Google neither can't find services files, nor the class > implementations. Drat... Google forked Java platform :-) > Paul Sandoz wrote: > There might be a way. It is possible to override the META-INF/ > services lookup by using the following method: https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/service/ServiceFinder.html > #setIteratorProvider > %28com.sun.jersey.spi.service.ServiceFinder.ServiceIteratorProvider > %29 So you could provide your own implementation. Paul. > So I've provided a hardcoded implementation with the names of the > classes indicateds in the META-INF/services files. The question is: > when I should do this call to serIteratorProvider()? Because if I do > before the Client creation it is looking for service jersey-client- > components. Yes, that is expected. If a file META-INF/services/jersey-client- components is present it will contain one or more class names. You can just ignore this service name and return an empty iterator. I think the right general solution is to support a module concept a bit like Google Guice and remove as much of the META-INF/services stuff as possible (perhaps one file to declare a module for dynamic purposes). They it should be possible for developers to compose public modules that declare components. Paul. > If I do after, it works, but... will be called again with a that > kind of serviceName? Thanks a lot :) > View this message in context: Re: java.lang.NullPointerException on > Android > Sent from the Jersey mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Lucas Ventura
Lucas,
I am experiencing the same problem getting this to run on Android. I am hoping you would please post your workaround solution. I'd like to see how you implemented the hardcoded list and where you invoked it. Regards, Broc |
|
Hi!
Sorry for not posting my temporary solution. At the end I didn't use Jersey as client in Android anyway. In the client class: Client client = ApacheHttpClient.create(); ServiceFinder.setIteratorProvider(new Buscador());The Buscador class is:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import com.sun.jersey.spi.service.ServiceFinder.ServiceIteratorProvider;
public class Buscador<T> extends ServiceIteratorProvider<T>
{
private static final HashMap<String, String[]> SERVICES = new HashMap<String, String[]>();
private static final String[] com_sun_jersey_spi_HeaderDelegateProvider = new String[] {
"com.sun.jersey.core.impl.provider.header.LocaleProvider",
"com.sun.jersey.core.impl.provider.header.EntityTagProvider",
"com.sun.jersey.core.impl.provider.header.MediaTypeProvider",
"com.sun.jersey.core.impl.provider.header.CacheControlProvider",
"com.sun.jersey.core.impl.provider.header.NewCookieProvider",
"com.sun.jersey.core.impl.provider.header.CookieProvider",
"com.sun.jersey.core.impl.provider.header.URIProvider",
"com.sun.jersey.core.impl.provider.header.DateProvider",
"com.sun.jersey.core.impl.provider.header.StringProvider"
};
private static final String[] com_sun_jersey_spi_inject_InjectableProvider = new String[] {
"com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider",
"com.sun.jersey.core.impl.provider.xml.XMLStreamReaderContextProvider",
"com.sun.jersey.core.impl.provider.xml.DocumentBuilderFactoryProvider",
"com.sun.jersey.core.impl.provider.xml.TransformerFactoryProvider"
};
private static final String[] javax_ws_rs_ext_MessageBodyReader = new String[] {
"com.sun.jersey.core.impl.provider.entity.StringProvider",
"com.sun.jersey.core.impl.provider.entity.ByteArrayProvider",
"com.sun.jersey.core.impl.provider.entity.FileProvider",
"com.sun.jersey.core.impl.provider.entity.InputStreamProvider",
"com.sun.jersey.core.impl.provider.entity.DataSourceProvider",
"com.sun.jersey.core.impl.provider.entity.RenderedImageProvider",
"com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider",
"com.sun.jersey.core.impl.provider.entity.FormProvider",
"com.sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider",
"com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General",
"com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General",
"com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General",
"com.sun.jersey.core.impl.provider.entity.ReaderProvider",
"com.sun.jersey.core.impl.provider.entity.DocumentProvider",
"com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader",
"com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader",
"com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader",
"com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General",
"com.sun.jersey.core.impl.provider.entity.EntityHolderReader"
};
private static final String[] javax_ws_rs_ext_MessageBodyWriter = new String[] {
"com.sun.jersey.core.impl.provider.entity.StringProvider",
"com.sun.jersey.core.impl.provider.entity.ByteArrayProvider",
"com.sun.jersey.core.impl.provider.entity.FileProvider",
"com.sun.jersey.core.impl.provider.entity.InputStreamProvider",
"com.sun.jersey.core.impl.provider.entity.DataSourceProvider",
"com.sun.jersey.core.impl.provider.entity.RenderedImageProvider",
"com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider",
"com.sun.jersey.core.impl.provider.entity.FormProvider",
"com.sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider",
"com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General",
"com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General",
"com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App",
"com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text",
"com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General",
"com.sun.jersey.core.impl.provider.entity.ReaderProvider",
"com.sun.jersey.core.impl.provider.entity.DocumentProvider",
"com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider",
"com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter"
};
static
{
SERVICES.put("com.sun.jersey.spi.HeaderDelegateProvider",
com_sun_jersey_spi_HeaderDelegateProvider);
SERVICES.put("com.sun.jersey.spi.inject.InjectableProvider",
com_sun_jersey_spi_inject_InjectableProvider);
SERVICES.put("javax.ws.rs.ext.MessageBodyReader", javax_ws_rs_ext_MessageBodyReader);
SERVICES.put("javax.ws.rs.ext.MessageBodyWriter", javax_ws_rs_ext_MessageBodyWriter);
}
@SuppressWarnings("unchecked")
@Override
public Iterator<Class<T>> createClassIterator(Class<T> service, String serviceName,
ClassLoader loader, boolean ignoreOnClassNotFound)
{
String[] classesNames = SERVICES.get(serviceName);
int length = classesNames.length;
ArrayList<Class<T>> classes = new ArrayList<Class<T>>(length);
for (int i = 0; i < length; i++)
{
try
{
classes.add((Class<T>) Class.forName(classesNames[i]));
} catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
return null;
}
@Override
public Iterator<T> createIterator(Class<T> service, String serviceName, ClassLoader loader,
boolean ignoreOnClassNotFound)
{
String[] classesNames = SERVICES.get(serviceName);
int length = classesNames.length;
ArrayList<T> classes = new ArrayList<T>(length);
for (int i = 0; i < length; i++)
{
try
{
classes.add(service.cast(Class.forName(classesNames[i]).newInstance()));
} catch (IllegalAccessException e)
{
e.printStackTrace();
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
return classes.iterator();
}
}
This is based in the original Jersey look-up-for-services classes ;)
|
|
Hi Lucas,
Thanks for posting, this is useful information. I suspect we can write some code to automatically generate such a class for use on Android. Paul. On Aug 25, 2010, at 8:15 AM, Lucas Ventura wrote: > > Hi! > Sorry for not posting my temporary solution. At the end I didn't use > Jersey > as client in Android anyway. > In the client class: > > Client client = ApacheHttpClient.create(); > ServiceFinder.setIteratorProvider(new Buscador()); > > The Buscador class is: > > import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; > > import > com.sun.jersey.spi.service.ServiceFinder.ServiceIteratorProvider; > > public class Buscador<T> extends ServiceIteratorProvider<T> > { > private static final HashMap<String, String[]> SERVICES = new > HashMap<String, String[]>(); > > private static final String[] > com_sun_jersey_spi_HeaderDelegateProvider = > new String[] { > "com.sun.jersey.core.impl.provider.header.LocaleProvider", > "com.sun.jersey.core.impl.provider.header.EntityTagProvider", > "com.sun.jersey.core.impl.provider.header.MediaTypeProvider", > "com.sun.jersey.core.impl.provider.header.CacheControlProvider", > "com.sun.jersey.core.impl.provider.header.NewCookieProvider", > "com.sun.jersey.core.impl.provider.header.CookieProvider", > "com.sun.jersey.core.impl.provider.header.URIProvider", > "com.sun.jersey.core.impl.provider.header.DateProvider", > "com.sun.jersey.core.impl.provider.header.StringProvider" > > }; > private static final String[] > com_sun_jersey_spi_inject_InjectableProvider > = new String[] { > "com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider", > "com > .sun.jersey.core.impl.provider.xml.XMLStreamReaderContextProvider", > "com > .sun.jersey.core.impl.provider.xml.DocumentBuilderFactoryProvider", > "com.sun.jersey.core.impl.provider.xml.TransformerFactoryProvider" > }; > private static final String[] javax_ws_rs_ext_MessageBodyReader = new > String[] { > "com.sun.jersey.core.impl.provider.entity.StringProvider", > "com.sun.jersey.core.impl.provider.entity.ByteArrayProvider", > "com.sun.jersey.core.impl.provider.entity.FileProvider", > "com.sun.jersey.core.impl.provider.entity.InputStreamProvider", > "com.sun.jersey.core.impl.provider.entity.DataSourceProvider", > "com.sun.jersey.core.impl.provider.entity.RenderedImageProvider", > "com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider", > "com.sun.jersey.core.impl.provider.entity.FormProvider", > "com > .sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider", > "com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider > $Text", > > "com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider > $General", > "com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider > $Text", > > "com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider > $General", > "com.sun.jersey.core.impl.provider.entity.XMLListElementProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLListElementProvider > $Text", > > "com.sun.jersey.core.impl.provider.entity.XMLListElementProvider > $General", > "com.sun.jersey.core.impl.provider.entity.ReaderProvider", > "com.sun.jersey.core.impl.provider.entity.DocumentProvider", > > "com.sun.jersey.core.impl.provider.entity.SourceProvider > $StreamSourceReader", > > "com.sun.jersey.core.impl.provider.entity.SourceProvider > $SAXSourceReader", > > "com.sun.jersey.core.impl.provider.entity.SourceProvider > $DOMSourceReader", > "com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider > $Text", > "com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider > $General", > "com.sun.jersey.core.impl.provider.entity.EntityHolderReader" > }; > private static final String[] javax_ws_rs_ext_MessageBodyWriter = new > String[] { > "com.sun.jersey.core.impl.provider.entity.StringProvider", > "com.sun.jersey.core.impl.provider.entity.ByteArrayProvider", > "com.sun.jersey.core.impl.provider.entity.FileProvider", > "com.sun.jersey.core.impl.provider.entity.InputStreamProvider", > "com.sun.jersey.core.impl.provider.entity.DataSourceProvider", > "com.sun.jersey.core.impl.provider.entity.RenderedImageProvider", > "com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider", > "com.sun.jersey.core.impl.provider.entity.FormProvider", > "com > .sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider", > "com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider > $Text", > > "com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider > $General", > "com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider > $Text", > > "com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider > $General", > "com.sun.jersey.core.impl.provider.entity.XMLListElementProvider > $App", > "com.sun.jersey.core.impl.provider.entity.XMLListElementProvider > $Text", > > "com.sun.jersey.core.impl.provider.entity.XMLListElementProvider > $General", > "com.sun.jersey.core.impl.provider.entity.ReaderProvider", > "com.sun.jersey.core.impl.provider.entity.DocumentProvider", > "com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider", > "com.sun.jersey.core.impl.provider.entity.SourceProvider > $SourceWriter" > }; > > static > { > SERVICES.put("com.sun.jersey.spi.HeaderDelegateProvider", > com_sun_jersey_spi_HeaderDelegateProvider); > SERVICES.put("com.sun.jersey.spi.inject.InjectableProvider", > com_sun_jersey_spi_inject_InjectableProvider); > SERVICES.put("javax.ws.rs.ext.MessageBodyReader", > javax_ws_rs_ext_MessageBodyReader); > SERVICES.put("javax.ws.rs.ext.MessageBodyWriter", > javax_ws_rs_ext_MessageBodyWriter); > } > > @SuppressWarnings("unchecked") > @Override > public Iterator<Class<T>> createClassIterator(Class<T> service, > String > serviceName, > ClassLoader loader, boolean ignoreOnClassNotFound) > { > String[] classesNames = SERVICES.get(serviceName); > int length = classesNames.length; > ArrayList<Class<T>> classes = new ArrayList<Class<T>>(length); > for (int i = 0; i < length; i++) > { > try > { > classes.add((Class<T>) Class.forName(classesNames[i])); > } catch (ClassNotFoundException e) > { > e.printStackTrace(); > } > } > return null; > } > > @Override > public Iterator<T> createIterator(Class<T> service, String > serviceName, > ClassLoader loader, > boolean ignoreOnClassNotFound) > { > String[] classesNames = SERVICES.get(serviceName); > int length = classesNames.length; > ArrayList<T> classes = new ArrayList<T>(length); > for (int i = 0; i < length; i++) > { > try > { > > classes > .add(service.cast(Class.forName(classesNames[i]).newInstance())); > } catch (IllegalAccessException e) > { > e.printStackTrace(); > } catch (InstantiationException e) > { > e.printStackTrace(); > } catch (ClassNotFoundException e) > { > e.printStackTrace(); > } > } > return classes.iterator(); > } > } > > This is based in the original Jersey look-up-for-services classes ;) > -- > View this message in context: http://jersey.576304.n2.nabble.com/java-lang-NullPointerException-on-Android-tp4212447p5459910.html > Sent from the Jersey mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
This post has NOT been accepted by the mailing list yet.
Hey Guys,
I am also trying to send a multipart message with jersey on Android. I also got the nullpointerexception so I am trying to implement Lucas's code. However I am having trouble with ApacheHttpClient. At First I got an error that the org.apache...httpclient class was missing so I added the sufficient .jar files. However now I got this: ERROR/dalvikvm(8957): Could not find class 'javax.swing.JTextField', referenced from method com.sun.jersey.client.apache.config.DefaultCredentialsProvider.getCredentials And later: ERROR/AndroidRuntime(8957): Uncaught handler: thread Thread-10 exiting due to uncaught exception ERROR/AndroidRuntime(8957): java.lang.ExceptionInInitializerError ERROR/AndroidRuntime(8957): at com.sun.jersey.client.apache.ApacheHttpClient.createDefaultClientHander(ApacheHttpClient.java:192) ERROR/AndroidRuntime(8957): at com.sun.jersey.client.apache.ApacheHttpClient.<init>(ApacheHttpClient.java:95) ERROR/AndroidRuntime(8957): at com.example.android.apis.Sender.postWavestream_multipart_jersey(Sender.java:214) ERROR/AndroidRuntime(8957): at com.example.android.apis.Extractor.run(Extractor.java:82) ERROR/AndroidRuntime(8957): at java.lang.Thread.run(Thread.java:1058) ERROR/AndroidRuntime(8957): Caused by: java.lang.VerifyError: com.sun.jersey.client.apache.config.DefaultCredentialsProvider ERROR/AndroidRuntime(8957): at com.sun.jersey.client.apache.ApacheHttpClientHandler.<clinit>(ApacheHttpClientHandler.java:113) ERROR/AndroidRuntime(8957): ... 5 more This class is in the jdk but I can't include it in my classpath because I get an error saying the dalvic cannot be created (not mentioning it is around 40 MB...). Please help - how to run the apachehttpclient on android? |
| Powered by Nabble | Edit this page |
