[
https://issues.apache.org/jira/browse/JUDDI-939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14976466#comment-14976466
]
Matthieu Ghilain edited comment on JUDDI-939 at 10/27/15 2:23 PM:
------------------------------------------------------------------
I have found the following *ugly* workaround to make it work.
{code}
private String resolveEndpointForServiceID(String uddiServiceId) {
try {
UDDIClient uddiClient = new UDDIClient();
// THIS UGLY LINE FIXES THE NullPointerException
FieldUtils.writeDeclaredField(uddiClient, "properties", new
Properties(), true);
ServiceLocator serviceLocator =
uddiClient.getServiceLocator("uddiv3");
serviceLocator.setPolicy(PolicyRoundRobin.class.getName());
serviceLocator.withCache(new URL("http","0.0.0.0",0, ""));
return serviceLocator.lookupEndpoint(uddiServiceId);
} catch (Exception e) {
throw new EndpointResolutionFromUDDIException("Could not resolve
endpoint '"+uddiServiceId+"'.", e);
}
}
{code}
was (Author: [email protected]):
I have found the following *ugly* workaround to make it work.
{code}
private String resolveEndpointForServiceID(String uddiServiceId) {
try {
UDDIClient uddiClient = new UDDIClient();
FieldUtils.writeDeclaredField(uddiClient, "properties", new
Properties(), true);
ServiceLocator serviceLocator =
uddiClient.getServiceLocator("uddiv3");
serviceLocator.setPolicy(PolicyRoundRobin.class.getName());
serviceLocator.withCache(new URL("http","0.0.0.0",0, ""));
return serviceLocator.lookupEndpoint(uddiServiceId);
} catch (Exception e) {
throw new EndpointResolutionFromUDDIException("Could not resolve
endpoint '"+uddiServiceId+"'.", e);
}
}
{code}
> NullPointerException when using service cache
> ---------------------------------------------
>
> Key: JUDDI-939
> URL: https://issues.apache.org/jira/browse/JUDDI-939
> Project: jUDDI
> Issue Type: Bug
> Components: juddi-client
> Affects Versions: 3.3.1
> Reporter: Matthieu Ghilain
> Labels: cache, juddi
>
> Calling this method gives a NullPointerException. If I remove the
> serviceLocator.withCache(). Everything is working fine. I have attached my
> uddi.xml so that you can see my configuration.
> {code}
> private String resolveEndpointForServiceID(String uddiServiceId) {
> try {
> UDDIClient uddiClient = new UDDIClient();
> ServiceLocator serviceLocator =
> uddiClient.getServiceLocator("uddiv3");
> serviceLocator.setPolicy(PolicyRoundRobin.class.getName());
> serviceLocator.withCache(new URL("http","0.0.0.0",0, ""));
> return serviceLocator.lookupEndpoint(uddiServiceId);
> } catch (Exception e) {
> throw new EndpointResolutionFromUDDIException("Could not resolve
> endpoint '"+uddiServiceId+"'.", e);
> }
> }
> {code}
> {code:title=Stacktrace|borderStyle=solid}
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at
> com.intellij.junit4.JUnit4TestRunnerUtil$IgnoreIgnoredTestJUnit4ClassRunner.runChild(JUnit4TestRunnerUtil.java:341)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
> at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
> at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)
> Caused by: org.apache.commons.configuration.ConfigurationException:
> java.lang.NullPointerException
> at
> org.apache.juddi.v3.client.mapping.ServiceLocator.initCache(ServiceLocator.java:172)
> at
> org.apache.juddi.v3.client.mapping.ServiceLocator.withCache(ServiceLocator.java:84)
> Caused by: java.lang.NullPointerException
> at java.util.Hashtable.putAll(Hashtable.java:586)
> at
> org.apache.juddi.v3.client.mapping.UDDIServiceCache.<init>(UDDIServiceCache.java:119)
> at
> org.apache.juddi.v3.client.mapping.ServiceLocator.initCache(ServiceLocator.java:170)
> ... 30 more
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)