You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Gaurav Gupta <ga...@gmail.com> on 2019/11/12 12:06:29 UTC

NetBeans plugins classloader shared

Hi all,

I am facing a weird classloader issue in Jeddict plugin that includes
*org.netbeans.api:org-netbeans-modules-xml-jaxb-api* dependency via maven
plugin nbm-maven-plugin as JAXB removed from JDK.

Every XML binding operation performs perfectly without any issue
until other plugins like Radar
<http://plugins.netbeans.org/plugin/51532/radar-netbeans> and SQL DAL Maker
<http://plugins.netbeans.org/plugin/73614/sql-dal-maker> installed in
Apache NetBeans which bundle JAXB libraries (API, Impl, and Core).

After installation of any of above-listed plugins, Jeddict plugin throws
the following error:

Message : Will not load class com.sun.xml.bind.v2.ContextFactory
> arbitrarily from one of ModuleCL@2f558e85[org.radar.radar.netbeans] and
> ModuleCL@4ccccff0[org.netbeans.libs.jaxb] starting from
> SystemClassLoader[742 modules];



As Radar and SQL DAL Maker plugins, neither part of the Apache NetBeans
Platform nor listed in Jeddict module's manifest file then how classloader
is shared.

Please help!

Thanks and kind regards,
Gaurav Gupta

Re: NetBeans plugins classloader shared

Posted by Gaurav Gupta <ga...@gmail.com>.
Thanks, Jaroslav and Matthias for the reply, soon I will try this solution.

Thanks and kind regards,
Gaurav Gupta





On Wed, Nov 13, 2019 at 1:22 AM Matthias Bläsing <mb...@doppel-helix.eu>
wrote:

> Hi,
>
> I had a similar problem (Webservice Client bases on Axis 1). It was
> possible to fix it this way:
>
>     private static MantisConnectPortType initClient(String baseUrl, String
> httpUsername, String httpPassword) throws ServiceException,
> MalformedURLException {
>         ClassLoader origLoader =
> Thread.currentThread().getContextClassLoader();
>
> Thread.currentThread().setContextClassLoader(MantisRepository.class.getClassLoader());
>         MantisConnectPortType result = null;
>         try {
>             // Initialize client
>         } finally {
>             Thread.currentThread().setContextClassLoader(origLoader);
>         }
>         return result;
>     }
>
> It was enough to just wrap the initialization, this might work for you
> to.
>
> Greetings
>
> Matthias
>
> Am Dienstag, den 12.11.2019, 17:32 +0100 schrieb Jaroslav Tulach:
> > Thread.currentThread.getContextClassLoader is asked to load the
> > class. The
> > ClassLoader sees classes from all modules. It doesn't know which one
> > to
> > choose.
> >
> > -jt
> >
> >
> > Dne út 12. 11. 2019 13:08 uživatel Gaurav Gupta <
> > gaurav.gupta.jc@gmail.com>
> > napsal:
> >
> > > Hi all,
> > >
> > > I am facing a weird classloader issue in Jeddict plugin that
> > > includes
> > > *org.netbeans.api:org-netbeans-modules-xml-jaxb-api* dependency via
> > > maven
> > > plugin nbm-maven-plugin as JAXB removed from JDK.
> > >
> > > Every XML binding operation performs perfectly without any issue
> > > until other plugins like Radar
> > > <http://plugins.netbeans.org/plugin/51532/radar-netbeans> and SQL
> > > DAL
> > > Maker
> > > <http://plugins.netbeans.org/plugin/73614/sql-dal-maker> installed
> > > in
> > > Apache NetBeans which bundle JAXB libraries (API, Impl, and Core).
> > >
> > > After installation of any of above-listed plugins, Jeddict plugin
> > > throws
> > > the following error:
> > >
> > > Message : Will not load class com.sun.xml.bind.v2.ContextFactory
> > > > arbitrarily from one of ModuleCL@2f558e85[org.radar.radar.netbean
> > > > s] and
> > > > ModuleCL@4ccccff0[org.netbeans.libs.jaxb] starting from
> > > > SystemClassLoader[742 modules];
> > >
> > >
> > > As Radar and SQL DAL Maker plugins, neither part of the Apache
> > > NetBeans
> > > Platform nor listed in Jeddict module's manifest file then how
> > > classloader
> > > is shared.
> > >
> > > Please help!
> > >
> > > Thanks and kind regards,
> > > Gaurav Gupta
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: dev-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>

