Solved

null value returned for the url

Posted on 2011-09-08
6
226 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now