Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [lyo-dev] OSLC consumer : Exception in thread "main" java.lang.NoClassDefFoundError:

I had a similar problem. 
Try changing the library that has the Base64 class used for decoding from org.apache.commons. to another one. I used  com.sun.jersey.core.util.Base64.

Regards,

Mohamed Mosaad


2013/4/17 Alessio Bucaioni <alessiounivaq@xxxxxxxxx>
Dear all,
i was trying to implement a OSLC consumer which needs to consume resources from a private URI, thus only accessible with the proper credentials.
The basic main i have implemented looks like that:

final String MEDIA_TYPE = OslcMediaType.APPLICATION_RDF_XML;
final int timeout = 50000;
final  String queryBase =  "myQueryBase";
final  Set<Class<?>> providers = new HashSet<Class<?>>();
providers.addAll(JenaProvidersRegistry.getProviders());
providers.addAll(Json4JProvidersRegistry.getProviders());
   
BasicAuthSecurityHandler basicAuthHandler = new BasicAuthSecurityHandler();
basicAuthHandler.setUserName("username");
basicAuthHandler.setPassword("pwd");
final OslcRestClient oslcRestClient = new OslcRestClient(providers,queryBase, MEDIA_TYPE, timeout, basicAuthHandler);
final RequirementResource[] mbatSystemDefinitions = oslcRestClient.getOslcResources (RequirementResource[].class);

final String id = "1";
final String resourceBase = queryBase + "/" + id;
final OslcRestClient oslcRestClient1 = new OslcRestClient(providers,queryBase, MEDIA_TYPE, timeout, basicAuthHandler);
final RequirementResource mbatSystemDefinition = oslcRestClient1.getOslcResource (RequirementResource.class);
System.out.println("Rhasody System Definition: " + mbatSystemDefinition.getAbout());
System.out.println("ID:    " + mbatSystemDefinition.getIdentifier());
System.out.println("Title: " + mbatSystemDefinition.getTitle());
System.out.println("File:  " + mbatSystemDefinition.getSystemDefinitionFile());
System.out.println("== ******************************************************* =="); 

When i try to execute it i get this exception

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at org.apache.wink.client.handlers.AbstractAuthSecurityHandler.getEncodedString(AbstractAuthSecurityHandler.java:75)
at org.apache.wink.client.handlers.BasicAuthSecurityHandler.handle(BasicAuthSecurityHandler.java:78)
at org.apache.wink.client.internal.handlers.HandlerContextImpl.doChain(HandlerContextImpl.java:52)
at org.apache.wink.client.internal.ResourceImpl.invoke(ResourceImpl.java:227)
at org.apache.wink.client.internal.ResourceImpl.invoke(ResourceImpl.java:189)
at org.apache.wink.client.internal.ResourceImpl.invokeNoException(ResourceImpl.java:181)
at org.apache.wink.client.internal.ResourceImpl.get(ResourceImpl.java:310)
at org.eclipse.lyo.oslc4j.client.OslcRestClient.getOslcResources(OslcRestClient.java:231)
at oslc.mbat.consumer.DummyMain.main(DummyMain.java:52)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 9 more

Do you have any suggestion?

Best,
Alessio.

--
Alessio Bucaioni,
Research Engineering @Mälardalen University (Västerås, SE)

Swedish mobile:  +46725298579
Italian mobile:  +393497925734

Address: via Pier Michele Vizioli 5
              Camarda, L'Aquila
              67100, AQ, Italy



_______________________________________________
lyo-dev mailing list
lyo-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/lyo-dev



Back to the top