cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juan Jose Vazquez Delgado (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COCOON-2172) Cocoon Spring Configurator 1.0.1 doesn´t work properly with Weblogic 9.2
Date Fri, 14 Mar 2008 11:15:24 GMT

    [ https://issues.apache.org/jira/browse/COCOON-2172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578685#action_12578685
] 

Juan Jose Vazquez Delgado commented on COCOON-2172:
---------------------------------------------------

I added this code in DeploymentUtil class to solve the issue:

 protected static void deployBlockResources(String relativeDirectory,
                                               String destinationDirectory,
                                               Map    blockContexts)
    throws IOException {
        final Enumeration jarUrls = DeploymentUtil.class.getClassLoader().getResources(BLOCK_RESOURCES_PATH);
        while ( jarUrls.hasMoreElements() ) {
            final URL resourceUrl = (URL)jarUrls.nextElement();

            String url = resourceUrl.toExternalForm();
            if ( "file".equals(resourceUrl.getProtocol()) ) {
                // FIXME: This only covers the siuation when the project is Maven generated
                // if this is a file url generated by the Maven,
                // it has this form "file:{url}/{block name}/target/classes/COB-INF
                int pos = url.indexOf("/target/classes/COB-INF");
                // extract block name (if any)
                if (pos >= 0) {
                    String blockName = url.substring(0, pos);
                    blockName = blockName.substring(blockName.lastIndexOf('/') + 1);
                    // register the root URL for the block resources
                    blockContexts.put(blockName, url);
                }
            } else if ( "jar".equals(resourceUrl.getProtocol()) || "zip".equals(resourceUrl.getProtocol())
) {
                // if this is a jar url, it has this form: "jar:{url-to-jar}!/{resource-path}"
                // to open the jar, we can simply remove everything after "!/"
                int pos = url.indexOf('!');
                url = url.substring(0, pos+2); // +2 as we include "!/"
                /**
                 * Included because of Weblogic 9.2 classloader behaviour 
                 */
                if ("zip".equals(resourceUrl.getProtocol()))
                		url = url.replace("zip:", "jar:file:");
                final URL jarUrl = new URL(url);
              
                final JarURLConnection connection = (JarURLConnection)jarUrl.openConnection();
                final JarFile jarFile = connection.getJarFile();
                String blockName = jarFile.getManifest().getMainAttributes().getValue("Cocoon-Block-Name");
                if ( blockName == null ) {
                    String jarPath = jarFile.getName();
                    // extract jar name
                    String jarName = jarPath.substring(jarPath.lastIndexOf(File.separatorChar)
+ 1);
                    // drop file extension
                    blockName = jarName.substring(0, jarName.lastIndexOf('.'));
                    // TODO how do we strip version from blockName?
                }
                final StringBuffer buffer = new StringBuffer(destinationDirectory);
                buffer.append(File.separatorChar);
                buffer.append(relativeDirectory);
                buffer.append(File.separatorChar);
                buffer.append(blockName);
                String destination = buffer.toString();
                deploy(jarFile, BLOCK_RESOURCES_PATH, destination);
                // register the root URL for the block resources
                blockContexts.put(blockName, new File(destination).toURL().toExternalForm());
            }
            // we only handle jar files and ordinary files
            // TODO - Should we throw an exception if it's some other protocol type? (or log?)
        }
    }

> Cocoon Spring Configurator 1.0.1 doesn´t work properly with Weblogic 9.2
> ------------------------------------------------------------------------
>
>                 Key: COCOON-2172
>                 URL: https://issues.apache.org/jira/browse/COCOON-2172
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.2-dev (Current SVN)
>            Reporter: Juan Jose Vazquez Delgado
>
> Deploying to Weblogic 9.2 happens this:
> 1. Spring loads the jar configurations with zip protocol instead jar protocol, i.e.
> zip:C:/bea/user_projects/domains/cm_domain/servers/AdminServer/tmp/_WL_user/proxy-ear/53xotj/war/WEB-INF/lib/cocoon-
> servlet-service-impl-1.0.0-M2.jar!/META-INF/cocoon/spring/cocoon-callstack-environment.xml
> 2. In Runtime, the "URLConnection" class is a "weblogic.utils.ZipUrlConnection" not a
"JarURLConnection"

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message