Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer #11789

Closed
hangc0276 opened this issue Aug 26, 2021 · 10 comments · Fixed by #11790
Closed

java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer #11789

hangc0276 opened this issue Aug 26, 2021 · 10 comments · Fixed by #11790
Assignees
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@hangc0276
Copy link
Contributor

hangc0276 commented Aug 26, 2021

Describe the bug
When create a function, the server side throws NosuchMethodError exception

Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
        at io.airlift.compress.lz4.Lz4Compressor.compress(Lz4Compressor.java:100) ~[io.airlift-aircompressor-0.19.jar:0.19]
        at org.apache.pulsar.common.compression.CompressionCodecLZ4.encode(CompressionCodecLZ4.java:78) ~[org.apache.pulsar-pulsar-common-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.client.impl.ProducerImpl.applyCompression(ProducerImpl.java:376) ~[org.apache.pulsar-pulsar-client-original-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.client.impl.ProducerImpl.sendAsync(ProducerImpl.java:403) ~[org.apache.pulsar-pulsar-client-original-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.client.impl.ProducerImpl.internalSendAsync(ProducerImpl.java:292) ~[org.apache.pulsar-pulsar-client-original-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.client.impl.TypedMessageBuilderImpl.sendAsync(TypedMessageBuilderImpl.java:103) ~[org.apache.pulsar-pulsar-client-original-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.client.impl.TypedMessageBuilderImpl.send(TypedMessageBuilderImpl.java:82) ~[org.apache.pulsar-pulsar-client-original-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.functions.worker.FunctionMetaDataManager.updateFunctionOnLeader(FunctionMetaDataManager.java:241) ~[org.apache.pulsar-pulsar-functions-worker-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.functions.worker.rest.api.ComponentImpl.internalProcessFunctionRequest(ComponentImpl.java:1578) ~[org.apache.pulsar-pulsar-functions-worker-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.functions.worker.rest.api.ComponentImpl.updateRequest(ComponentImpl.java:887) ~[org.apache.pulsar-pulsar-functions-worker-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.functions.worker.rest.api.FunctionsImpl.registerFunction(FunctionsImpl.java:238) ~[org.apache.pulsar-pulsar-functions-worker-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at org.apache.pulsar.broker.admin.impl.FunctionsBase.registerFunction(FunctionsBase.java:183) ~[org.apache.pulsar-pulsar-broker-2.9.0-SNAPSHOT.jar:2.9.0-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_291]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_291]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_291]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_291]
        at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255) ~[org.glassfish.jersey.core-jersey-server-2.34.jar:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[org.glassfish.jersey.core-jersey-common-2.34.jar:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[org.glassfish.jersey.core-jersey-common-2.34.jar:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[org.glassfish.jersey.core-jersey-common-2.34.jar:?]

To Reproduce
Steps to reproduce the behavior:

$ bin/pulsar standalone
$ bin/pulsar-admin tenants create test
$ bin/pulsar-admin namespaces create test/test-namespace
$ bin/pulsar-admin functions create --function-config-file examples/example-function-config.yaml --jar examples/api-examples.jar

Expected behavior
Created Successfully

Desktop (please complete the following information):

  • OS: [e.g. iOS]

Additional context
Add any other context about the problem here.

@nlu90
Copy link
Member

nlu90 commented Aug 26, 2021

Please try to run the function with java 11.

I tested with master branch on java 11, the function runs fine.

➜  sn-pulsar git:(master) ✗ java -version
java version "11.0.11" 2021-04-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)
➜  sn-pulsar git:(master) ./bin/pulsar-admin functions create --jar ./pulsar-functions/java-examples/target/pulsar-functions-api-examples.jar --classname org.apache.pulsar.functions.api.examples.ExclamationFunction --inputs persistent://public/default/my-topic --name exclamation --tenant public --namespace default --output persistent://public/default/output
"Created successfully"
➜  sn-pulsar git:(master) ✗ ./bin/pulsar-client produce -m "$i. hello" public/default/my-topic
...
22:15:26.993 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully produced
➜  sn-pulsar git:(master) ✗ ./bin/pulsar-client consume -n 0 -s tttt public/default/output
...
----- got message -----
key:[null], properties:[__pfn_input_msg_id__=CPoMEAAgADAB, __pfn_input_topic__=persistent://public/default/my-topic], content:. hello!
...

@liangyuanpeng
Copy link
Contributor

liangyuanpeng commented Aug 26, 2021

Please try to run the function with java 11.

I tested with master branch on java 11, the function runs fine.

Thanks for your work and i think it should be work for java8, not java11 only, right?

@hangc0276
Copy link
Contributor Author

Yes, i build and run with java8

 hangc@MacBook-Pro-2  ~/Workspace/release/pulsar-2.8.1  java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

 hangc@MacBook-Pro-2  ~/Workspace/release/pulsar-2.8.1  mvn -v
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: /Users/hangc/Cloud/apache-maven-3.6.2
Java version: 1.8.0_291, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/jre
Default locale: en_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

@hangc0276
Copy link
Contributor Author

hangc0276 commented Aug 26, 2021

Please try to run the function with java 11.
I tested with master branch on java 11, the function runs fine.

Thanks for your work and i think it should be work for java8, not java11 only, right?

I agree with you. When user run pulsar function with java8, it will fail. @nlu90

@eolivelli
Copy link
Contributor

Arw you using latest master?
@codelipenghui fixed this problem recently

@hangc0276
Copy link
Contributor Author

Arw you using latest master?
@codelipenghui fixed this problem recently

@eolivelli Yes, I build from the latest master. build and run with java8

@eolivelli
Copy link
Contributor

I refer to this patch
#11594

@eolivelli
Copy link
Contributor

it is in a different code path.

The correct fix is to upgrade Airlift or to downgrade it

@eolivelli
Copy link
Contributor

@hangc0276
Copy link
Contributor Author

@eolivelli Ok, i upgrade the aircompressor to 0.20, it works, thank you very much. It push a PR #11790, PTAL.

hangc0276 added a commit that referenced this issue Aug 26, 2021
Fix #11789

### Modification
upgrade aircompressor from 0.19 to 0.20
hangc0276 added a commit that referenced this issue Aug 26, 2021
Fix #11789

### Modification
upgrade aircompressor from 0.19 to 0.20

(cherry picked from commit 051f52d)
@hangc0276 hangc0276 self-assigned this Aug 26, 2021
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this issue Mar 18, 2022
Fix apache#11789

### Modification
upgrade aircompressor from 0.19 to 0.20
Jason918 pushed a commit that referenced this issue Jul 28, 2022
Fix #11789

upgrade aircompressor from 0.19 to 0.20

(cherry picked from commit 051f52d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants