Solved

null value returned for the url

Posted on 2011-09-08
6
239 Views
Last Modified: 2012-05-12
We are using server side java with blazeDS for our current project, and are using class.getClassLoader().getResource("fileName"), but we are getting a null value returned for the url.  We have placed "fileName" with the .class files on the server, but it seems like it is unable to find the file.  Is there something we are missing, maybe in setting up the project?


thanks
0
Comment
Question by:anotherfn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36505748
Is it inside the WEB-INF folder?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36505756
If you use

this.getClass().getClassLoader().getResource("fileName")

then my understanding is that you should be putting your class inside the pacjage of class of your instance this - are you doing it this way ?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36505905
I'm sorry I was not right in my previous post - actually

URL url = this.getClass().getClassLoader().getResource("fileName");

This will be looking at the root of your classpath for class of intsnce this


0
Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

 
LVL 47

Expert Comment

by:for_yan
ID: 36505926

So if your class of this is
com.company.pack.MyClass

then your MyClass.class will be in the fiolder

com/company/pack

however this

URL url = this.getClass().getClassLoader().getResource("fileName.txt");

will be looking for file  fileName.txt
in the folder above com

if you put it alongside with class fiile MyClass
the you shoud say:

URL url = this.getClass().getClassLoader().getResource("com/company/pack/fileName.txt");

Otherwise it returns null

I juts tested it and it works that way





0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36505940
I think it should work the same way, no matter if it is in regular applcation or in J2EE or app server
or anything because this is how these methods should work according to specification
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36506975
Please post your code and tell us where you file is
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question