Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Loader Delegate false not working #24808

Open
kurtomerfaruk opened this issue Feb 13, 2024 · 2 comments
Open

Class Loader Delegate false not working #24808

kurtomerfaruk opened this issue Feb 13, 2024 · 2 comments

Comments

@kurtomerfaruk
Copy link

Environment Details

  • GlassFish Version (and build number): 7.0.9-7.0.12
  • JDK version: JDK 11
  • OS: Windows 11
  • Database: Microsoft Sql Server

Problem Description

Although I use in glassfish-web.xml, Glassfish uses the jars on the server.

             <dependency>
                <groupId>org.glassfish</groupId>
                <artifactId>jakarta.faces</artifactId>
                <version>4.0.4</version>
            </dependency>

[2024-02-13T15:55:38.537894+03:00] [GF 7.0.9] [INFO] [faces.config.listener.version] [jakarta.enterprise.resource.webcontainer.faces.config] [tid: _ThreadID=57 _ThreadName=admin-listener(2)] [levelValue: 800] [[ Initializing Mojarra 4.0.5 for context

I also have the same problem with other jars.

@OndroMih
Copy link
Contributor

Hi, which other jars you have a problem with?

In general, it's not possible to just add a library into your application and expect that GlassFish will use it. GlassFish will usually use the components inside GlassFish - for example Mojarra will be used when GlassFish detects that your application uses JSF and it needs to start a JSF engine. When you disable classLoader delegation, what changes is where classes are loaded from if they are imported into other classes in the application.

However, specifically for Jakarta Faces, there's an option supported in glassfish-web.xml file. You can specify the property useBundledJsf to true if you want to use a Jakarta Faces implementation packaged in your application:

<glassfish-web-app error-url="">
  <class-loader delegate="false"/>
  <property name="useBundledJsf" value="true"/>
</glassfish-web-app>

To explain how classloader delegation works for other components, I'll give you an example with Jackson JSON mapper, which is present in GlassFish and is also often bundled in applications. By default, you don't need to add Jackson JARs to your application and you can still access the Jackson's ObjectMapper class directly, e.g. from a servlet. If you add Jackson JARs to your application, the application will still use the Jackson library in GlassFish. WIth delegate=false, your application will use Jackson library in your app.

There is an exception: If a class's package starts with jakarta, it's always loaded from GlassFish. Even if delegate=false and you have that class somewhere in your application.

Here's documentation about Class Loader Delegation.

@kurtomerfaruk
Copy link
Author

unavailable except for the jar inside the server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants