473,516 Members | 2,889 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in getting real path in JBoss Application server

9 New Member
Hello everyone,

I was testing a web app on Tomcat and I basically created a 'Temp' folder in the 'Web-content' folder of the project in Eclipse. I write files to that folder in my web app by using the following code:

Expand|Select|Wrap|Line Numbers
  1. String imagePath = getServletContext().getRealPath("/Temp/")+"\\"+userName+".png";
  2.  
After doing this, I was able to download the file from http://localhost:8080/MyProjectName/Temp

When I switched to JBoss for the same application without making any changes, and after creating the 'Temp' folder in the same location, I keep facing a 'file not found' exception when I try to use the following code:

Expand|Select|Wrap|Line Numbers
  1. String imagePath = getServletContext().getRealPath("/Temp/")+"\\"+userName+".png";
  2. ImageIO.write((BufferedImage)returnValue, "jpg", new File(pathOfChart+"chart.jpg"));
  3.  
It says 'The system could not find the path specified'.

Does anyone know why this is happening and/or how I could work around this?

Thanks in advance for your help.

Cheers.

Nikhil
Apr 23 '09 #1
9 10454
dmjpro
2,476 Top Contributor
Don't use \\ for path separator in Windows? Always use \ for File Path Separator.
Apr 23 '09 #2
JosAH
11,448 Recognized Expert MVP
@dmjpro
The poster is using a single back slash; it needs to be escaped in String literals.

kind regards,

Jos
Apr 23 '09 #3
dmjpro
2,476 Top Contributor
@JosAH
<snipped> ............. Actually it would be , "always use / " ;)
Apr 23 '09 #4
ne0lithic
9 New Member
I worked around that problem by creating a directory (if it doesn't automatically exist) at the servlet's start up. A "filePointer.mkdirs()" seemed to take care of that just fine. The same code works with that. Just thought I would put this up if anyone else faces a similar problem. Thanks for your help.

Regards,

Nikhil
Apr 24 '09 #5
dmjpro
2,476 Top Contributor
@ne0lithic
See, Have the code like this ...

Expand|Select|Wrap|Line Numbers
  1. String imagePath = getServletContext().getRealPath("/Temp/")+userName+".png";
  2.  
Here i can see two paths you are using ...
1.imagePath
2.pathOfChart

Print two paths, and see what it results ;)
Use / always as "file path separator" what ever OS or server you are using.
First let me know which path the "System can't find" and what are print outs of "two paths". Check whether two paths exist or not.
Apr 24 '09 #6
chaarmann
785 Recognized Expert Contributor
Instead of using / or \, the best way (os-independent) is to use "File.separator" !

Always using / is not os-independent!
Apr 24 '09 #7
dmjpro
2,476 Top Contributor
Yeah.. I Know.
I think if i put / then it would be running on any OS so far what implemented. Basically Windows offer \ and rest offers /.
But if you put / for Windows then Java can intelligently make it Windows compatible ;)
Apr 24 '09 #8
ne0lithic
9 New Member
FYI, I tried printing the path when I had the earlier problem and it showed now problems whatsoever. If I hard-coded the path in the system (say "D:/Something/Somewhere") that would work just fine.
Apr 27 '09 #9
chaarmann
785 Recognized Expert Contributor
You are defining variable "imagePath", but don't use it!
Instead, you use "pathOfChart".

So why don't you print out these values and show them to us, or list the whole source code?

The calculation of imagePath seems correct.
You wrote if you hardcode the whole path it works.
So I guess the error is somewhere how you calculate "pathOfChart". Maybe it doesn't contain a backslash at the end? (it must, because you are concatenating directly the image name to it.)
Apr 30 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3060
by: Ricky | last post by:
My question: If I have a mapped driver letter g: that referes to \\servername\d\foldername How do I get java to convert it from g: to the real path so I can use it? I have a script that allows someone to locate a file on the server, but most will use there mapped drives as they know nothing better.
4
2200
by: Chris Gatto | last post by:
Hello, My organization is currently considering the purchase of a new intranet application server and we are looking for opinions from those who have been down this road before. In brief the server must support the following: - 600+ users using various ASP.Net based applications, only 2 currently but growing over time as old legacy apps...
3
1898
by: Ann Huxtable | last post by:
Hi, I am developing a C# front end. But my backend app server is JBoss. I want to know how I can communicate with the backend (maybe using System.Net.WebClient classes?). A search on Google does not yield much. I look forward to any one who has actually done this in practise, or failing that, any suggestions of how to solve this would be...
1
1472
by: Jochen Fromm | last post by:
In the Java and J2EE world there are quite a few application servers like WebShpere, WebLogic or JBoss if you want to develop large-scale applications. How many pure .NET application server exist which are not based on old COM or COM+ technology ? Would it make sense to develop a new one, with special emphasis on self-* properties,...
3
5391
by: den 2005 | last post by:
Hi everybody, I like to allow user to select and browse to which location to save the pdf file of a crystal report viewed on a web page, how can i do this in ASP.Net? I need to get the path selected from dialog box. Thanks. Note: Using VS 2002 den2005
7
25703
by: Vincent Delporte | last post by:
Hello I'm interested in hearing reflections by seasoned web app developpers about the different ways to write PHP apps, and especially how they compare in terms of performance, whether it's the PHP part or connections to MySQL. As far as I know, there are different ways to write a PHP application: - CGI, ie. the usual way : some PHP code...
2
1373
by: mastery20 | last post by:
hi gurus, i have downloaded jboss 4.0.2 in zip format and i have checked it in ie by giving the url:localhost:8080/jmx-console.when i am trying to execute ant it is not.In command mode when i compiled by ant -f jboss-build.xml compile it gives an error msg stating that "ant is not recognised as internal or external command [/B" . plz help me.wat...
11
8251
by: rh00667 | last post by:
hi all, i'm confused now. how i can get the full path of an application? if myapp is in a directory which belongs to PATH, argv gives me the first token of cmd line, and not the real path of the executed program. so if i write anywhere:
2
1026
by: walterbyrd | last post by:
Can somebody help me understand the difference? Not just where Python is concerned, but in general? As I understand it, an application server is supposed to be a great help in developing apps, because most of the business logic is already there. It seems to me that, usually when applications servers are discussed, people are talking about...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.