You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Brian Panulla <bp...@ist.psu.edu> on 2007/11/28 21:31:42 UTC
Reading a data file bundled in the .aar
I'm just getting started with Axis2. I have a data file for testing my
first Web service that I would like to bundle up in the aar file, but I
can't seem to read the file when I deploy the service to the Web server.
I'm using Axis 2 1.3.2, running using the built in Web server.
My aar is structured like this:
/
|_____data/myDatafile
|
|_____edu.psu.ist.nc2if.ws.myWebService
|
|____ META-INF/services.xml
Here's what I'm trying to do as part of myWebService:
String inputDataFile = "/data/myDataFile";
// Build a URL object as a handle to the sample data file
URL DataUrl = getClass().getResource(inputDataFile);
/* URL InputStream through a Buffered read to read a line at a
time */
BufferedReader bufRead = new BufferedReader(
new InputStreamReader( DataUrl.openStream() ));
This works great when I unit test within Eclipse, but there's something
blowing up when I build the aar and deploy it.
I need to learn more about logging and debugging services, so that's
definitely my next step, but I thought I'd ping the list to see if this
is something i'm just not seeing here.
Any suggestions?
-B
--
_____
Brian Panulla
Senior Technologist, Solutions Institute
College of Information Sciences and Technology
bpanulla@ist.psu.edu
http://ghostednotes.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Reading a data file bundled in the .aar
Posted by Brian Panulla <bp...@ist.psu.edu>.
Anthony Bull wrote:
>
> Is it blowing up or just not finding your data file?
>
> In my services, I have to use a different class-loader depending on
> whether or not the .aar file is exploded.
>
> E.g.
>
> InputStream input =
> AuthenticationHandler.class.getClassLoader().getResourceAsStream(
> "service.properties");
> if ( input == null) {
> // Loading from an .aar file, so have to use parent class
> loader!
> input =
> AuthenticationHandler.class.getClassLoader().getParent().getResourceAsStream(
> "service.properties");
> }
> props.load( input);
>
>
That would make sense. I'm still trying to get a good error message out
of the Web service.... I'm developing to be a backed to an Adobe Flex
application, and I haven't gotten Flex to bubble the whole error message
through to my UI. It's making it quite difficult to debug. My best guess
is that it just isn't finding the file... the effective location of the
data file is the only variable I can't think of between the JUnit test
and the deployed service.
Is there a straightforward way to get exceptions triggered in the
service to log to the axis2 log? I hacked around in the axis
configuration file, but wasn't successful.
Thanks for your patience... I'm still pretty clumsy with this.
--
_____
Brian Panulla
Senior Technologist, Solutions Institute
College of Information Sciences and Technology
bpanulla@ist.psu.edu
http://ghostednotes.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Reading a data file bundled in the .aar
Posted by Anthony Bull <an...@bcsoft.co.nz>.
Is it blowing up or just not finding your data file?
In my services, I have to use a different class-loader depending on
whether or not the .aar file is exploded.
E.g.
InputStream input =
AuthenticationHandler.class.getClassLoader().getResourceAsStream(
"service.properties");
if ( input == null) {
// Loading from an .aar file, so have to use parent class loader!
input =
AuthenticationHandler.class.getClassLoader().getParent().getResourceAsStream(
"service.properties");
}
props.load( input);
Brian Panulla wrote:
> I'm just getting started with Axis2. I have a data file for testing my
> first Web service that I would like to bundle up in the aar file, but
> I can't seem to read the file when I deploy the service to the Web
> server. I'm using Axis 2 1.3.2, running using the built in Web server.
>
> My aar is structured like this:
>
> /
> |_____data/myDatafile
> |
> |_____edu.psu.ist.nc2if.ws.myWebService
> |
> |____ META-INF/services.xml
>
>
> Here's what I'm trying to do as part of myWebService:
>
> String inputDataFile = "/data/myDataFile";
> // Build a URL object as a handle to the sample data file
> URL DataUrl = getClass().getResource(inputDataFile);
> /* URL InputStream through a Buffered read to read a line
> at a time */
> BufferedReader bufRead = new BufferedReader(
> new InputStreamReader( DataUrl.openStream() ));
>
> This works great when I unit test within Eclipse, but there's
> something blowing up when I build the aar and deploy it.
>
> I need to learn more about logging and debugging services, so that's
> definitely my next step, but I thought I'd ping the list to see if
> this is something i'm just not seeing here.
>
> Any suggestions?
>
> -B
>
>
--
Anthony
-------------------------------------
Anthony Bull
Senior Developer
Black Coffee Software Ltd
PO Box 10-192 The Terrace
Wellington, New Zealand
anthony.bull@bcsoft.co.nz
Ph +64 4 472 8818
Fax +64 4 472 8811
-------------------------------------
www.bcsoft.co.nz
---------------------------------------------------------------
This email may contain confidential or privileged information,
and is intended for use only by the addressee, or addressees.
If you are not the intended recipient please advise the sender
immediately and do not copy, use or disclose the contents to
any other person or organisation.
Black Coffee Software Ltd accepts no responsibility for viruses
received with this email, or to any changes made to the original
content. Any views or opinions expressed in this email may be
personal to the sender and are not necessarily those of Black
Coffee Software Ltd.
---------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
RE: Reading a data file bundled in the .aar
Posted by si...@bt.com.
Hi Brian,
I am not sure, but you are using an absolute path. Relative paths are
more flexible.
Although this is just a wild guess, I am not expert on this area.
Sietse
-----Original Message-----
From: Brian Panulla [mailto:bpanulla@ist.psu.edu]
Sent: 28 November 2007 20:32
To: axis-user@ws.apache.org
Subject: Reading a data file bundled in the .aar
I'm just getting started with Axis2. I have a data file for testing my
first Web service that I would like to bundle up in the aar file, but I
can't seem to read the file when I deploy the service to the Web server.
I'm using Axis 2 1.3.2, running using the built in Web server.
My aar is structured like this:
/
|_____data/myDatafile
|
|_____edu.psu.ist.nc2if.ws.myWebService
|
|____ META-INF/services.xml
Here's what I'm trying to do as part of myWebService:
String inputDataFile = "/data/myDataFile";
// Build a URL object as a handle to the sample data file
URL DataUrl = getClass().getResource(inputDataFile);
/* URL InputStream through a Buffered read to read a line at a
time */
BufferedReader bufRead = new BufferedReader(
new InputStreamReader( DataUrl.openStream() ));
This works great when I unit test within Eclipse, but there's something
blowing up when I build the aar and deploy it.
I need to learn more about logging and debugging services, so that's
definitely my next step, but I thought I'd ping the list to see if this
is something i'm just not seeing here.
Any suggestions?
-B
--
_____
Brian Panulla
Senior Technologist, Solutions Institute College of Information Sciences
and Technology bpanulla@ist.psu.edu http://ghostednotes.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org