Tag Archives: java

Kafka opens JMX port and reports that the error port is occupied

Kafka turns on JMX_ After port, when using Kafka command-line tools (Kafka topics, kafka-console-consumer.sh, etc.), an exception will be reported that the port is occupied, such as:

bash-5.1# /opt/kafka_2.13-2.7.0/bin/kafka-topics.sh --create --topic chat --partitions 5 --zookeeper 172.16.5.16:2181 --replication-factor 3
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
        java.net.BindException: Address in use (Bind failed)
sun.management.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
        java.net.BindException: Address in use (Bind failed)
        at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:480)
        at sun.management.Agent.startAgent(Agent.java:262)
        at sun.management.Agent.startAgent(Agent.java:452)
Caused by: java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
        java.net.BindException: Address in use (Bind failed)
        at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346)
        at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:254)
        at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412)
        at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
        at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:237)
        at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:213)
        at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:173)
        at sun.management.jmxremote.SingleEntryRegistry.<init>(SingleEntryRegistry.java:49)
        at sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:816)
        at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:468)
        ... 2 more
Caused by: java.net.BindException: Address in use (Bind failed)
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.ServerSocket.bind(ServerSocket.java:392)
        at java.net.ServerSocket.<init>(ServerSocket.java:254)
        at java.net.ServerSocket.<init>(ServerSocket.java:145)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:45)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:345)
        at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670)
        at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335)
        ... 11 more

terms of settlement:

Modify the bin/kafka-run-class.sh file:

Find this code

if [  $JMX_PORT ]; then
  KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
fi

Replace with the following:

ISKAFKASERVER="false"
if [[ "$*" =~ "kafka.Kafka" ]]; then
    ISKAFKASERVER="true"
fi
if [  $JMX_PORT ] && [ -z "$ISKAFKASERVER" ]; then
  KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
fi

Then create topic and solve the problem.

bash-5.1#
bash-5.1# /opt/kafka_2.13-2.7.0/bin/kafka-topics.sh --create --topic chat --partitions 5 --zookeeper 172.16.5.16:2181 --replication-factor 3
Created topic chat.
bash-5.1#

The java.lang.exceptionininitializererror of mybatis reports an error

1. First, look at mybatis-config.xml

<mapper resource="com/kuang/dao/TeacherMapper.xml"/>

Be sure to follow the student mapper above. The directory where XML is stored is right

2. Look at mapper.xml

<mapper namespace="com.kuang.dao.StudentMapper">

Be sure to match the directory stored in the student mapper above

3. If there is Chinese in the comments, check whether UTF-8 in the two XML is changed to uft8

<?xml version="1.0" encoding="UTF8" ?>

4. Maven resource export problem

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>
</build>

5. Check whether mapper and mapper.xml are in the same directory under the target directory, and then check whether there are any extra or duplicate. If so, delete those that do not correspond to the SRC directory above.

Summary:

The directories of SRC, test and target should be consistent!!!

Idea starts Tomcat console with garbled code but no error

Problem display

resolvent

1. Find the Tomcat installation directory  

  2. Open the logging.properties file from the conf folder
find the line java.util.logging.consolehandler.encoding = UTF-8 and change it to java.util.logging.consolehandler.encoding = GBK
that is, change the console code from UTF-8 to GBK

  Successful solution, give a praise

Android studio reports an error when building AAR for unity

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Java\jdk1.8.0_191\bin\java.exe -classpath "C:\Program Files\Unity Hub\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"

