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

Getting java.lang.NoSuchMethodException: org.eclipse.equinox.http.servlet.HttpServiceServlet.sessionDestroyed(java.lang.String) #511

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abirla-tibco
Copy link

My usecase is , i had created a keystore certificate with multiple DNS and when i was running my application using that certificate, i was getting an expection as multiple keystore certificate are not supported.

I was getting this error because jetty has changed the way it was creating the object of SslContextFactory , earlier it was creating the object as new SslContextFactory() , but now they have modified it as new SslContextFactory().Server() or new SsslContextFactory().Client().

We are using a thirdparty maven jar to create and start the jetty server and that jar is org.eclipse.equinox.http.jetty , we had version 3.4 so we have upgraded this jar , because in org.eclipse.equinox.http.jetty.3.4 , the object of SslContextFactory is getting created as new SslContextFactory().

I have upgraded it to version 3.7.600 , but after upgrading it to 3.7 i was getting an error as java.lang.NoSuchMethodException: org.eclipse.equinox.http.servlet.HttpServiceServlet.sessionDestroyed(java.lang.String).

The root cause of this error is, in HttpServerManager class there is no such method named sessionDestroyed which takes string as a parameter. In HttpServerManager there is one inner class named InternalHttpServiceServlet which contains a method called sessionDestoryed and this method takes javax.servlet.HttpSessionEvent object as a parameter.

So there is some parameter mismatch. so i have used an approch to solve this issue as instead of declaring the Method type of variable as final i have made them non-fianl so that i don't need to inialize them in the inner class constructor. Becuase in the inner class constructor jetty has initalized them using java reflaction. Jetty is trying to get the method object but in both the method initalization wrong parameter is getting used.

@laeubi laeubi requested a review from tjwatson February 12, 2024 10:42
@laeubi
Copy link
Member

laeubi commented Feb 12, 2024

@anjali-birla you need to sign the ECA. Also note the HttpService is kind of discouraged so you probably want to migrate to the HttpWhiteboard instead on the long term.

@merks
Copy link
Contributor

merks commented Feb 12, 2024

We cannot merge PRs with the ECA being in place.

https://github.com/eclipse-platform/.github/blob/main/CONTRIBUTING.md#setting-up-your-eclipse-and-github-account

It seems to me that both these places with have NullPointerException:

sessionDestroyed.invoke(httpServiceServlet, event.getSession().getId());

@abirla-tibco
Copy link
Author

abirla-tibco commented Feb 13, 2024

I got your point , as i am removing the creation of both the method object and after that when i will try invoking those method objects i will get NullPointerException.

but when I am giving a call to org.eclipse.equinox.http.jetty.internal.Activator's start() method and the start() method is giving call to HttpServerManager's updated() method .

In the HttpServerManager's updated() method , ServletHolder's object is getting created and while creating the object , new InternalHttpServiceServlet() is getting passed as a parameter.

as we are doing new InternalHttpServiceServlet() , it's constructor is getting called and when my flow reached at the constuctor of InternalHttpServiceServlet class , i am getting java.lang.NoSuchMethodException:org.eclipse.equinox.http.servlet.HttpServiceServlet.sessionDestroyed(java.lang.String). error as it's taking string as parameter while creating the method object where as the actual method is expecting the object of HttpSessionEvent as the parameter.

Can you please help me out with the approch to solve this issue or to resolve this NoSuchMethodException?

@merks
Copy link
Contributor

merks commented Feb 13, 2024

I need a way to reproduce the problem.

I’m away from the computer for a few days so can’t help until Friday at the earliest.

@abirla-tibco
Copy link
Author

No issues, Please let me know once you'll be back.

@merks
Copy link
Contributor

merks commented Feb 13, 2024

In the meantime, try to provide a way to reproduce the problem. A simple sample or better yet a test so that it never breaks again.

@abirla-tibco
Copy link
Author

I have created a basic plugin-project and in that i have overridden Activator and HttpServerManager class of org.eclipse.equinox.http.jetty-3.7.600 jar , i have copied the exact same code of the jar in these two classes, and in the MENIFEST.MF , i have added my activator in the Bundle-Activator field.

When i am running that plugin it's giving a call to my activator's start method and after that the flow till the error will be -

MyActivator.start() -> MyHttpServerManager.updated() -> this updated method is creating a object of ServleHolder [ServletHolder holder = new ServletHolder(new InternalHttpServiceServlet()); ] -> due to this new InternalHttpServiceServlet() parameter , inner class constructor is getting called and in the constuctor of the inner class, the place where we are creating the method object of sessionDestroyed and sessionIdChanged , giving me noSuchMethodException due to parameter mismatch.

I am providing a zip file which will contain that plugin and in order to run that plugin you will need to have an osgi freamework installed in your studio.

Steps To Run The Plugin: -

  1. Import the plugin in the sudio where you already have osgi [ Either you can import the archive or you can extract that zip and import that plugin]
  2. Go to the run configuration.
  3. Double-click the Equinox OSGi Framework button and it will open a runtime configuration dialog box.
  4. In that dialog box , change the value of the Name field to Hello World Bundle.
  5. You will notice that in the Plug-ins section under the Workspace plug-in , there is an entry for the
    com.javaworld.sample.HelloWorld plugin, which is checked. Under Target Platform, make sure that the checkbox next to the org.eclipse.osgi plugin is also checked.
    6.Now click the Run button.

Attachments -
Sample_OSGI_Plugin.zip
Error_Log.txt

I am attching the error log file and plugin both here with this comment. Please find both the attchments.

The same error will occur for sessionIdChanged method also.

Please help me out with the approach to fix this issue.

@merks
Copy link
Contributor

merks commented Feb 14, 2024

That sounds promising.

@merks
Copy link
Contributor

merks commented Feb 16, 2024

This seems completely unworkable to me. Your sample does not work with the latest Equinox version and your changes break the tests that rely on the things you are removing. I don't know how to deal with that and my time is limited. 😢

If you want changes in the latest version there needs to be a sample that just uses the latest version because that's the only version we can change and that version's tests need to continue to work which is not the case with your PR's changes.

} catch (Exception e) {
throw new IllegalStateException(e);
}
//removed the constructor code because it wasn't correct , method object was created using reflaction but wrong parameters were getting passed to it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must confess that delete things here completely seems incorrect to me, maybe instead you want them to be initialized on first access (e.g. with a protected method) that the can be override if desired (e.g. that seems to be what you are trying here).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delaying the problem won't help. These methods must exist or there must be an alternatives that exist in their place. Moreover, the sample code is using Jetty 9.4.x while Eclipse is using 12.x with ee8, so that seems completely unworkable to me as well. I tried to get the thing to even compile without errors with no luck. Before we can informatively discuss what can be changed, there needs to exist something that actually runs and demonstrates the problem are trying to fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that @anjali-birla tries to extend this Equinox class in some way and probably doing whatever is suitable in that situation then

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

Successfully merging this pull request may close these issues.

3 participants