Page 1 of 1

SFS2X Guava Version seems too Old for Google Pubsub

Posted: 01 Aug 2019, 08:31
by h128
Hi, we are trying to integrate Google Pubsub into our SFS2X game backend.

However, we find the following error, which implies that the Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object) method, provided by Guava and called by Pubsub library, can’t be found.

Code: Select all

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
at io.grpc.Metadata$Key.validateName(Metadata.java:628)
at io.grpc.Metadata$Key.<init>(Metadata.java:636)
at io.grpc.Metadata$Key.<init>(Metadata.java:566)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:740)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:735)
at io.grpc.Metadata$Key.of(Metadata.java:592)
at io.grpc.Metadata$Key.of(Metadata.java:588)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.<init>(GrpcHeaderInterceptor.java:61)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:173)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:162)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:149)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:157)
at com.google.cloud.pubsub.v1.stub.GrpcPublisherStub.create(GrpcPublisherStub.java:161)
at com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:154)
at com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:83)
at com.google.cloud.pubsub.v1.Publisher$Builder.build(Publisher.java:607)
at com.mydomain.myproject.lobby.pubsub.publisher.EventLogPublisher._createGcpPublisher(EventLogPublisher.java:86)
at com.mydomain.myproject.lobby.pubsub.publisher.EventLogPublisher.<init>(EventLogPublisher.java:40)
at com.mydomain.myproject.lobby.pubsub.publisher.EventLogPublisher.<clinit>(EventLogPublisher.java:29)
at com.mydomain.myproject.lobby.pubsub.template.EventLog.queueForPublish(EventLog.java:27)
at com.mydomain.myproject.lobby.utils.CCULogger.sampleCCU(CCULogger.java:51)
at com.mydomain.myproject.lobby.utils.CCULogger.init(CCULogger.java:27)
at com.mydomain.myproject.lobby.lobbyserver.LobbyServerMainExtensionDelegate.initManagers(LobbyServerMainExtensionDelegate.java:117)
at com.mydomain.myproject.lobby.lobbyserver.LobbyServerMainExtensionDelegate.startWorld(LobbyServerMainExtensionDelegate.java:78)
at com.mydomain.myproject.lobby.lobbyserver.LobbyServerMainExtensionDelegate.init(LobbyServerMainExtensionDelegate.java:61)
at com.mydomain.myproject.lobby.BaseZoneExtension.init(BaseZoneExtension.java:31)
at com.mydomain.myproject.lobby.lobbyserver.LobbyServerMainExtension.init(LobbyServerMainExtension.java:12)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:303)
at com.smartfoxserver.v2.entities.managers.SFSZoneManager.createZone(SFSZoneManager.java:426)
at com.smartfoxserver.v2.entities.managers.SFSZoneManager.initializeZones(SFSZoneManager.java:239)
at com.smartfoxserver.v2.SmartFoxServer.start(SmartFoxServer.java:297)
at com.smartfoxserver.v2.Main.main(Main.java:14)
After executing the following log command

Code: Select all

Class klass = Preconditions.class;
URL location = klass.getResource('/' + klass.getName().replace('.', '/') + ".class");
System.out.println(location);
We know that the Preconditions.class is located on

Code: Select all

jar:file:/opt/SmartFoxServer_2X/SFS2X/lib/guava-18.0.jar!/com/google/common/base/Preconditions.class
To further confirm this speculation, we had tried to manually replace the Jar of Guava in the SFS2X/lib, from guava-18.0.jar to gruava-28.0.jar.

And everything works.

However, considering changing the jar SFS2X depends on might cause unexpected trouble, we don’t tend to adopt such workaround.

We had also tried to downgrade the Pubsub library, but it seems that none of them can be adapted to Guava 18.0.

Any suggestion for this issue?

Thanks in advance!

Re: SFS2X Guava Version seems too Old for Google Pubsub

Posted: 01 Aug 2019, 10:59
by Lapo
Hi,
we don't have specific suggestions. If replacing the library solves the problem I think it's fine.
The SFS2X dependency on Guava is very light.

In any case I've added a note to check the latest Guava libraries and possibly add them to next release.

Cheers