Comments (9)
- Issue Imported From: https://github.com/jersey/jersey/issues/304
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @mpotociar
- Original Issue Closed By:@glassfishrobot
from jersey.
@glassfishrobot Commented
Reported by [email protected]
from jersey.
@glassfishrobot Commented
[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.
@glassfishrobot Commented
[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.
@glassfishrobot Commented
[email protected] said:
Fixed in the trunk.
from jersey.
@glassfishrobot Commented
[email protected] said:
Verified against Weblogic R11 PS1, problem no longer reproduces.
from jersey.
@glassfishrobot Commented
Was assigned to jersey-issues
from jersey.
@glassfishrobot Commented
This issue was imported from java.net JIRA JERSEY-32
from jersey.
@glassfishrobot Commented
Marked as fixed on Tuesday, December 1st 2009, 9:21:10 pm
from jersey.
Related Issues (20)
- What is the difference between jersey2.x, jersey 3.x and jersey4.x and which one is recommended? HOT 8
- Connection Leak when Circuit Breaker Hystrix Command timeout HOT 2
- 3.1.7 OSGi bundle issue HOT 12
- "MessageBodyWriter not found for media type=application/xml" error preventing upgrade from 2.32 to 2.33 HOT 4
- KeepAlive Caching stops working in 2.41 HOT 1
- Incosistent handling of inherited @Produces annotations HOT 2
- AsyncContext completion attempt after AsyncListener.onError is called HOT 3
- Process dump caused by malicious response headers HOT 2
- ChunkedInput.close is not sufficient to release client connections
- Json Jackon Maven test failing for version 3.1.3 HOT 1
- NPE after switching to jersey-micrometer HOT 8
- Issue when injecting @QueryParam values when the URL query string has percentage encoded &
- JdkConnector using Obsolete `java.net.CookieManager` HOT 2
- `JerseySseEventSource` ignores `onError` callback supplied to `register()` method, making it impossible to surface HTTP/network errors
- Jetty connector is not supported on JDK version less than 17 HOT 7
- RequestEvent for RequestEventListener might lost request attributes for async flow HOT 1
- Add ability to disable DefaultJacksonJaxbJsonProvider
- Jsonb still not injectable
- Jersey 2.X ResourceDoclet much slower compared to 1.X
- Update DigestAuthenticator.java to implement RFC 7616
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.