I have 2 different porltets that use the same component HttpClientBuilder.java, first it's working ok, but the second give me this erorr:
java.lang.NoClassDefFoundError: org/apache/http/impl/conn/ManagedHttpClientConnectionFactory
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.(PoolingHttpClientConnectionManager.java:493)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:149)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:138)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:114)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726)
at com.firm.msite.portlet.shops.StoreJSON.load(StoreJSON.java:55)
at com.firm.msite.portlet.shops.ShopsPortlet.doView(ShopsPortlet.java:137)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.bea.portlet.container.PortletStub.doRender(PortletStub.java:942)
at com.bea.portlet.container.FilterChainGenerator.runFilterChain(FilterChainGenerator.java:125)
at com.bea.portlet.container.PortletStub.render(PortletStub.java:414)
at com.bea.portlet.container.AppContainer.renderStub(AppContainer.java:1123)
at com.bea.portlet.container.AppContainer.invokeRender(AppContainer.java:1055)
at com.bea.netuix.servlets.controls.content.JavaPortletContent.fireRender(JavaPortletContent.java:267)
at com.bea.netuix.servlets.controls.content.JavaPortletContent.renderInternal(JavaPortletContent.java:162)
at com.bea.netuix.servlets.controls.content.JavaPortletContent.beginRender(JavaPortletContent.java:108)
at com.bea.netuix.nf.ControlLifecycle$7.visit(ControlLifecycle.java:485)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:518)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
a part of code that generate this error:
long beginTime= (new Date()).getTime();
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(this.url);
// add request header
CloseableHttpResponse response = client.execute(request);
Can some one help me please ?
EDIT: We are using WebLogic Portal from Oracle
If you are using Maven to manage your dependency you can add a new dependency as below in your pom.xml
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
Provide more info of your environment, if this does not help .
Certainly it is a classloading issue, and that class canbe found at: httpclient-4.5.jar
You can check from which jar file is the functional portlet retrieving that class: http://devwebcl.blogspot.cl/2016/03/logging-of-class-loading-and-unloading.html
One approach is to put the following code in the mentioned code:
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
System.out.println(url.getFile());
}
or use: -verbose:class system property, but this is more verbose and you need to change your startup scripts.
This way you can identify which jar file is missing. (maybe it is a different name for httpclient)
Related
I'm trying to implement code that uses the Azure Java SDK to list the SQL Server instances running on my Azure subscription.
I followed the examples posted and wrote the following code:
Azure azure = Azure.authenticate(credentials)).withDefaultSubscription();
SqlServers sqlServers = azure.sqlServers();
PagedList<SqlServer> list = sqlServers.list();
But the last line throws a java.lang.NoSuchMethodError with the following stack trace:
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeBindings.create(Ljava/lang/Class;[Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/type/TypeBindings;
at com.microsoft.rest.serializer.JacksonAdapter.constructJavaType(JacksonAdapter.java:119)
at com.microsoft.rest.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:131)
at com.microsoft.rest.ServiceResponseBuilder.buildBody(ServiceResponseBuilder.java:216)
at com.microsoft.rest.ServiceResponseBuilder.build(ServiceResponseBuilder.java:110)
at com.microsoft.azure.AzureResponseBuilder.build(AzureResponseBuilder.java:56)
at com.microsoft.azure.management.sql.implementation.ServersInner.listDelegate(ServersInner.java:553)
at com.microsoft.azure.management.sql.implementation.ServersInner.access$400(ServersInner.java:42)
at com.microsoft.azure.management.sql.implementation.ServersInner$17.call(ServersInner.java:539)
at com.microsoft.azure.management.sql.implementation.ServersInner$17.call(ServersInner.java:535)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:173)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138)
at rx.Observable.unsafeSubscribe(Observable.java:10142)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.subscribe(Observable.java:10238)
at rx.Observable.subscribe(Observable.java:10205)
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:444)
at rx.observables.BlockingObservable.single(BlockingObservable.java:341)
at com.microsoft.azure.management.sql.implementation.ServersInner.list(ServersInner.java:488)
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.TopLevelModifiableResourcesImpl.list(TopLevelModifiableResourcesImpl.java:116)
at AzureDiscoveryClient.main(AzureDiscoveryClient.java:19)
This obviously looks like a defect as the SDK allows to do that and should return a reasonable error code if something goes wrong.
Still, is there any other way to list the SQL Server instances running in my Azure subscription? Or perhaps I'm doing something in my code?
Please refer to my working code as below:
import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.credentials.ApplicationTokenCredentials;
import com.microsoft.azure.management.Azure;
import com.microsoft.azure.management.sql.SqlServer;
import com.microsoft.azure.management.sql.SqlServers;
import java.io.IOException;
public class ListSqlInstance {
public static void main(String[] args) throws IOException {
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(
"{client Id}",
"{talent Id}",
"{secret}",
AzureEnvironment.AZURE);
Azure.Authenticated azureAuth = Azure.authenticate(credentials);
Azure azure = azureAuth.withDefaultSubscription();
SqlServers sqlServers = azure.sqlServers();
PagedList<SqlServer> list = sqlServers.list();
System.out.println(list.size());
}
}
My sdk version:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
version>1.12.0</version>
</dependency>
Don't forget grant access sql server permissons to your client.
Hope it helps you.
I am not sure if you are looking for a powershell cmdlet solution. But this Powershell cmdlet should list all the sql server instances in your subscription.
Assuming prior to running this powershell cmdlet you already logged in to your azure account in powershell and set the current subscription in the current powershell session if you have multiple subscriptions mapped to your account.
PS C:\azure> get-azurermresourcegroup | get-azurermsqlserver
ResourceGroupName : DbRG
ServerName : testSqlserver
Location : East US
SqlAdministratorLogin : XXXX
SqlAdministratorPassword : XXX
ServerVersion : 12.0
Tags :
Problem solved!
The error came from an incompatibility between the Azure SDK and the jackson-databind library.
One of the methods used from this library is relatively new, and the version I had in my project (clean project with just one import - Azure SDK) did not have this method.
Imported the latest jackson-databind as follows:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
Has solved the problem.
Thanks Everyone for the help.
This question is about java library of Siddhi - CEP
Description:
I tried to establish an HTTP source to receive data. There was no error creating the Runtime and starting it.
[nioEventLoopGroup-2-1] INFO org.wso2.transport.http.netty.listener.ServerConnectorBootstrap$HTTPServerConnector - HTTP(S) Interface starting on host localhost and port 9056
[main] INFO org.wso2.extension.siddhi.io.http.source.HttpConnectorPortBindingListener - siddhi: started HTTP server connector localhost:9056
[main] INFO org.wso2.extension.siddhi.io.http.source.HttpSourceListener - Source Listener has created for url http://localhost:9056/endpoints/
However, when I send a POST request to the designated address. I get an error:
[nioEventLoopGroup-3-1] ERROR org.wso2.extension.siddhi.io.http.source.HTTPConnectorListener - Error in http server connector
java.lang.NoSuchMethodError: io.netty.handler.codec.http.HttpRequest.method()Lio/netty/handler/codec/http/HttpMethod;
at org.wso2.transport.http.netty.listener.CustomHttpContentCompressor.decode(CustomHttpContentCompressor.java:44)
at org.wso2.transport.http.netty.listener.CustomHttpContentCompressor.decode(CustomHttpContentCompressor.java:14)
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:354)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:748)
Could anyone suggest a reason of what I have done wrong? Thank you in advance.
Affected Product Version:
4.1.17
OS, DB, other environment details and versions:
IntelliJ IDEA 2017.3.5 (Community Edition)
Build #IC-173.4674.33, built on March 6, 2018
JRE: 1.8.0_152-release-1024-b15 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Steps to reproduce:
The test code I wrote:
import org.wso2.siddhi.core.SiddhiAppRuntime;
import org.wso2.siddhi.core.SiddhiManager;
import org.wso2.siddhi.core.event.Event;
import org.wso2.siddhi.core.stream.output.StreamCallback;
import org.wso2.siddhi.core.util.EventPrinter;
//import org.wso2.extension.siddhi.io.http.source.*;
public class httpTest
{
public static void main(String[] args) {
String siddhiString = "#App:name(\"haha\") " +
"#App:description(\"fasd\") " +
"#App:statistics(reporter = \"jmx\", interval = \"30\") " +
"#source(type=\"http\",receiver.url=\"http://localhost:9056/endpoints/\",#map(type=\"text\",fail.on.missing.attribute=\"true\",regex.A=\"(.*)\",#attributes(data=\"A\"))) " +
"#sink(type=\"mqtt\",url=\"tcp://120.78.71.179:1883\",topic=\"34\",#map(type=\"text\")) " +
"define stream a4P068X5YCK(data String);";
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiString);
siddhiAppRuntime.addCallback("a4P068X5YCK", new StreamCallback() {
#Override
public void receive(Event[] events) {
EventPrinter.print(events);
}
});
siddhiAppRuntime.start();
}
}
Then I send a POST request to http://localhost:9056/endpoints/. It returns the exception posted above.
Update:
I went back and check the Siddhi-io-http github documentation page. I found that it says:
... This extension only works inside the WSO2 Data Analytic Server and cannot be run with standalone siddhi.
I guess it might suggest that http is not supported by siddhi library at the moment. I have submitted issue on siddhi repository page to ask for confirmation.
Update 2:
I have changed my Siddhi Query so that it copy the source stream into the other sink stream. Other part of the code remains the same:
String siddhiString = "#App:name(\"haha\") " +
"#App:description(\"fasd\") " +
"#App:statistics(reporter = \"jmx\", interval = \"30\") " +
"#source(type=\"http\",receiver.url=\"http://localhost:9056/endpoints/\",#map(type=\"text\",fail.on.missing.attribute=\"true\",regex.A=\"(.*)\",#attributes(data=\"A\"))) " +
"define stream a4P068X5YCK(data String); " +
"#sink(type=\"mqtt\",url=\"tcp://120.78.71.179:1883\",topic=\"34\",#map(type=\"text\")) " +
"define stream pout(data String); " +
"from a4P068X5YCK " +
"select * " +
"insert into pout; " +
"";
The same problem still exists. I tried the wso2 processor and it works fine. Now my guesses are:
1. version mismatch
2. lack of some packages in wso2 processor dependecies.
I will try to identify it in those two direction and will update in here and Issue page as soon as I find something new.
Update 3:
As I keep adding updates, the format seems to have some problem but fortunately this issue also comes to an end. I tried to Include all dependencies from wso2 processor source code and my test program starts working. Therefore I assume there is a component in wso2 processor that siddhi library is lacking.
I tried to delete the dependencies one by one to see if my test program still works. Finally I have found that package. With this package my code works well.
<dependency>
<groupId>org.wso2.msf4j</groupId>
<artifactId>org.wso2.msf4j.feature</artifactId>
<version>${msf4j.version}</version>
<type>zip</type>
</dependency>
As I am a beginner to coding, I am not exactly what was the problem. I would be grateful if someone could explain to me the reason behind the problem. I appreciate all the helps received in this process and it would also be a great experience for me.
Update 4: #Grainier I tried the sample code you posted and it actually worked! Although I still have no idea why. I tried to copy your exact code to a new .java in my project. It still won't work. Therefore I guess there is something to do with POM file.
Something I noticed is that when I ran your sample code there are few more WARNINGS printed in console: SMALL UPDATE: I have found that the Warnings appeared because I am using JDK 10. As soon as I switch back to 1.8 warnings disappeared and the code still works. So maybe this is not the reason.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/C:/Users/ktz001/.m2/repository/io/netty/netty-common/4.1.16.Final/netty-common-4.1.16.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
The second difference is in the POM file. In you have one more repository added compared to mine.
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
It would be great if you could suggest any reason.
Thank you for all of your work! It has been really helpful.
There seems to be an issue with the documentation... This should work with standalone Siddhi. All you have to do is add following dependencies in your project (also mqtt, which I haven't included below);
<dependencies>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-core</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-annotations</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-compiler</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.extension.siddhi.io.http</groupId>
<artifactId>siddhi-io-http</artifactId>
<version>${siddhi.io.http.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.extension.siddhi.map.text</groupId>
<artifactId>siddhi-map-text</artifactId>
<version>${siddhi.mapper.text.version}</version>
</dependency>
</dependencies>
However, there's an issue with your query which is, you have defined a #source and a #sink to a single stream. Which is wrong. If you want to make it a passthrough, then you have to define two streams (one for source and one for sink) and write a query to insert events from source stream to sink stream.
UPDATE:
A sample can be found here; Please try that and see whether it's working.
I have some code for connecting to a JClouds swift storage container which works fine in its own test area, but once I integrate into my project, I get an error:
Exception in thread "main" java.util.ServiceConfigurationError:
org.jclouds.apis.ApiMetadata: Provider
org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata could not be
instantiated: java.lang.IllegalStateException:
java.lang.reflect.InvocationTargetException
This is the code which fails on the ContextBuilder line:
private SwiftApi swiftApi;
public JCloudsConnector(String username, String password, String endpoint) {
String provider = "openstack-swift";
Properties overrides = new Properties();
overrides.setProperty("jclouds.mpu.parallel.degree", "" + Runtime.getRuntime().availableProcessors());
swiftApi = ContextBuilder.newBuilder(provider)
.endpoint(endpoint)
.credentials(username, password)
.overrides(overrides)
.buildApi(SwiftApi.class);
}
I am using the same dependencies (JClouds version 1.7.3) so I can't understand what the problem might be since both are run in the same environment.
Thanks to Ignasi Barrera, I was able to sort this by adding an entry for Guava 15.0 in my maven POM file:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
I'm having trouble with richfaces 4.3.1 on weblogic 10.3.5.0, on deploy the following exception happens:
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! duplicate key: class javax.faces.validator.LongRangeValidator
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:290)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
Truncated. see log file for complete stacktrace
Caused By: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! duplicate key: class javax.faces.validator.LongRangeValidator
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:351)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:222)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalArgumentException: duplicate key: class javax.faces.validator.LongRangeValidator
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:72)
at com.google.common.collect.ImmutableMap$Builder.fromEntryList(ImmutableMap.java:245)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:231)
at org.richfaces.javascript.ClientServiceConfigParser.parseConfig(ClientServiceConfigParser.java:53)
I had a look inside ClientServiceConfigParser and debugged it and I found that it ended up loading /META-INF/csv.xml twice from richfaces-components-ui-4.3.1.Final.jar
The method in question is:
public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (null == loader) {
loader = ClientServiceConfigParser.class.getClassLoader();
}
Builder<Class<?>, LibraryFunction> resultBuilder = ImmutableMap.builder();
try {
Enumeration<URL> resources = loader.getResources(name);
while (resources.hasMoreElements()) {
URL url = (URL) resources.nextElement();
resultBuilder.putAll(parse(loader, url));
}
} catch (IOException e) {
return Collections.emptyMap();
}
return resultBuilder.build();
}
It seems something to do with Weblogic's ChangeAwareClassLoader (weblogic.utils.classloaders.ChangeAwareClassLoader). Because inside org.richfaces.javascript.ClientServiceConfigParser.parseConfig(String) when it runs ClassLoader loader = Thread.currentThread().getContextClassLoader(); it ends up returning the ChangeAwareClassLoader which happens to get 2 copies of the same resource. However if I null out the loader (using a debugger) so that it runs loader = ClientServiceConfigParser.class.getClassLoader();, then it ends up with a different classloader: weblogic.utils.classloaders.GenericClassLoader. Which doesn't get 2 copies of the same resource.
For what it's worth I'm using maven and have loaded in richfaces this way:
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
Before people suggest that I've loaded the wrong maven depdencies, I can tell you its not related to: IllegalArgumentException: duplicate key (JSF)
Because using a debugger I confirmed that loader.getResources(name); returns the exact same resource.
zip:C:/bea/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/_appsdir_umsWebUI-jee-ear-1.0-SNAPSHOT_ear/6m7brt/lib/richfaces-components-ui-4.3.1.Final.jar!/META-INF/csv.xml
zip:C:/bea/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/_appsdir_umsWebUI-jee-ear-1.0-SNAPSHOT_ear/6m7brt/lib/richfaces-components-ui-4.3.1.Final.jar!/META-INF/csv.xml
Also for reference I tried the JSF forum and just put a post on the weblogic forums, but I figured I might get a better response here. The two other posts are here:
https://forums.oracle.com/forums/thread.jspa?threadID=2529414
https://community.jboss.org/thread/224100
So aside from compiling my own version of rich faces, does anyone have any ideas of workarounds? How to disable the ChangeAwareClassLoader maybe? My Google searches haven't resulted in anything when trying to disable that class loader.
Ok I managed to get 4.3.1 working in the end. It turned out that because I was using Skinny Wars in maven, it has unforseen side effects with the ChangeAwareClassLoader. I thought I tried this problem without using Skinny Wars, but I guess I didn't.
I'm trying to query my solr database based off the code provided in this question with SolrJ but it keeps throwing a null pointer exception.
My code is:
#PUT
#Produces(MediaType.TEXT_PLAIN)
public String returnText(String url) throws MalformedURLException, SolrServerException{
SolrServer server = new HttpSolrServer("http://localhost:8080/apache-solr-1.4.0");
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("?q", "*:*");
params.set("facet", true);
params.set("rows", 5);
QueryResponse response = server.query(params);
System.out.println(response);
return "success";
}
and if I run this url: http://localhost:8080/apache-solr-1.4.0/select/?q=*:*&facet=true&rows=5 in my browser then it returns the correct values however if I enter: http://localhost:8080/apache-solr-1.4.0/select/q=*:*&facet=true&rows=5 then I get the exact same error as when I run it in eclipse, the error is:
19/12/2012 1:09:01 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
org.apache.solr.client.solrj.SolrServerException: Server at http://localhost:8080/apache-solr-1.4.0 returned non ok status:500, message:null java.lang.NullPointerException at java.io.StringReader.<init>(StringReader.java:33) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:197) at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:78) at org.apache.solr.search.QParser.getQuery(QParser.java:131) at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:89) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:174) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316) at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:328)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:211)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:311)
at geoportal.webservice.download.returnText(download.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.......
If I change my code to params.set("q","*:*"); then I get this error:
19/12/2012 1:13:30 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
org.apache.solr.client.solrj.SolrServerException: Error executing query
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:95)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:311)
at geoportal.webservice.download.returnText(download.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.......
Any ideas as to what I've done wrong?
Thanks heaps
EDIT
Here is my new code for the solrQuery based off this:
#PUT
#Produces(MediaType.TEXT_PLAIN)
public String returnText(String url) throws MalformedURLException, SolrServerException{
SolrServer server = new HttpSolrServer("http://localhost:8080/apache-solr-1.4.0");
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.setFacet(true);
query.set("wt", "json");
query.setRows(5);
query.setStart(0);
QueryResponse response = server.query(query);
System.out.println(response);
return "success";
}
But it still isn't working :(
Console output:
19/12/2012 2:24:33 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
org.apache.solr.client.solrj.SolrServerException: Error executing query
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:95)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:311)
at geoportal.webservice.download.returnText(download.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
......
EDIT
I put a System.out.println(query.toString()); in my code and it outputted:
q=*%3A*&facet=true&wt=json&rows=5&start=0
If I enter this into my browser like
http://localhost:8080/apache-solr-1.4.0/select/q=*%3A*&facet=true&wt=json&rows=5&start=0
then it throws a null pointer exception again. However if I manually enter a ? in front of q=*%3A*... then it works. So I assume that my solr server needs this ? (is this because it's so old?), is there any way to hard code one in?
Thanks
Try use the SolrQuery object instead of ModifiableSolrParams. Maybe it will help.
If you cant use SolrQuery for any reason, try using statics names, like "CommonParams.Q" instead of hardcoded ones like "?q"
EDITED
I tested your problem and I think you are lacking configurations at your Application Server.
Are you using JBoss 7.1? You need to add a line to .standalone.sh or standalone.bat telling where solr is. For example, in Jboss 7.1, in default configurations, you have to add \"-Dsolr.solr.home=$SOLR_HOME/example/solr\" \ to the standalone.sh
I dont know about others Application Servers, but you can search a little and see how you can do that in another AS.
Try using SolrQuery, you have option to set everything like query, filter, facet, start, rows etc. Below is a sample code
on the latest solr 6.2.1 you can create solr client like below:
SolrClient solr = new HttpSolrClient.Builder("<url>").build();
SolrQuery query = new SolrQuery();
query.setQuery("collector:" + input);
query.addFilterQuery("(doc_type:" + entity + ")");
query.addSort("lastUpdatedAt", ORDER.desc);
query.setFacet(true);
query.setStart(pagenumber);
query.setRows(pagesize);
QueryResponse response = solr.query(query);
You might not have the same version of Solr and SolrJ.
You might be making a bad decision by using such an ancient version of Solr at all.
You are failing to check the Solr log to find out where the 500 is coming from.
You are using ModifiableSolrParams instead SolrQuery.
As the previous comments suggests try using SolrQuery.
Here is the link that may help solrj example
I think you're missing response.getResults();
this will return a SolrDocumentList which you can handle using an Iterator and loop through the results
like:
SolrDocumentList docs = response.getResults();
Iterator<SolrDocument> iter = docs.iterator();
while (iter.hasNext())
{
// handle results
}