[Jersey-issues] [JIRA] Commented: (JERSEY-763) VfsSchemeScanner cannot be run in Jboss-7 environment

  • From: "genman (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [Jersey-issues] [JIRA] Commented: (JERSEY-763) VfsSchemeScanner cannot be run in Jboss-7 environment
  • Date: Tue, 5 Feb 2013 18:27:53 +0000 (GMT+00:00)
  • Auto-submitted: auto-generated


    [ 
http://java.net/jira/browse/JERSEY-763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=355238#action_355238
 ] 

genman commented on JERSEY-763:
-------------------------------


For some reason I can't attach a file here. This is the patch I'm 
recommending.

Although compile against the JBoss jars, there is no runtime dependency 
unless the scanner sees 'vfs' a scheme, in which case Java will attempt to 
load the JBoss classes.

This applies against https://svn.java.net/svn/jersey~svn/trunk@5829

From 62a001d7e8f66186af23b96009580ecb337dba23 Mon Sep 17 00:00:00 2001
From: Elias Ross <elias_ross@...>
Date: Tue, 5 Feb 2013 18:16:42 +0000
Subject: [PATCH] JBoss 7 patch

---
 jersey/jersey-core/pom.xml                         |    6 ++++
 .../core/spi/scanning/uri/VfsSchemeScanner.java    |   28 
+++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/jersey/jersey-core/pom.xml b/jersey/jersey-core/pom.xml
index 2a8bb9d..6ca0ea9 100644
--- a/jersey/jersey-core/pom.xml
+++ b/jersey/jersey-core/pom.xml
@@ -77,6 +77,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jboss-vfs</artifactId>
+            <version>3.1.0.Final</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
diff --git 
a/jersey/jersey-core/src/main/java/com/sun/jersey/core/spi/scanning/uri/VfsSchemeScanner.java
 
b/jersey/jersey-core/src/main/java/com/sun/jersey/core/spi/scanning/uri/VfsSchemeScanner.java
index 813c47e..4555066 100644
--- 
a/jersey/jersey-core/src/main/java/com/sun/jersey/core/spi/scanning/uri/VfsSchemeScanner.java
+++ 
b/jersey/jersey-core/src/main/java/com/sun/jersey/core/spi/scanning/uri/VfsSchemeScanner.java
@@ -52,6 +52,11 @@ import java.util.HashSet;
 import java.util.Set;
 import javax.ws.rs.core.UriBuilder;
 
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualFile;
+import java.util.logging.Logger;
+
 /**
  * A JBoss-based "vfsfile", "vfs" and "vfszip" scheme URI scanner.
  *
@@ -59,18 +64,39 @@ import javax.ws.rs.core.UriBuilder;
  */
 public class VfsSchemeScanner implements UriSchemeScanner {
 
+    private static final Logger LOG = 
Logger.getLogger(VfsSchemeScanner.class.getName());
+
     public Set<String> getSchemes() {
         return new HashSet<String>(Arrays.asList("vfsfile", "vfszip", 
"vfs"));
     }
 
     // UriSchemeScanner
-    
+
     public void scan(final URI u, final ScannerListener sl) {
+
+        if (u.getScheme().equalsIgnoreCase("vfs")) {
+            LOG.fine("vfs " + u);
+            URI physicalURI;
+            try {
+                VirtualFile virtualFile = VFS.getChild(u);
+                LOG.fine("child " + u);
+                physicalURI = VFSUtils.getPhysicalURI(virtualFile);
+                LOG.fine("physicalURI " + physicalURI);
+            } catch (IOException ex) {
+                throw new ScannerException(String.format("Could not turn vfs 
URI into physical URI: %s", u.toString()), ex);
+            }
+            new FileSchemeScanner().scan(physicalURI, sl);
+        } else {
+            throw new ScannerException(String.format("Unsupported URL scheme 
for scanner: %s", u.toString()));
+        }
+
         if (!u.getScheme().equalsIgnoreCase("vfszip")) {
+            LOG.fine("not vfszip " + u);
             new FileSchemeScanner().scan(
                     UriBuilder.fromUri(u).scheme("file").build(),
                     sl);
         } else {
+            LOG.fine("vfszip " + u);
             final String su = u.toString();
             final int webInfIndex = su.indexOf("/WEB-INF/classes");
             if (webInfIndex != -1) {
-- 
1.7.1



> VfsSchemeScanner cannot be run in Jboss-7 environment
> -----------------------------------------------------
>
>                 Key: JERSEY-763
>                 URL: http://java.net/jira/browse/JERSEY-763
>             Project: jersey
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: re3lex
>            Assignee: Jakub Podlesak
>
> Name of "vfsfile" protocol has been changed to "vfs" in Jboss-7 but 
> VfsSchemeScanner is mapped to vfsfile and vfszip protocols.
> So because of this I'm getting error when jersey tries to scan my rest 
> resources during jboss startup:
> {code}
> 01:01:25,195 ERROR (MSC service thr) [             [/ScoreCard]] 
> StandardWrapper.Throwable: 
> com.sun.jersey.core.spi.scanning.ScannerException: The URI scheme vfs of 
> the URI 
> vfs:/D:/views/third-party/jboss/jboss-as-7.0.1.Final/standalone/deployments/ScoreCard.ear/ScoreCard.war/WEB-INF/classes/com/lex
> /scoreCard/web/rest/ is not supported. Package scanning deployment is not 
> supported for such URIs.
> Try using a different deployment mechanism such as explicitly declaring 
> root resource and provider classes using an extension of 
> javax.ws.rs.core.Application
>         at 
> com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:225)
>         at 
> com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139)
>         at 
> com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:78)
>         at 
> com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:116)
>         at 
> com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:81)
>         at 
> com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:92)
>         at 
> com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:677)
>         at 
> com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:655)
>         at 
> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:206)
>         at 
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:342)
>         at 
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:516)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:242)
>         at 
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)
>         at 
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)
>         at 
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631)
>         at 
> org.apache.catalina.core.StandardContext.start(StandardContext.java:3844)
>         at 
> org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
>         at 
> org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
>         at 
> org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:662)
> {code}
> Can we add additional "vfs" protocol to VfsSchemeScanner?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[Jersey-issues] [JIRA] Commented: (JERSEY-763) VfsSchemeScanner cannot be run in Jboss-7 environment

genman (JIRA) 02/05/2013
Terms of Use; Privacy Policy; Copyright ©2013-2014 (revision 20140418.2d69abc)
 
 
Close
loading
Please Confirm
Close