google+ operations throws exception with spring social google - google-plus

The method plusOperations().getPerson(googleId) generates the following exception:
Could not read JSON: No enum const class
org.springframework.social.google.api.plus.Person$UrlType.CONTRIBUTOR
(through reference chain:
org.springframework.social.google.api.plus.Person["urls"]->
org.springframework.social.google.api.plus.ProfileURL["type"]);
nested exception is
com.fasterxml.jackson.databind.JsonMappingException: No enum const class
org.springframework.social.google.api.plus.Person$UrlType.CONTRIBUTOR
(through reference chain:
org.springframework.social.google.api.plus.Person["urls"]->
org.springframework.social.google.api.plus.ProfileURL["type"])

Related

Entry point was not found when. dotnet core 2.0 EfCore

While trying to ensure that my database has been created, I do the following in my statup class:
using (var scope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var context = scope.ServiceProvider.GetRequiredService<MyContext>();
context.Database.EnsureCreated();
}
I've registered the context within the ServiceCollection this way:
services.AddDbContext<MyDbContext>(options => options.UseSqlServer(connectionString));
When calling EnsureCreated() I get the following exception:
DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[mynamespace.Data.MyDbContext])' on type 'MyDbContext'. ---> Entry point was not found. (See inner exception for details.)
DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ChtrDbContext (ReflectionActivator), Services = [chtr.server.data.Data.ChtrDbContext], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[mynamespace.MyDbContext])' on type 'MyDbContext'. ---> Entry point was not found. (See inner exception for details.) (See inner exception for details.)
It's worth noticing that I use Autofac as my IoC Framework

How to use exception mapper for exceptions thrown from interceptors in MSF4J

I added a authorisation module in interceptor, and tried to use exception mapper to throw 401 status code, but even if it is scanning my exception mapper, it is not using it in runtime.
#Component
public class ExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<Exception> {
public ExceptionMapper() {
System.out.println("true Manish= " + true);
}
#Override
public Response toResponse(Exception exception) {
System.out.println("product Manish Exception comning here");
return Response.status(Response.Status.EXPECTATION_FAILED).
entity(exception.getMessage()).
type("text/plain").
build();
}
}
So, it is printing true Manish=true, but when my interceptor throws an exception, it doesn't hit toResponse() method
At the moment MSF4J can't map the exception which are get thrown from interceptor level. It only can map the exceptions which are thrown inside the actual service. We would like to enhance that to having global exception mappers. https://github.com/wso2/msf4j/issues/327 been created for that.

Red5 Application fails to connect

I am attempting to run a basic application on Red5 that just makes an attempt to connect to the red5 server (on localhost). The source for this application is below:
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.scope.IScope;
// import org.red5.server.api.service.ServiceUtils;
/**
* Sample application that uses the client manager.
*
* #author The Red5 Project (red5#osflash.org)
*/
public class Application extends ApplicationAdapter {
/** {#inheritDoc} */
#Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
return true;
}
/** {#inheritDoc} */
#Override
public void disconnect(IConnection conn, IScope scope) {
super.disconnect(conn, scope);
}
}
My client code is also pretty basic. For brevity, the snippet is below:
public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.connect("rtmp://localhost/Player");
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
connection.client = this;
}
public function onConnectionNetStatus(event:NetStatusEvent) : void {
// did we successfully connect
if(event.info.code == "NetConnection.Connect.Success") {
Alert.show("Successful Connection", "Information");
} else {
Alert.show("Unsuccessful Connection "+event.info.code, "Information");
}
Note that I make the alert box show the error code so I can see what happens.
On the client side, when I attempt to connect, I get two failure messages:
Unsuccessful Connection NetConnection.Connect.Closed
Unsuccessful Connection NetConnection.Connect.Rejected
And on the server side I am seeing the following:
[INFO] [NioProcessor-10]
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Action connect
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPConnection -
Setting object encoding to AMF3
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPHandler - Scope
Player not found on localhost
[WARN] [Red5_Scheduler_Worker-3]
org.red5.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection
from 127.0.0.1 : 50051 to localhost (in: 3334 out 3256 ), with id 9
due to long handshake
It seems clear that something is wrong due to some kind of mis- configuration. Unfortunately, I have no idea where to look for the problem.
Could someone please give some idea of what is going wrong and how I can fix this? Thank you...
ADDITION: Startup Exception that occurs when running Red5 v1 RC2:
Exception in thread "Launcher:/Player" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with
name 'web.context' defined in ServletContext resource [/WEB-INF/red5-web.xml]:
Unsatisfied dependency expressed through bean property 'clientRegistry': : Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml];
nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1199)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:593)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:833)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1184)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
... 19 more
Another Fact could be that u have 2 Red5.jars so u have to delete one. In my case it worked rly good.
Big Ty for this post
Change org.red5.server.WebScope to org.red5.server.scope.WebScope in your red5-web.xml file.
what version of Red5 is that?
Are there any exceptions when you startup your custom webapp? There might be already an error in the startup of the server that consequently leads to your issue.
Sebastian
The application scope that you are attempting to connect to "Player" does not exist on the server; the log notes this as "Scope Player not found on localhost". What this means in general is that your application didn't load. The reason that it didn't load looks like class package error for WebScope. Change the beans class attribute to org.red5.server.scope.WebScope and try again.

