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

In netty-4.1.28.Final version, an error occurs when running on jdk6. #8166

Closed
koo-taejin opened this issue Aug 2, 2018 · 1 comment
Closed
Assignees
Milestone

Comments

@koo-taejin
Copy link

Actual behavior

io.netty.channel.ChannelException: Unable to create Channel from class class io.netty.channel.socket.nio.NioSocketChannel
Caused by: java.lang.NoClassDefFoundError: java/nio/channels/NetworkChannel
	at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:105)
	at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:94)
	at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:87)
	at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:80)
	... 32 more
Caused by: java.lang.ClassNotFoundException: java.nio.channels.NetworkChannel
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Steps to reproduce

// run following test on jvm6

    @Test
    public void listenerTest() throws Exception {
        Bootstrap bootstrap = createBootstrap();
        Channel channel = bootstrap.connect(host, port).sync().channel();

    }

    public Bootstrap createBootstrap() {
        EventLoopGroup workerGroup = new NioEventLoopGroup();
        Bootstrap bootstrap = new Bootstrap();
        bootstrap.group(workerGroup).channel(NioSocketChannel.class)
                .handler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    protected void initChannel(SocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new HttpClientCodec());
                        ch.pipeline().addLast(new HttpObjectAggregator(65535));
                    }
                });
        return bootstrap;
    }

Netty version

netty-4.1.28.Final

JVM version (e.g. java -version)

1.6.0_45

OS version (e.g. uname -a)

Windows10, CentOS 6.6

I think this issue is problem, but I'm not sure.
If this issue is problem, May I make a correction?

koo-taejin added a commit to koo-taejin/netty that referenced this issue Aug 2, 2018
description
Fixed problem loading class included in java7+ when using java6
normanmaurer added a commit that referenced this issue Aug 2, 2018
Motivation:

952eeb8 introduced the possibility to use any JDK SocketOption when using the NIO transport but broke the possibility to use netty with java6.

Modifications:

Do not use java7 types in method signatures of the static methods in NioChannelOption to prevent class-loader issues on java6.

Result:

Fixes #8166.
@normanmaurer
Copy link
Member

@koo-taejin PTAL #8168

@normanmaurer normanmaurer self-assigned this Aug 2, 2018
normanmaurer added a commit that referenced this issue Aug 2, 2018
Motivation:

952eeb8 introduced the possibility to use any JDK SocketOption when using the NIO transport but broke the possibility to use netty with java6.

Modifications:

Do not use java7 types in method signatures of the static methods in NioChannelOption to prevent class-loader issues on java6.

Result:

Fixes #8166.
normanmaurer added a commit that referenced this issue Aug 3, 2018
Motivation:

952eeb8 introduced the possibility to use any JDK SocketOption when using the NIO transport but broke the possibility to use netty with java6.

Modifications:

Do not use java7 types in method signatures of the static methods in NioChannelOption to prevent class-loader issues on java6.

Result:

Fixes #8166.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants