473,693 Members | 3,029 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";
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"));
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.


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

kind regards,

Apr 23 '09 #3
2,476 Top Contributor
<snipped> ............. Actually it would be , "always use / " ;)
Apr 23 '09 #4
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.mk dirs()" 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.


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

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

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
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
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
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
785 Recognized Expert Contributor
You are defining variable "imagePath" , but don't use it!
Instead, you use "pathOfChar t".

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 "pathOfChar t". 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

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.
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 are converted; - Some applications are mission critical, others not so much; - DB back-end is a...
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 very much appreciated.
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, scalability, robustness and adaptiveness ? -J.
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
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 in web pages, and the PHP interpreter is loaded each time a PHP page is called
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 are the necessary things to be modified .and give me a instruction to execute. plz help...
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:
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 Java. I suppose most popular Python frameworks incorporate an application server, but I get the...
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.