# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/ludo/acvs/v3/admin/rest/src/main/java/org/glassfish/admin/rest # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: LazyJerseyInit.java --- LazyJerseyInit.java Base (BASE) +++ LazyJerseyInit.java Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -47,17 +47,38 @@ import com.sun.jersey.api.core.ResourceConfig; import org.glassfish.api.container.EndpointRegistrationException; import com.sun.grizzly.tcp.Adapter; +import com.sun.grizzly.tcp.http11.GrizzlyRequest; +import com.sun.grizzly.tcp.http11.GrizzlyResponse; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.container.filter.LoggingFilter; import com.sun.jersey.api.core.DefaultResourceConfig; import com.sun.jersey.spi.inject.SingletonTypeInjectableProvider; +import java.util.HashSet; import java.util.Set; +import java.util.StringTokenizer; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import org.glassfish.admin.rest.adapter.Reloader; +import org.glassfish.admin.rest.generator.ASMResourcesGenerator; +import org.glassfish.admin.rest.generator.ResourcesGenerator; +import org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider; +import org.glassfish.admin.rest.provider.ActionReportResultJsonProvider; +import org.glassfish.admin.rest.provider.ActionReportResultXmlProvider; +import org.glassfish.admin.rest.provider.BaseProvider; +import org.glassfish.admin.rest.resources.GeneratorResource; import org.glassfish.admin.rest.resources.ReloadResource; +import org.glassfish.admin.rest.resources.StatusGenerator; +import org.glassfish.admin.rest.resources.custom.ManagementProxyResource; +import org.glassfish.admin.rest.results.ActionReportResult; +import org.glassfish.admin.rest.utils.xml.RestActionReporter; +import org.glassfish.api.ActionReport; import org.glassfish.internal.api.ServerContext; import org.jvnet.hk2.component.Habitat; +import org.jvnet.hk2.config.ConfigModel; +import org.jvnet.hk2.config.Dom; +import org.jvnet.hk2.config.DomDocument; /** * @@ -67,9 +88,10 @@ * Class that initialize the Jersey container. It is called via introspection from RestAdapter * so that RestAdapter does not depend on Jersey classes. This way, we gain 90ms at startup time * and load the jersey classes only at the very last time, when needed. + * It is safe to have imports on com.sun.jersey.* APIs in this class. * @author ludo */ -public class LazyJerseyInit { +public class LazyJerseyInit implements LazyJerseyInterface{ /** @@ -79,7 +101,8 @@ * @return the correct GrizzlyAdapter * @throws EndpointRegistrationException */ - public static GrizzlyAdapter exposeContext(Set classes, ServerContext sc, Habitat habitat) + @Override + public GrizzlyAdapter exposeContext(Set classes, ServerContext sc, Habitat habitat) throws EndpointRegistrationException { @@ -131,7 +154,8 @@ } - static protected RestConfig getRestConfig(Habitat habitat) { + @Override + public RestConfig getRestConfig(Habitat habitat) { if (habitat == null) { return null; } @@ -146,4 +170,153 @@ return null; } + + @Override + public void reportError(GrizzlyRequest req, GrizzlyResponse res, int statusCode, String msg) { + try { + // TODO: There's a lot of arm waving and flailing here. I'd like this to be cleaner, but I don't + // have time at the moment. jdlee 8/11/10 + RestActionReporter report = new RestActionReporter(); //getClientActionReport(req); + report.setActionExitCode(ActionReport.ExitCode.FAILURE); + report.setActionDescription("Error"); + report.setMessage(msg); + BaseProvider provider; + String type = getAcceptedMimeType(req); + if ("xml".equals(type)) { + res.setContentType("application/xml"); + provider = new ActionReportResultXmlProvider(); + } else if ("json".equals(type)) { + res.setContentType("application/json"); + provider = new ActionReportResultJsonProvider(); + } else { + res.setContentType("text/html"); + provider = new ActionReportResultHtmlProvider(); } + res.setStatus(statusCode); + res.getOutputStream().write(provider.getContent(new ActionReportResult(report)).getBytes()); + res.getOutputStream().flush(); + res.finishResponse(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static String getAcceptedMimeType(GrizzlyRequest req) { + String type = null; + String requestURI = req.getRequestURI(); + Set acceptableTypes = new HashSet() { + + { + add("html"); + add("xml"); + add("json"); + } + }; + + // first we look at the command extension (ie list-applications.[json | html | mf] + if (requestURI.indexOf('.') != -1) { + type = requestURI.substring(requestURI.indexOf('.') + 1); + } else { + String userAgent = req.getHeader("User-Agent"); + if (userAgent != null) { + String accept = req.getHeader("Accept"); + if (accept != null) { + if (accept.indexOf("html") != -1) {//html is possible so get it... + return "html"; + } + StringTokenizer st = new StringTokenizer(accept, ","); + while (st.hasMoreElements()) { + String scheme = st.nextToken(); + scheme = scheme.substring(scheme.indexOf('/') + 1); + if (acceptableTypes.contains(scheme)) { + type = scheme; + break; + } + } + } + } + } + + return type; + } + + @Override + public Set> getResourcesConfigForMonitoring(Habitat habitat) { + final Set> r = new HashSet>(); + r.add(org.glassfish.admin.rest.resources.MonitoringResource.class); + + r.add(org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.class); + r.add(org.glassfish.admin.rest.provider.ActionReportResultJsonProvider.class); + r.add(org.glassfish.admin.rest.provider.ActionReportResultXmlProvider.class); + + return r; + } + + @Override + public Set> getResourcesConfigForManagement(Habitat habitat) { + + Class domainResourceClass = null;//org.glassfish.admin.rest.resources.generated.DomainResource.class; + + generateASM(habitat); + try { + domainResourceClass = Class.forName("org.glassfish.admin.rest.resources.generatedASM.DomainResource"); + } catch (ClassNotFoundException ex) { + Logger.getLogger(LazyJerseyInit.class.getName()).log(Level.SEVERE, null, ex); + } + + final Set> r = new HashSet>(); + + // uncomment if you need to run the generator: + r.add(GeneratorResource.class); + r.add(StatusGenerator.class); + //r.add(ActionReportResource.class); + + r.add(domainResourceClass); + r.add(ManagementProxyResource.class); + r.add(org.glassfish.admin.rest.resources.SessionsResource.class); //TODO this needs to be added to all rest adapters that want to be secured. Decide on it after the discussion to unify RestAdapter is concluded + r.add(org.glassfish.admin.rest.resources.StaticResource.class); + + //body readers, not in META-INF/services anymore + r.add(org.glassfish.admin.rest.readers.FormReader.class); + r.add(org.glassfish.admin.rest.readers.ParameterMapFormReader.class); + r.add(org.glassfish.admin.rest.readers.JsonHashMapProvider.class); + r.add(org.glassfish.admin.rest.readers.JsonPropertyListReader.class); + r.add(org.glassfish.admin.rest.readers.JsonParameterMapProvider.class); + + r.add(org.glassfish.admin.rest.readers.XmlHashMapProvider.class); + r.add(org.glassfish.admin.rest.readers.XmlPropertyListReader.class); + + //body writers + r.add(org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.class); + r.add(org.glassfish.admin.rest.provider.ActionReportResultJsonProvider.class); + r.add(org.glassfish.admin.rest.provider.ActionReportResultXmlProvider.class); + + + r.add(org.glassfish.admin.rest.provider.FormWriter.class); + + r.add(org.glassfish.admin.rest.provider.GetResultListHtmlProvider.class); + r.add(org.glassfish.admin.rest.provider.GetResultListJsonProvider.class); + r.add(org.glassfish.admin.rest.provider.GetResultListXmlProvider.class); + + r.add(org.glassfish.admin.rest.provider.OptionsResultJsonProvider.class); + r.add(org.glassfish.admin.rest.provider.OptionsResultXmlProvider.class); + + return r; + } + + private void generateASM(Habitat habitat) { + try { + Domain entity = habitat.getComponent(Domain.class); + Dom dom = Dom.unwrap(entity); + DomDocument document = dom.document; + ConfigModel rootModel = dom.document.getRoot().model; + + ResourcesGenerator resourcesGenerator = new ASMResourcesGenerator(); + resourcesGenerator.generateSingle(rootModel, document); + resourcesGenerator.endGeneration(); + } catch (Exception ex) { + Logger.getLogger(GeneratorResource.class.getName()).log(Level.SEVERE, null, ex); + } + } +} + Index: LazyJerseyInterface.java --- LazyJerseyInterface.java Locally New +++ LazyJerseyInterface.java Locally New @@ -0,0 +1,73 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package org.glassfish.admin.rest; + +import com.sun.grizzly.tcp.http11.GrizzlyAdapter; +import com.sun.grizzly.tcp.http11.GrizzlyRequest; +import com.sun.grizzly.tcp.http11.GrizzlyResponse; +import java.util.Set; +import org.glassfish.api.container.EndpointRegistrationException; +import org.glassfish.internal.api.ServerContext; +import org.jvnet.hk2.component.Habitat; + +/** + * + * @author ludo + */ +public interface LazyJerseyInterface { + + /** + * Called via introspection in the RestAdapter service() method only when the GrizzlyAdapter is not initialized + * @param classes set of Jersey Resources classes + * @param sc the current ServerContext, needed to find the correct classpath + * @return the correct GrizzlyAdapter + * @throws EndpointRegistrationException + */ + GrizzlyAdapter exposeContext(Set classes, ServerContext sc, Habitat habitat) + throws EndpointRegistrationException; + + RestConfig getRestConfig(Habitat habitat); + + void reportError(GrizzlyRequest req, GrizzlyResponse res, int statusCode, String msg); + + Set> getResourcesConfigForMonitoring(Habitat habitat); + + Set> getResourcesConfigForManagement(Habitat habitat); +} Index: adapter/RestAdapter.java --- adapter/RestAdapter.java Base (BASE) +++ adapter/RestAdapter.java Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -57,7 +57,7 @@ import java.net.InetAddress; import javax.security.auth.login.LoginException; -import org.glassfish.admin.rest.LazyJerseyInit; +import org.glassfish.admin.rest.LazyJerseyInterface; import org.glassfish.admin.rest.RestService; import org.glassfish.admin.rest.SessionManager; import org.glassfish.api.ActionReport; @@ -75,24 +75,17 @@ import java.net.HttpURLConnection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.StringTokenizer; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.glassfish.admin.rest.Constants; -import org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider; -import org.glassfish.admin.rest.provider.ActionReportResultJsonProvider; -import org.glassfish.admin.rest.provider.ActionReportResultXmlProvider; -import org.glassfish.admin.rest.provider.BaseProvider; -import org.glassfish.admin.rest.results.ActionReportResult; -import org.glassfish.admin.rest.utils.xml.RestActionReporter; + import org.glassfish.internal.api.AdminAccessController; import org.glassfish.internal.api.ServerContext; +import java.util.logging.Level; - /** * Adapter for REST interface * @author Rajeshwar Patil, Ludovic Champenois @@ -121,6 +114,8 @@ @Inject ServerEnvironment serverEnvironment; + private volatile LazyJerseyInterface lazyJerseyInterface =null; + private Map httpStatus = new HashMap() {{ put(404, "Resource not found"); put(500, "A server error occurred. Please check the server logs."); @@ -398,38 +393,7 @@ protected abstract Set> getResourcesConfig(); - private String getAcceptedMimeType(GrizzlyRequest req) { - String type = null; - String requestURI = req.getRequestURI(); - Set acceptableTypes = new HashSet() {{ add("html"); add("xml"); add("json"); }}; - // first we look at the command extension (ie list-applications.[json | html | mf] - if (requestURI.indexOf('.')!=-1) { - type = requestURI.substring(requestURI.indexOf('.')+1); - } else { - String userAgent = req.getHeader("User-Agent"); - if (userAgent != null) { - String accept = req.getHeader("Accept"); - if (accept != null) { - if (accept.indexOf("html") != -1) {//html is possible so get it... - return "html"; - } - StringTokenizer st = new StringTokenizer(accept, ","); - while (st.hasMoreElements()) { - String scheme=st.nextToken(); - scheme = scheme.substring(scheme.indexOf('/')+1); - if (acceptableTypes.contains(scheme)) { - type = scheme; - break; - } - } - } - } - } - - return type; - } - // private ActionReport getClientActionReport(GrizzlyRequest req) { // ActionReport report=null; // String requestURI = req.getRequestURI(); @@ -444,14 +408,38 @@ // return report; // } + /* + * dynamically load the class that contains all references to Jersey APIs + * so that Jersey is not loaded when the RestAdapter is loaded at boot time + * gain a few 100millis at GlassFish startyp time ++ */ + protected LazyJerseyInterface getLazyJersey() { + if (lazyJerseyInterface != null) { + return lazyJerseyInterface; + } + synchronized (com.sun.grizzly.tcp.Adapter.class) { + if (lazyJerseyInterface == null) { + try { + Class lazyInitClass = Class.forName("org.glassfish.admin.rest.LazyJerseyInit"); + lazyJerseyInterface = (LazyJerseyInterface) lazyInitClass.newInstance(); + } catch (Exception ex) { + logger.log(Level.SEVERE, + "Error trying to call org.glassfish.admin.rest.LazyJerseyInit via instrospection: ", ex); + } + } + } + return lazyJerseyInterface; + } + private void exposeContext() throws EndpointRegistrationException { String context = getContextRoot(); logger.fine("Exposing rest resource context root: " + context); if ((context != null) || (!"".equals(context))) { Set> classes = getResourcesConfig(); - adapter = LazyJerseyInit.exposeContext(classes, sc, habitat); + // adapter = LazyJerseyInit.exposeContext(classes, sc, habitat); + adapter = getLazyJersey().exposeContext(classes, sc, habitat); ((GrizzlyAdapter) adapter).setResourcesContextPath(context); logger.info("Listening to REST requests at context: " + context + "/domain"); @@ -460,33 +448,10 @@ private void reportError(GrizzlyRequest req, GrizzlyResponse res, int statusCode, String msg) { - try { - // TODO: There's a lot of arm waving and flailing here. I'd like this to be cleaner, but I don't - // have time at the moment. jdlee 8/11/10 - RestActionReporter report = new RestActionReporter(); //getClientActionReport(req); - report.setActionExitCode(ActionReport.ExitCode.FAILURE); - report.setActionDescription("Error"); - report.setMessage(msg); - BaseProvider provider; - String type = getAcceptedMimeType(req); - if ("xml".equals(type)) { - res.setContentType("application/xml"); - provider = new ActionReportResultXmlProvider(); - } else if ("json".equals(type)) { - res.setContentType("application/json"); - provider = new ActionReportResultJsonProvider(); - } else { - res.setContentType("text/html"); - provider = new ActionReportResultHtmlProvider(); + // delegate to the class that knows about all Jersey API + // for faster startup of this adapter. + getLazyJersey().reportError(req, res, statusCode, msg); } - res.setStatus(statusCode); - res.getOutputStream().write(provider.getContent(new ActionReportResult(report)).getBytes()); - res.getOutputStream().flush(); - res.finishResponse(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } private volatile com.sun.grizzly.tcp.Adapter adapter = null; private boolean isRegistered = false; Index: adapter/RestManagementAdapter.java --- adapter/RestManagementAdapter.java Base (BASE) +++ adapter/RestManagementAdapter.java Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -39,21 +39,9 @@ */ package org.glassfish.admin.rest.adapter; -import com.sun.enterprise.config.serverbeans.Domain; -import java.util.HashSet; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.glassfish.admin.rest.generator.ASMResourcesGenerator; -import org.glassfish.admin.rest.generator.ResourcesGenerator; -import org.glassfish.admin.rest.resources.GeneratorResource; -import org.glassfish.admin.rest.resources.StatusGenerator; -import org.glassfish.admin.rest.resources.custom.ManagementProxyResource; import org.jvnet.hk2.annotations.Service; -import org.jvnet.hk2.config.ConfigModel; -import org.jvnet.hk2.config.Dom; -import org.jvnet.hk2.config.DomDocument; /** * Adapter for REST management interface @@ -71,67 +59,9 @@ @Override protected Set> getResourcesConfig() { - Class domainResourceClass = null;//org.glassfish.admin.rest.resources.generated.DomainResource.class; + return getLazyJersey().getResourcesConfigForManagement(habitat); - generateASM(); - try { - domainResourceClass = Class.forName("org.glassfish.admin.rest.resources.generatedASM.DomainResource"); - } catch (ClassNotFoundException ex) { - Logger.getLogger(RestManagementAdapter.class.getName()).log(Level.SEVERE, null, ex); } - final Set> r = new HashSet>(); - // uncomment if you need to run the generator: - r.add(GeneratorResource.class); - r.add(StatusGenerator.class); - //r.add(ActionReportResource.class); - - r.add(domainResourceClass); - r.add(ManagementProxyResource.class); - r.add(org.glassfish.admin.rest.resources.SessionsResource.class); //TODO this needs to be added to all rest adapters that want to be secured. Decide on it after the discussion to unify RestAdapter is concluded - r.add(org.glassfish.admin.rest.resources.StaticResource.class); - - //body readers, not in META-INF/services anymore - r.add(org.glassfish.admin.rest.readers.FormReader.class); - r.add(org.glassfish.admin.rest.readers.ParameterMapFormReader.class); - r.add(org.glassfish.admin.rest.readers.JsonHashMapProvider.class); - r.add(org.glassfish.admin.rest.readers.JsonPropertyListReader.class); - r.add(org.glassfish.admin.rest.readers.JsonParameterMapProvider.class); - - r.add(org.glassfish.admin.rest.readers.XmlHashMapProvider.class); - r.add(org.glassfish.admin.rest.readers.XmlPropertyListReader.class); - - //body writers - r.add(org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.class); - r.add(org.glassfish.admin.rest.provider.ActionReportResultJsonProvider.class); - r.add(org.glassfish.admin.rest.provider.ActionReportResultXmlProvider.class); - - - r.add(org.glassfish.admin.rest.provider.FormWriter.class); - - r.add(org.glassfish.admin.rest.provider.GetResultListHtmlProvider.class); - r.add(org.glassfish.admin.rest.provider.GetResultListJsonProvider.class); - r.add(org.glassfish.admin.rest.provider.GetResultListXmlProvider.class); - - r.add(org.glassfish.admin.rest.provider.OptionsResultJsonProvider.class); - r.add(org.glassfish.admin.rest.provider.OptionsResultXmlProvider.class); - - return r; } - - private void generateASM() { - try { - Domain entity = habitat.getComponent(Domain.class); - Dom dom = Dom.unwrap(entity); - DomDocument document = dom.document; - ConfigModel rootModel = dom.document.getRoot().model; - - ResourcesGenerator resourcesGenerator = new ASMResourcesGenerator(); - resourcesGenerator.generateSingle(rootModel, document); - resourcesGenerator.endGeneration(); - } catch (Exception ex) { - Logger.getLogger(GeneratorResource.class.getName()).log(Level.SEVERE, null, ex); - } - } -} Index: adapter/RestMonitoringAdapter.java --- adapter/RestMonitoringAdapter.java Base (BASE) +++ adapter/RestMonitoringAdapter.java Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -40,7 +40,6 @@ package org.glassfish.admin.rest.adapter; -import java.util.HashSet; import java.util.Set; import org.jvnet.hk2.annotations.Service; @@ -62,14 +61,8 @@ @Override protected Set> getResourcesConfig(){ - final Set> r = new HashSet>(); - r.add(org.glassfish.admin.rest.resources.MonitoringResource.class); + return getLazyJersey().getResourcesConfigForMonitoring(habitat); - r.add(org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.class); - r.add(org.glassfish.admin.rest.provider.ActionReportResultJsonProvider.class); - r.add(org.glassfish.admin.rest.provider.ActionReportResultXmlProvider.class); - - return r; } public static final String CONTEXT = "/monitoring"; } Index: generator/ASMClassWriter.java --- generator/ASMClassWriter.java Base (BASE) +++ generator/ASMClassWriter.java Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -435,7 +435,8 @@ } }); - clM.invoke(/*similarClass.getClassLoader()*/Thread.currentThread().getContextClassLoader(), generatedClassName, byteContent, 0, + clM.invoke(similarClass.getClassLoader() + /*Thread.currentThread().getContextClassLoader()*/, generatedClassName, byteContent, 0, byteContent.length, pd); //load it