Giter VIP home page Giter VIP logo

Comments (8)

glassfishrobot avatar glassfishrobot commented on June 27, 2024

Reported by [email protected]

from jersey.

glassfishrobot avatar glassfishrobot commented on June 27, 2024

[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 avatar glassfishrobot commented on June 27, 2024

[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 avatar glassfishrobot commented on June 27, 2024

[email protected] said:
Fixed in the trunk.

from jersey.

glassfishrobot avatar glassfishrobot commented on June 27, 2024

[email protected] said:
Verified against Weblogic R11 PS1, problem no longer reproduces.

from jersey.

glassfishrobot avatar glassfishrobot commented on June 27, 2024

Was assigned to jersey-issues

from jersey.

glassfishrobot avatar glassfishrobot commented on June 27, 2024

This issue was imported from java.net JIRA JERSEY-32

from jersey.

glassfishrobot avatar glassfishrobot commented on June 27, 2024

Marked as fixed on Tuesday, December 1st 2009, 9:21:10 pm

from jersey.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.