Lorg/apache/http/client/methods/HttpUriRequest; - httpclient

by: java.lang.NoSuchMethodError: No virtual method
execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/client/methods/CloseableHttpResponse;
in class Lorg/apache/http/impl/client/DefaultHttpClient; or its super
classes (declaration of
'org.apache.http.impl.client.DefaultHttpClient' appears in
/system/framework/ext.jar)
where is the problem?

Related

Getting GWT RPC Serialization Error while populating liststore of ComboBox

I am using GWT 2.9 and I am getting below error
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosOptionModel' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = com.xyz.nos.model.NosOptionModel#6cad8f33
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosOptionModel' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = com.xyz.nos.model.NosOptionModel#5fc5e111
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosCaseDetailModel' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = com.xyz.nos.model.NosCaseDetailModel#af3642f
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.CountryGroupModel' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = com.xyz.nos.model.CountryGroupModel#51987007
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'com.xyz.nos.model.NosUser' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = com.xyz.nos.model.NosUser#28bbfa7f
I am doing GWT RPC for populating liststore of combobox and getting above exception while performing it from EntryPoint class. All the above classes are Pojo's and all the fields of these classes are Serializable
I have tried all possible solutions given in GWT - RPC SerializationException
I have defined my service as below
public interface INamedComboListDataProvider<M> extends RemoteService {
public List<M> load(String name);
}
I also have checked my serializationWhitelist and it only contain following 25 classes
{class com.google.gwt.user.client.ui.TreeListenerCollection=true, class java.lang.String=true, class com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException=true, class com.google.gwt.user.client.ui.FocusListenerCollection=true, class com.google.gwt.user.client.rpc.RpcTokenException=true, class java.util.LinkedList=true, class java.lang.RuntimeException=false, class com.google.gwt.user.client.ui.LoadListenerCollection=true, class com.google.gwt.user.client.ui.ClickListenerCollection=true, class com.google.gwt.user.client.ui.FormHandlerCollection=true, class java.lang.Throwable=false, class com.google.gwt.user.client.ui.KeyboardListenerCollection=true, class com.google.gwt.user.client.ui.MouseListenerCollection=true, class com.google.gwt.user.client.ui.TabListenerCollection=true, class java.util.Vector=true, class com.google.gwt.user.client.ui.ChangeListenerCollection=true, class com.google.gwt.user.client.ui.ScrollListenerCollection=true, class com.google.gwt.user.client.ui.PopupListenerCollection=true, class com.google.gwt.user.client.ui.MouseWheelListenerCollection=true, class java.util.Arrays$ArrayList=true, class java.lang.Exception=false, class java.util.ArrayList=true, class java.util.Collections$EmptyList=true, class java.util.Collections$SingletonList=true, class com.google.gwt.user.client.ui.TableListenerCollection=true}
I also have added project folder structure below
client
model
service
services
util
Common.gwt.xml
Main.gwt.xml
Can anybody guide me where I am going wrong and why does the serializationwhilteList does not contain the pojo models ?

Injection causes WELD-001408: Unsatisfied dependencies

I have a java EE web application in which a particular injection causes following error:
WELD-001408: Unsatisfied dependencies for type GenericDAO with qualifiers #Default
MyBean
#Stateless
public class MyBean extends CustomBean<Entity> {
...
}
CustomBean
public class CustomBean<T extends Serializable> implements Serializable {
#Inject
private GenericDAO<T> genericDAO;
}
GenericDAO
public abstract class GenericDAO<T extends Serializable> implements Serializable {
...
}
The issue appears only if a beans.xml is defined in the application. Deleting this, solves also the issue. In my case beans.xml is needed. Also when removing the GenericDAO<T> genericDAO; injection from the CustomBean, the error does not appear anymore. Also the rest of my injection in other classes, seem to work without any issue.
I've tried to solve that by creating an interface of GenericDAO and inject the interface instead. Also tried to with several anotations like #Local , #Dependent etc but i stumble upon different errors every time.

Why does Scalatra give me a FlashMap casting error sometimes?

When running Scalatra in code reload mode, if I load the page before the scalate engine has reinitialized I get a 500 error.
If I watch the terminal until it looks like the engine has fully reloaded, it works fine, but I think this happens when I load the page between a) successful compile, and b) the container restart.
This won't correct itself until I change something else and force a new compile and code reload.
I can't seem to find why this is happening, does anyone have any ideas?
Here is how I'm doing code reloading:
./sbt "container:start" "~ ;copy-resources;aux-compile"
Here is the error I see:
HTTP ERROR 500
Problem accessing /. Reason:
org.scalatra.FlashMap cannot be cast to org.scalatra.FlashMap
Caused by:
java.lang.ClassCastException: org.scalatra.FlashMap cannot be cast to org.scalatra.FlashMap
at org.scalatra.FlashMapSupport$$anonfun$org$scalatra$FlashMapSupport$$getFlash$2$$anonfun$1.apply(flashMap.scala:182)
at org.scalatra.FlashMapSupport$$anonfun$org$scalatra$FlashMapSupport$$getFlash$2$$anonfun$1.apply(flashMap.scala:182)
at scala.Option.map(Option.scala:145)
at org.scalatra.FlashMapSupport$$anonfun$org$scalatra$FlashMapSupport$$getFlash$2.apply(flashMap.scala:181)
at org.scalatra.FlashMapSupport$$anonfun$org$scalatra$FlashMapSupport$$getFlash$2.apply(flashMap.scala:180)
at scala.Option.getOrElse(Option.scala:120)
at org.scalatra.FlashMapSupport$class.org$scalatra$FlashMapSupport$$getFlash(flashMap.scala:180)
at org.scalatra.FlashMapSupport$class.flash(flashMap.scala:192)
at beekeeper.controllers.HomeServlet.flash(HomeServlet.scala:13)
at org.scalatra.FlashMapSupport$$anonfun$handle$1.apply$mcV$sp(flashMap.scala:137)
at org.scalatra.FlashMapSupport$$anonfun$handle$1.apply(flashMap.scala:136)
at org.scalatra.FlashMapSupport$$anonfun$handle$1.apply(flashMap.scala:136)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
at org.scalatra.DynamicScope$class.withRequest(DynamicScope.scala:71)
at org.scalatra.ScalatraServlet.withRequest(ScalatraServlet.scala:49)
at org.scalatra.FlashMapSupport$class.handle(flashMap.scala:136)
at beekeeper.controllers.HomeServlet.handle(HomeServlet.scala:13)
at org.scalatra.ScalatraServlet.service(ScalatraServlet.scala:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:744)
This error says that there are 2 instances of the same class, loaded by different class loaders. This behavior rooted in java: classes from different class loaders are not the same. Basically equals method for classes is the function of a class name and a class loader. Classes will not be the same in this case even if they come from the same jar or folder.
When container reloads code it creates a new class loader, while your session still holds instance of flash map loaded using old class loader. This most likely the cause of the issue.
In Java every class is identified by its fully qualified class name and the class loader that has loaded it, this implies that:
ClassLoader1.my.package.MyClass != ClassLoader2.my.package.MyClass
This signifiy that it is not possible to cast an object of class MyClass loaded in ClassLoader1 to type MyClass loaded from ClassLoader2. You can find more details on
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html
On the other hand, it is not possible to load the same class twice in the same class loader, so you need a new class loader, there is no way around it. While I never wrote code that performs class reloading, one can suppose that class reloading means in practice:
create a new class loader
reload the class
swap class loaders
Because of what described above, one needs to be careful when designing classes that are supposed to be reloaded: see http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html#designing

Persisting Classes implementing an interface with GORM MongoDB Plugin

I am having a problem while persisting a class. I have a class called Scraper which uses an interface called Paginator. There are several implementations of the Paginator interface which will be instantiated at runtime. So the structure looks like this:
class Scraper {
//some code
Paginator paginator
//more code
def Scraper(Paginator paginator){
this.paginator = paginator
}
}
and then there are the concrete implementations of the paginator interface lets say paginatorA and paginatorB. So now I am trying to do the following:
PaginatorA p = new PaginatorA()
Scraper s = new Scaper(p)
s.save(flush:true)
...and what it get is:
Error Error executing script TestApp:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDatastore': Cannot resolve reference to bean 'mongoMappingContext' while setting bean property 'mappingContext';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException (Use --stacktrace to see the full trace)
Can anybody tell me what to make of this? I guess it has something to do with the Mapper because it doesn't know which concrete Paginator to use or how to persist it? If that is the case then how can I tell the framework what to do? I tried to come up with a solution for hours now and am really frustrated so any help would be really really appreciated.
Oh btw I also tried implementing against the concrete implementation (PaginatorA) ... this works perfectly fine since my assumption that it has something to do with the paginator interface.
Thanks for any response...
The error is bad, you should probably raise a JIRA issue for that, but fundamentally there are 2 problems I can see with the code:
Your persistent classes must have a public no-args constructor as per any JavaBean, by adding a constructor that takes your interface, you are no longer providing one
Your Scraper class needs to mark the 'Paginator' as transient to tell the persistence engine not to attempt to persist the 'paginator' property. Since this a custom interface it will not know how to persist it.

Problem integrating JavaScript into GWT with JSNI

I am trying to create a simple binding for WebSockets for GWT using JSNI, but I keep getting an exception every time a JSNI method is invoked. The simplified class definition is as fallows:
public class Socket extends JavaScriptObject{
protected Socket() {}
public static native Socket connect(String url) /*-{
return new WebSocket(url);
}-*/;
}
While trying to instantiate a Socket object, using the line :
Socket socket = Socket.connect("http://www.google.com");
i get the fallowing exception and I don't know why :
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:193)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassFormatError: Illegal method name "$" in class edu/catalindumitru/gwt/socket/Socket
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1078)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at edu.catalindumitru.gwt.steel.client.GameCore.onModuleLoad(GameCore.java:32)
... 9 more
I have tried previously to create a similar binding for typed arrays and web workers, but I got the exact same error, so I decided to suspend development for those bindings and try something simpler until I can find the reason for this exception.
I got the same error report from GWT when using JavaScriptObject's quite conventionally.
My problem was simply that all JSO methods must be declared final, and I had missed one.
You are missing the $wnd prefix
return new $wnd.WebSocket(url);
Take a look how others have implemented it: http://code.google.com/p/gwt-comet/source/browse/trunk/src/net/zschech/gwt/websockets/client/WebSocket.java
Maybe you could just use gwt-comet's websockets?
Just a guess, but as far as I seen the overlays were used rather for JSON type data. Here your try to perform marshaling for browser API object. I'm not sure if it is going to work this way. Especially that JSNI have restrictions of types being passed.
Maybe you could try storing WebSocket as a field in native part, and delegate methods to that field. But this is just a blind guess.