Re: NetBeans plugins classloader shared

Posted by Matthias Bläsing <mb...@doppel-helix.eu>.
Hi,

I had a similar problem (Webservice Client bases on Axis 1). It was
possible to fix it this way:

    private static MantisConnectPortType initClient(String baseUrl, String httpUsername, String httpPassword) throws ServiceException, MalformedURLException {
        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(MantisRepository.class.getClassLoader());
        MantisConnectPortType result = null;
        try {
            // Initialize client
        } finally {
            Thread.currentThread().setContextClassLoader(origLoader);
        }
        return result;
    }

It was enough to just wrap the initialization, this might work for you
to.

Greetings

Matthias

Am Dienstag, den 12.11.2019, 17:32 +0100 schrieb Jaroslav Tulach:
> Thread.currentThread.getContextClassLoader is asked to load the
> class. The
> ClassLoader sees classes from all modules. It doesn't know which one
> to
> choose.
> 
> -jt
> 
> 
> Dne út 12. 11. 2019 13:08 uživatel Gaurav Gupta <
> gaurav.gupta.jc@gmail.com>
> napsal:
> 
> > Hi all,
> > 
> > I am facing a weird classloader issue in Jeddict plugin that
> > includes
> > *org.netbeans.api:org-netbeans-modules-xml-jaxb-api* dependency via
> > maven
> > plugin nbm-maven-plugin as JAXB removed from JDK.
> > 
> > Every XML binding operation performs perfectly without any issue
> > until other plugins like Radar
> > <http://plugins.netbeans.org/plugin/51532/radar-netbeans> and SQL
> > DAL
> > Maker
> > <http://plugins.netbeans.org/plugin/73614/sql-dal-maker> installed
> > in
> > Apache NetBeans which bundle JAXB libraries (API, Impl, and Core).
> > 
> > After installation of any of above-listed plugins, Jeddict plugin
> > throws
> > the following error:
> > 
> > Message : Will not load class com.sun.xml.bind.v2.ContextFactory
> > > arbitrarily from one of ModuleCL@2f558e85[org.radar.radar.netbean
> > > s] and
> > > ModuleCL@4ccccff0[org.netbeans.libs.jaxb] starting from
> > > SystemClassLoader[742 modules];
> > 
> > 
> > As Radar and SQL DAL Maker plugins, neither part of the Apache
> > NetBeans
> > Platform nor listed in Jeddict module's manifest file then how
> > classloader
> > is shared.
> > 
> > Please help!
> > 
> > Thanks and kind regards,
> > Gaurav Gupta
> > 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




Re: NetBeans plugins classloader shared

Posted by Jaroslav Tulach <ja...@gmail.com>.
Thread.currentThread.getContextClassLoader is asked to load the class. The
ClassLoader sees classes from all modules. It doesn't know which one to
choose.

-jt


Dne út 12. 11. 2019 13:08 uživatel Gaurav Gupta <ga...@gmail.com>
napsal:

> Hi all,
>
> I am facing a weird classloader issue in Jeddict plugin that includes
> *org.netbeans.api:org-netbeans-modules-xml-jaxb-api* dependency via maven
> plugin nbm-maven-plugin as JAXB removed from JDK.
>
> Every XML binding operation performs perfectly without any issue
> until other plugins like Radar
> <http://plugins.netbeans.org/plugin/51532/radar-netbeans> and SQL DAL
> Maker
> <http://plugins.netbeans.org/plugin/73614/sql-dal-maker> installed in
> Apache NetBeans which bundle JAXB libraries (API, Impl, and Core).
>
> After installation of any of above-listed plugins, Jeddict plugin throws
> the following error:
>
> Message : Will not load class com.sun.xml.bind.v2.ContextFactory
> > arbitrarily from one of ModuleCL@2f558e85[org.radar.radar.netbeans] and
> > ModuleCL@4ccccff0[org.netbeans.libs.jaxb] starting from
> > SystemClassLoader[742 modules];
>
>
>
> As Radar and SQL DAL Maker plugins, neither part of the Apache NetBeans
> Platform nor listed in Jeddict module's manifest file then how classloader
> is shared.
>
> Please help!
>
> Thanks and kind regards,
> Gaurav Gupta
>