You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Manu Lopez <ml...@intecna.es> on 2007/03/05 13:59:34 UTC
Re: Reading resources off classpath
Hello
I've deployed a WebService using Http+Jsr181 components. One of the WS
operations needs to load a .properties file. Bassically this is the ws
operation code:
/**
* Web service operation
*/
@WebMethod(operationName = "getTicket")
public String getTicket(@WebParam(name = "username") String username,
@WebParam(name = "password") String password) throws Exception {
try {
InputStream fileStream =
es.intecna.persistence.ContextFactory.class.getClassLoader().getResourceAsStream("ldap/ldap.properties");
Properties config = new Properties();
config.load(fileStream);
}
catch (Exception e) {
e.printStackTrace();
}
return null;
}
When I try to invoke the webservice operation with a Client, I get a NPE in
Servicemix console:
INFO - AegisBindingProvider - xsi:type="" was specified, but no
corresponding Type was registered; defaulting to
{http://www.w3.org/2001/XMLSchema}string
INFO - AegisBindingProvider - xsi:type="" was specified, but no
corresponding Type was registered; defaulting to
{http://www.w3.org/2001/XMLSchema}string
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:365)
at java.util.Properties.load(Properties.java:293)
at
es.intecna.webservices.Authentication.getTicket(Authentication.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:54)
at
org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:271)
at
org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:84)
at
org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:132)
at
org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:107)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at
org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
at
org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
at
org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.process(Jsr181ExchangeProcessor.java:110)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:593)
at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:595)
The ldap/ldap.properties file is never read.
This file is placed in
<SM_HOME>/data/smx/service-assemblies/<SA_NAME>/version_1/sus/servicemix-jsr181/<SU_NAME>/ldap/ldap.properties
In the xbean.xml I set the classpath:
<classpath>
<location>.</location>
</classpath>
Where should I place the .properties file?
Thanks
gnodet wrote:
>
> You should be able to do that from the deployed bean using
>
> getClass().getClassLoader().getResource(xx)
>
> or using the thread context class loader.
>
> You need to include the needed resources in the SU, and
> add the <classpath><location>.</location></classpath> tag
> if you use 3.0.
>
> On 11/22/06, Ryan Moquin <fr...@gmail.com> wrote:
>> Hello, I was searching online and couldn't find an answer to this
>> question.
>> If I package other resources, other than my wsdl, in a JSR 181
>> service-unit
>> that I want to load via the classpath, how would I do it? I tried using
>> my
>> webservice classloader, but it can't find it. Is there a class I can use
>> to
>> grab it?
>>
>> Thanks!
>>
>>
>
>
> --
> Cheers,
> Guillaume Nodet
>
>
--
View this message in context: http://www.nabble.com/Reading-resources-off-classpath-tf2687650s12049.html#a9311006
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Reading resources off classpath
Posted by Manu Lopez <ml...@intecna.es>.
I have solve the problem by copying the .properties folder inside /conf which
is in the classpath.
Manu Lopez wrote:
>
> Hello
>
> I've deployed a WebService using Http+Jsr181 components. One of the WS
> operations needs to load a .properties file. Bassically this is the ws
> operation code:
>
> /**
> * Web service operation
> */
> @WebMethod(operationName = "getTicket")
> public String getTicket(@WebParam(name = "username") String username,
> @WebParam(name = "password") String password) throws Exception {
>
> try {
> InputStream fileStream =
> es.intecna.persistence.ContextFactory.class.getClassLoader().getResourceAsStream("ldap/ldap.properties");
> Properties config = new Properties();
> config.load(fileStream);
> }
> catch (Exception e) {
> e.printStackTrace();
> }
> return null;
> }
>
> When I try to invoke the webservice operation with a Client, I get a NPE
> in Servicemix console:
>
> INFO - AegisBindingProvider - xsi:type="" was specified, but no
> corresponding Type was registered; defaulting to
> {http://www.w3.org/2001/XMLSchema}string
> INFO - AegisBindingProvider - xsi:type="" was specified, but no
> corresponding Type was registered; defaulting to
> {http://www.w3.org/2001/XMLSchema}string
> java.lang.NullPointerException
> at java.util.Properties$LineReader.readLine(Properties.java:365)
> at java.util.Properties.load(Properties.java:293)
> at
> es.intecna.webservices.Authentication.getTicket(Authentication.java:54)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:54)
> at
> org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:271)
> at
> org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:84)
> at
> org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:132)
> at
> org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:107)
> at
> org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
> at
> org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
> at
> org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
> at
> org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.process(Jsr181ExchangeProcessor.java:110)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:489)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:441)
> at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:593)
> at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:174)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:176)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
> at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
> at java.lang.Thread.run(Thread.java:595)
>
> The ldap/ldap.properties file is never read.
>
> This file is placed in
> <SM_HOME>/data/smx/service-assemblies/<SA_NAME>/version_1/sus/servicemix-jsr181/<SU_NAME>/ldap/ldap.properties
>
> In the xbean.xml I set the classpath:
> <classpath>
> <location>.</location>
> </classpath>
>
> Where should I place the .properties file?
>
> Thanks
>
>
>
>
>
>
>
>
>
>
> gnodet wrote:
>>
>> You should be able to do that from the deployed bean using
>>
>> getClass().getClassLoader().getResource(xx)
>>
>> or using the thread context class loader.
>>
>> You need to include the needed resources in the SU, and
>> add the <classpath><location>.</location></classpath> tag
>> if you use 3.0.
>>
>> On 11/22/06, Ryan Moquin <fr...@gmail.com> wrote:
>>> Hello, I was searching online and couldn't find an answer to this
>>> question.
>>> If I package other resources, other than my wsdl, in a JSR 181
>>> service-unit
>>> that I want to load via the classpath, how would I do it? I tried using
>>> my
>>> webservice classloader, but it can't find it. Is there a class I can
>>> use to
>>> grab it?
>>>
>>> Thanks!
>>>
>>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Reading-resources-off-classpath-tf2687650s12049.html#a9313688
Sent from the ServiceMix - User mailing list archive at Nabble.com.