stderr[

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class bitter.jnibridge.JNIBridge found in modules opsdk-debug-runtime.jar (:opsdk-debug:) and unity-classes.jar (unity-classes.jar)
  Duplicate class bitter.jnibridge.JNIBridge$a found in modules opsdk-debug-runtime.jar (:opsdk-debug:) and unity-classes.jar (unity-classes.jar)
  Duplicate class com.unity3d.player.GoogleARCoreApi found in modules opsdk-debug-runtime.jar (:opsdk-debug:) and unity-classes.jar (unity-classes.jar)

NoClassDefFoundError: io/ebean/bean/ EntityBean [How to Solve]

Error stack frame, as follows:

java.lang.NoClassDefFoundError: io/ebean/bean/EntityBean

	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
	at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
	at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:108)
	at java.lang.Class.getGenericInterfaces(Class.java:913)
	at org.springframework.core.ResolvableType.getInterfaces(ResolvableType.java:471)
	at org.springframework.core.GenericTypeResolver.buildTypeVariableMap(GenericTypeResolver.java:265)
	at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:242)
	at org.springframework.data.util.ClassTypeInformation.getTypeVariableMap(ClassTypeInformation.java:114)
	at org.springframework.data.util.ClassTypeInformation.getTypeVariableMap(ClassTypeInformation.java:103)
	at org.springframework.data.util.ClassTypeInformation.<init>(ClassTypeInformation.java:92)
	at org.springframework.data.util.ClassTypeInformation.lambda$from$1(ClassTypeInformation.java:70)
	at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324)
	at org.springframework.data.util.ClassTypeInformation.from(ClassTypeInformation.java:70)
	at org.springframework.data.repository.core.support.AbstractRepositoryMetadata.<init>(AbstractRepositoryMetadata.java:58)
	at org.springframework.data.repository.core.support.DefaultRepositoryMetadata.<init>(DefaultRepositoryMetadata.java:52)
	at org.springframework.data.repository.core.support.AbstractRepositoryMetadata.getMetadata(AbstractRepositoryMetadata.java:73)
	at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.getRepositoryConfigurations(RepositoryConfigurationExtensionSupport.java:98)
	at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:121)
	at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:60)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:358)
	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:357)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:145)
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
	at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:139)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
	at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
	at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.ClassNotFoundException: io.ebean.bean.EntityBean
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 78 more



The solution is to replace the idea entitybean enhancement plug-in. My computer is replaced with entitybean 10. X enhancement

Easyexcel Llinux reports an error, but the local error is correct

terms of settlement:

    on the command line, enter
    Yum install fontconfig to add a sentence in the dockerfile (just add it in the line before entrypoint)
    Run APK add -- update font-adobe-100dpi TTF dejavu fontconfig restart or rebuild

    Reason:
    the openjdk used in the docker container is different from the local JDK, so the null pointer error of the font will be reported. If the font is useful, you can try it

Java connection zookeeper high availability hive error

Today, when using java to connect zookeeper high availability hive, errors are reported:

java.lang.NullPointerException

at org.apache.thrift.transport.TSocket.open(TSocket.java:209)

 

 

My current Hadoop and hive versions are as follows:

< hadoop.version> 2.6.0-cdh5.5.2
< hive.version> 1.1.0-cdh5.16.2

At this time, I use the old connection string to connect without error:

“jdbc:hive2://marshal:10000”;

However, if a new connection string is used to connect, an error is reported:

“jdbc:hive2://marshal:2181,marshal01:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2_zk”;

  After some experiments, the final solution is to make the hive version a little higher than the Hadoop version

< hadoop.version> 2.6.0-cdh5.5.2
< hive.version> 1.1.0-cdh5.6.0

There will be no error at this time

Using JSTL to traverse the list set reports an error

Use JSTL to report an error when traversing the list set

javax.el.PropertyNotFoundException: Property [department] not found on type [com.studying.model.Employee]

However, the Department attribute in the data transmitted from the back end has a value

Error reason

After careful search, it is found that the set/get method of attribute Department has been forgotten in the employee class

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

Mac idea springboot project reported an error

Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_ 144.jdk/Contents/Home/bin/java (0x10dd324c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_ 144.jdk/contents/home/jre/lib/libinstrument.dylib error

To solve the problem, you need to set the idea custom properties. Click Help on the navigation bar and select Edit custom properties,

For the first time, there is no properties file. At this time, the following interface will pop up in idea to prompt you to create it. Click Create directly.

Write idea. No. launcher = true in idea.properties, and then restart idea.

JMeter running error response code: non HTTP response code: java.lang.illegalargumentexception find and solve

JMeter operation error

Response code: non HTTP response code: java.lang.illegalargumentexception
response message: non HTTP response message: bound must be greater than origin


the error is due to the problem of parameter transmission. First, we need to check whether the parameter is correct


after checking, we find that the name is wrong, The case is not distinguished, so it can’t be found all the time. It’s successful to run after modification.