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 renjith kalappurackal <re...@yahoo.com> on 2007/08/14 20:08:58 UTC

" Accessing a file from service Class "

Hi All,
 
I have a problem facing while try to read a file from a web services that is packaged as aar.
My application  structure is as follows
 
The server I am using is jboss-3.0.8_tomcat-4.1.24.
And I wrote code to access file in my local machine as below in lets say Converter.java.
 
MessageContext ctx = MessageContext.getCurrentMessageContext();
AxisService asrv = ctx.getAxisService();
fin = (FileInputStream) asrv.getClassLoader().getResourceAsStream(xml)
 
Where xml being the name of the file lets say (myconfig.xml) And I placed this file in axis2/WEB-INF/classes. And put converter.java in a jar file in C:\jboss-3.0.8_tomcat-4.1.24\tomcat-4.1.x\shared\lib.
And I deployed my services in axis2.war and placed axis2.war in C:\jboss-3.0.8_tomcat-4.1.24\server\default\deploy\webapps.
 
This solution worked fine in local environment.
 
But when I moved the solution to Linux server it failed becuase of NullPointerException in
AxisService asrv = ctx.getAxisService();
 
    The structure of server is different being Converter.class in shared/lib directory of /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/shared/lib. but axis2 is deployed as exploded form under /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/mydomain/ and this erro is happening whenI tried to access my config file that is in /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/mydomain/axis2/WEB-INF/clasess/myconfig.xml from my service class (let say MyService.class) in AAR that 
/home/wpape/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/commence/erpsync/axis2/WEB-INF/services/myAAR.aar.          
         
   This error is happening when MyService.classs after accessing Converter.class in shared/lib try to get the messageContext. 
   
   I think I did somethign terrible wrong here. Could anyone tell me the best way to access this myconfig.xml in /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/mydomain/axis2/WEB-INF/clasess/ directory from a class that is placed in a jar in shared/lib that is being called by my service class in AAR.

   
  Thanks in advance,
  Renjith 

       
---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.

Re: " Accessing a file from service Class "

Posted by Martin Gainty <mg...@hotmail.com>.
the war task should include any/all files (include myconfig.xml) to be referenced
then any deploy tasks should un-war or decompress the files (including myconfig.xml) to the deployment folder which would be
either 
WEB-INF/lib
or
WEB-INF/classes

M--

This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

  ----- Original Message ----- 
  From: renjith kalappurackal 
  To: axis-user@ws.apache.org 
  Sent: Tuesday, August 14, 2007 2:08 PM
  Subject: " Accessing a file from service Class "


  Hi All,
   
  I have a problem facing while try to read a file from a web services that is packaged as aar.
  My application  structure is as follows
   
  The server I am using is jboss-3.0.8_tomcat-4.1.24.
  And I wrote code to access file in my local machine as below in lets say Converter.java.
   
  MessageContext ctx = MessageContext.getCurrentMessageContext();
  AxisService asrv = ctx.getAxisService();
  fin = (FileInputStream) asrv.getClassLoader().getResourceAsStream(xml)
   
  Where xml being the name of the file lets say (myconfig.xml) And I placed this file in axis2/WEB-INF/classes. And put converter.java in a jar file in C:\jboss-3.0.8_tomcat-4.1.24\tomcat-4.1.x\shared\lib.
  And I deployed my services in axis2.war and placed axis2.war in C:\jboss-3.0.8_tomcat-4.1.24\server\default\deploy\webapps.
   
  This solution worked fine in local environment.
   
  But when I moved the solution to Linux server it failed becuase of NullPointerException in
  AxisService asrv = ctx.getAxisService();
   
      The structure of server is different being Converter.class in shared/lib directory of /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/shared/lib. but axis2 is deployed as exploded form under /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/mydomain/ and this erro is happening whenI tried to access my config file that is in /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/mydomain/axis2/WEB-INF/clasess/myconfig.xml from my service class (let say MyService.class) in AAR that 
  /home/wpape/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/commence/erpsync/axis2/WEB-INF/services/myAAR.aar.          
           
   This error is happening when MyService.classs after accessing Converter.class in shared/lib try to get the messageContext. 

   I think I did somethign terrible wrong here. Could anyone tell me the best way to access this myconfig.xml in /home/jboss-3.0.8_tomcat-4.1.24/tomcat-4.1.x/webapps/mydomain/axis2/WEB-INF/clasess/ directory from a class that is placed in a jar in shared/lib that is being called by my service class in AAR.


  Thanks in advance,
  Renjith 


------------------------------------------------------------------------------
  Be a better Globetrotter. Get better travel answers from someone who knows.
  Yahoo! Answers - Check it out.