When using Ninject in my MVC3 I get a Ninject.ActivationException: Error activating IRepository{Ranking} installed via Nuget

I installed Ninject via nuget, and I registered my binds in NinjectMVC3's RegisterServices method (created by nuget). Follow my code:
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<IUnitOfWork>().To<UnitOfWork>();
kernel.Bind<IRepository<Action>>().To<ActionRepository>();
kernel.Bind<IRepository<ActionType>>().To<ActionTypeRepository>();
kernel.Bind<IRepository<City>>().To<CityRepository>();
kernel.Bind<IRepository<Country>>().To<CountryRepository>();
kernel.Bind<IRepository<Goods>>().To<GoodsRepository>();
kernel.Bind<IRepository<Media>>().To<MediaRepository>();
kernel.Bind<IRepository<MediaType>>().To<MediaTypeRepository>();
kernel.Bind<IRepository<Ranking>>().To<RankingRepository>();
kernel.Bind<IRepository<Role>>().To<RoleRepository>();
kernel.Bind<IRepository<Sponsor>>().To<SponsorRepository>();
kernel.Bind<IRepository<State>>().To<StateRepository>();
kernel.Bind<IRepository<UserAccountInfo>>().To<UserAccountInfoRepository>();
kernel.Bind<IRepository<UserAction>>().To<UserActionRepository>();
kernel.Bind<IRepository<UserDeservesGoods>>().To<UserDeservesGoodsRepository>();
kernel.Bind<IRepository<UserGoods>>().To<UserGoodsRepository>();
kernel.Bind<IRepository<User>>().To<UserRepository>();
kernel.Bind<IUserService>().To<UserService>();
kernel.Bind<IAccountService>().To<AccountService>();
DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
}
here is my HomeController:
readonly IRepository<Ranking> repoRanking;
public HomeController(IRepository<Ranking> repoRanking)
{
this.repoRanking = repoRanking;
}
When I execute HomeController, I get follow exception:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Ninject.ActivationException: Error activating IRepository{Ranking}
No matching bindings are available, and the type is not self-bindable.
Activation path:
2) Injection of dependency IRepository{Ranking} into parameter repoRanking of constructor of type HomeController
1) Request for HomeController
Suggestions:
1) Ensure that you have defined a binding for IRepository{Ranking}.
2) If the binding was defined in a module, ensure that the module has been loaded into the kernel.
3) Ensure you have not accidentally created more than one kernel.
4) If you are using constructor arguments, ensure that the parameter name matches the constructors parameter name.
5) If you are using automatic module loading, ensure the search path and filters are correct.
What I doing wrong?
Have you created a default module where you set your bindings instead of in the register services method?
public class DefaultModule : NinjectModule {
public override void Load() {
Bind<IProductService>().To<ProductService>().InTransientScope();
}
}
and then in your Global.asax file do this:
protected override IKernel CreateKernel() {
var kernel = new StandardKernel();
kernel.Load(Assembly.GetExecutingAssembly());
return kernel;
}

The type ExceptionPolicyImpl has multiple constructors of length 2. Unable to disambiguate

I've a WCF service configured with Enterprise Library 5 "Logging Application Block", "Validation Application Block Integration with WCF" and "Exception Handling Application Block WCF Provider" and configured it using fluent API like this:
builder.ConfigureExceptionHandling()
// -----------------------------------------------------
// Preventing Enterprise Library Validation Block exceptions from getting shielded.
// -----------------------------------------------------
.GivenPolicyWithName("WCF Exception Shielding")
.ForExceptionType<FaultException<ValidationFault>>()
.ThenDoNothing()
// -----------------------------------------------------
// Shielding unhandled exceptions
// -----------------------------------------------------
.ForExceptionType<Exception>()
.LogToCategory("My Logging Category")
.WithSeverity(TraceEventType.Critical)
.ShieldExceptionForWcf(typeof(ServiceUnhandledFault), Resources.UnhandledException_ErrorMessage)
.ThenThrowNewException();
Service Implementation:
[ServiceContract]
[ValidationBehavior]
[ExceptionShielding("WCF Exception Shielding")]
public interface IMyService
{
[OperationContract]
[FaultContract(typeof(ValidationFault))]
[FaultContract(typeof(ServiceUnhandledFault))]
void InsertEntity(MyEntity file);
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall)]
public partial class MyService : IMyService { ...Implementation... }
If I set the "IncludeExceptionDetailInFaults" property of my service debug behavior to false and call a service operation with an entity that won't validate correctly the following exception will be thrown in the service:
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl", name = "WCF Exception Shielding".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type ExceptionPolicyImpl has multiple constructors of length 2. Unable to disambiguate.
But if I set the IncludeExceptionDetailInFaults to true a validation fault will be returned to the client.
Does anybody know what I'm missing?
Looks like you are trying to configure Ent Lib with Fluent API approach. I had similar error when I was trying configure Ent Lib with BOTH configuration files (web.config) and fluent api. If yes, you might try removing the config file variables and do only with fluent api. I found that this resolved the error for me.
Let me know how it goes.