Unable to use http proxy with NewsReader since migration to new httpClient builder architecture

10 views
Skip to first unread message

Jérôme NENERT

unread,
Sep 7, 2023, 3:42:07 AM9/7/23
to uPortal Community, uport...@apereo.org
Hi,

Since migration to new httpClient builder architecture (
https://github.com/uPortal-Project/NewsReaderPortlet/commit/19c27b56d7a29cbb01a863f0c2a3d0069a4f5ef6
) , NewsReader can't use http.proxyHost and http.proxyPort. It was
working fine before ( using -Dhttp.proxyHost & -Dhttp.proxyPort options ).

Any ideas for solution/workaround?

ERROR [localhost-startStop-2] o.s.web.context.ContextLoader 2023-09-06
17:11:52,989 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'org.jasig.portlet.newsreader.adapter.RomeAdapter'
defined in class path resource [context/applicationContext.xml]:
Invocation of init method failed; nested exception is
java.lang.UnsupportedOperationException
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1619)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)
    at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4441)
    at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4899)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
    at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:710)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:687)
    at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:661)
    at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1177)
    at
org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1925)
    at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.UnsupportedOperationException: null
    at
org.apache.http.impl.client.InternalHttpClient.getParams(InternalHttpClient.java:211)
    at
org.jasig.portlet.newsreader.adapter.RomeAdapter.init(RomeAdapter.java:163)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1748)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1685)
    at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1615)
    ... 25 common frames omitted

Regards.

Jérôme NENERT
IT Services
Paris-Panthéon-Assas Université

Benito Gonzalez

unread,
Sep 8, 2023, 6:48:47 PM9/8/23
to Jérôme NENERT, uPortal Community, uport...@apereo.org
Hi,

It looks like HttpClient requires a call now in the builder to pick up System properties. I suggest adding the following to your overrides context:

```
    <bean id="httpClientBuilder" class="org.apache.http.impl.client.HttpClientBuilder"
          factory-method="create">
          <property name="defaultRequestConfig" ref="requestConfig" />
          <property name="retryHandler" ref="retryHandler" />
          <property name="SSLSocketFactory" ref="sslSocketFactory" />
    </bean>

    <bean id="systemHttpClientBuilder" factory-bean="httpClientBuilder" 
          factory-method="useSystemProperties"/>

    <bean id="httpClient" factory-bean="systemHttpClientBuilder" factory-method="build" />
```
You may need to move the property nodes from the httpClientBuilder to the systemHttpClientBuilder.

If you get it to work, please let us know or submit a PR.

Thanks!
-bjagg


--
You received this message because you are subscribed to the Google Groups "uPortal Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uportal-user...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/uportal-user/b96e2289-8e54-b692-c4ff-4c9e1f2f7030%40u-paris2.fr.

Jérôme NENERT

unread,
Sep 11, 2023, 10:28:46 AM9/11/23
to uport...@apereo.org, uPortal Community

Hi,

Tried to add your suggested overrides context, but unfortunately still getting the same error ( org.apache.http.impl.client.InternalHttpClient.getParams() java.lang.UnsupportedOperationException ).

Regards.

You received this message because you are subscribed to the Google Groups "uPortal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uportal-dev...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/uportal-dev/CAJ_1GkTuW5SNApHGTMAZqdKA8fZfjLJjdeqn9pD9Vm%3Ddz1B_Cg%40mail.gmail.com.

Jérôme NENERT

unread,
Feb 12, 2024, 5:26:32 AMFeb 12
to uport...@apereo.org, uPortal Community

Hi,

With suggested overrides context, issue is still here because deprecated httpClient.getParams() is called ( init from RomeAdapater code ) when http.proxyHost and http.proxyPort are set by JVM options.

Regards.

Reply all
Reply to author
Forward
0 new messages