Comments (8)
Reported by [email protected]
from jersey.
[email protected] said:
It might be possible to fix this by using getResourcePaths instead. As long as
the server implements a sensible URL scheme for the mapped paths, with folders
ending in "/", it should be easy to iterate over the classpath.
Consider the following resource:
@path("/context")
public class ServletContextDumper {
@get
public String dumpLocations(@context
ServletContext sc) throws MalformedURLException
{ StringBuilder sb = new StringBuilder(); // sb.append("classes\n"); String startPath = "/WEB-INF/classes"; iterate(sc, sb, startPath); sb.append("lib\n"); startPath = "/WEB-INF/lib"; iterate(sc, sb, startPath); // return sb.toString(); }
private void iterate(ServletContext sc, StringBuilder sb,
String startPath) throws MalformedURLException {
Set paths = sc.getResourcePaths(startPath);
for (String path : paths) {
sb.append(path);
sb.append(" = ");
sb.append(sc.getResource(path));
sb.append("\n");
//
if (path.endsWith("/"))
{ iterate(sc, sb, path); }
else {
try {
InputStream inputStream = sc.getResourceAsStream(path);
try {
if (path.endsWith(".class"))
{ sb.append("First few bytes as hex are are "); sb.append(Integer.toString(inputStream.read(), 16)); sb.append(Integer.toString(inputStream.read(), 16)); sb.append(Integer.toString(inputStream.read(), 16)); sb.append(Integer.toString(inputStream.read(), 16)); }
else
{ sb.append("First few charaters are "); sb.append(Character.toString((char)inputStream.read())); sb.append(Character.toString((char)inputStream.read())); sb.append(Character.toString((char)inputStream.read())); sb.append(Character.toString((char)inputStream.read())); }
sb.append(" \n");
} finally
{ inputStream.close(); }
} catch (IOException ioe)
{ ioe.printStackTrace(); }
}
}
}
public static class ExampleInnerClass {
}
}
This will list all the classes in nested directories and any jar under the lib
directory. Experimentation by Paul S shows this should work under glassfish.
Need to be tested under JBoss etc.
When run on weblogic the output for this application looks like:
classes
/WEB-INF/classes/project1/ = zip:C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/_wl_cls_gen.jar!/project1/
/WEB-INF/classes/project1/ServletContextDumper.class = zip:C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/_wl_cls_gen.jar!/project1/ServletContextDumper.class
First few bytes as hex are are cafebabe
/WEB-INF/classes/project1/ServletContextDumper$ExampleInnerClass.class =
zip:C:/Documents and Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/_wl_cls_gen.jar!/project1/ServletContextDumper$ExampleInnerClass.class
First few bytes as hex are are cafebabe
lib
/WEB-INF/lib/jsr311-api-1.0.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jsr311-api-1.0.jar
First few charaters are PK��
/WEB-INF/lib/jersey-server-1.0.3.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jersey-server-1.0.3.jar
First few charaters are PK��
/WEB-INF/lib/jettison-1.0.1.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jettison-1.0.1.jar
First few charaters are PK��
/WEB-INF/lib/_wl_cls_gen.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/_wl_cls_gen.jar
First few charaters are PK��
/WEB-INF/lib/jackson-lgpl-0.9.4.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jackson-lgpl-0.9.4.jar
First few charaters are PK��
/WEB-INF/lib/asm-3.1.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/asm-3.1.jar
First few charaters are PK��
/WEB-INF/lib/jersey-json-1.0.3.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jersey-json-1.0.3.jar
First few charaters are PK��
/WEB-INF/lib/jersey-client-1.0.3.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jersey-client-1.0.3.jar
First few charaters are PK��
/WEB-INF/lib/jersey-core-1.0.3.jar = file:/C:/Documents and
Settings/gdavison.EDC/Application
Data/JDeveloper/system11.1.1.2.35.54.57/DefaultDomain/servers/DefaultServer/tmp/_WL_user/jersey/gsvl5q/war/WEB-INF/lib/jersey-core-1.0.3.jar
First few charaters are PK��
Note that cafebabe and PK are the magic properties for .class files and
.zip/.jar file respectively.
from jersey.
[email protected] said:
Workaround for weblogic 10.X
You can configure weblogic to return a non-null value for getRealPath with the
following entry in WEB-INF/weblogic.xml
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app
http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
true
See specificaly CR CR299135 in
http://edocs.bea.com/wls/docs100/issues/known_resolved.html
from jersey.
[email protected] said:
Fixed in the trunk.
from jersey.
[email protected] said:
Verified against Weblogic R11 PS1, problem no longer reproduces.
from jersey.
Was assigned to jersey-issues
from jersey.
This issue was imported from java.net JIRA JERSEY-32
from jersey.
Marked as fixed on Tuesday, December 1st 2009, 9:21:10 pm
from jersey.
Related Issues (20)
- Partial update with PUT
- How can I forbidden http method 'OPTIONS' uniformity?
- Problem using wink libraries with JAX-RS 2.0 HOT 2
- java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.introspect.AnnotatedMember.getType()Lcom/fasterxml/jackson/databind/JavaType HOT 1
- Non-ISO8859-1 filenames creating garbled header in multipart request
- Handle com.fasterxml.jackson.databind.exc.InvalidFormatException inside a RequestContext HOT 2
- Jersey REST POST call throwing 404. HOT 2
- Spring RequestScope breaks SpringComponentProvider
- Features are initialized before the SpringComponentProvider
- Jersey creates multiple provider instances if a class implements more than one provider interface HOT 2
- does jersey 2.x Client API support DELETE with a body ? HOT 1
- Java 10 compiled class is breaking at the startup HOT 1
- Jersey threads stuck in `WAITING` HOT 4
- Cannot inject CDI bean into custom validator HOT 3
- Link in exception mapping example README is wrong
- Base64 encoding with non ASCII characters results in ArrayIndexOutOfBoundException
- Issue with SelectableEntityFiltering when the fields specified is . character
- SSE Events delimiter HOT 1
- Allow nested request body inside @BeanParam HOT 1
- Contribute Jersey to Eclipse Foundation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jersey.