Category Archives: JAVA

Java calls sqlldr and reports an error: Message 2100 not found

Java calls the sqlldr command of Oracle and reports an error: Message 2100 not found; No message file for product=RDBMS, facility=ULMessage 2100 not found; No message file for product=RDBMS, facility=UL

Manually executing sqlldr can be executed normally, but if it is placed in Java, the above 2100 error will be reported

I’ve been looking for mistakes for two days

Hope to help and record this problem

Sort out the solutions (two kinds) here (first say your own, and then summarize what Baidu has found)

1. Let’s talk about my problems first

Let’s start with the conclusion: you can execute sqlldr manually, but you need to set environment variables in Java( I don’t know much about Java. At least the problem will be solved after I set it like this.)

The line of runtime. Getruntime(). Exec (CMD) found on the Internet can execute sqlldr. The method is correct, but it seems that it has not been written, and the environment variable needs to be set

 

String[] cmd = { "/bin/bash", "-c", "echo $ORACLE_HOME;echo $LD_LIBRARY_PATH;$ORACLE_HOME/bin/" + shellCommand };

final Process pid = Runtime.getRuntime().exec(cmd,new String[] { "ORACLE_HOME=/oracle/app/oracle/product/11.2.0.4/dbhome/",
            "LD_LIBRARY_PATH=/usr/local/lib:/oracle/app/oracle/product/11.2.0.4/dbhome/lib:$LD_LIBRARY_PATH" });
            Process pid = Runtime.getRuntime().exec(cmd
            System.out.println("Process pid" + pid);
            bufferedReader = new BufferedReader(new InputStreamReader(pid.getErrorStream()), 1024);

Just add these lines

The full code is as follows:

public static int executeShellsetHome(String shellCommand) {
        int success = -1;
        BufferedReader bufferedReader = null;
        String[] cmd = { "/bin/bash", "-c", "echo $ORACLE_HOME;echo $LD_LIBRARY_PATH;$ORACLE_HOME/bin/" + shellCommand };
        try {
            System.out.println("run  executeShellsetHome");
            final Process pid = Runtime.getRuntime().exec(cmd,new String[] { "ORACLE_HOME=/oracle/app/oracle/product/11.2.0.4/dbhome/",
            "LD_LIBRARY_PATH=/usr/local/lib:/oracle/app/oracle/product/11.2.0.4/dbhome/lib:$LD_LIBRARY_PATH" });
            Process pid = Runtime.getRuntime().exec(cmd
            System.out.println("Process pid" + pid);
            bufferedReader = new BufferedReader(new InputStreamReader(pid.getErrorStream()), 1024);
            pid.waitFor();
            success = pid.exitValue();
            if(0==success){
                System.out.println("sqlldr success");
            }
            else  {
                String line = null;
                String errorMsg = "";
                while (bufferedReader != null && (line = bufferedReader.readLine()) != null) {
                    errorMsg += line;
                }
                throw new Exception("run" + shellCommand + "error" + errorMsg);
            }
            

        } catch (Exception ioe) {
            ioe.printStackTrace();
            System.out.println("Exception");
        } finally {
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            
        }
        return success;
    }

 

2. The remaining issues are related to permissions

$ORACLE_Permissions for home/RDBMS/MESG/oraus.msg and oraus.msb   ( It is also said that only one permission of oraus.msb needs to be changed (specific self-test is required)

It is also possible to put these two files in the upper directory, that is, $oracle_Home/RDBMS/and give sufficient permissions

If there is any mistake, please help correct it and discuss it together if there is a problem

LoadRunner Java is missing the necessary import package and reports an error

loadrunner runs the script from eclipse, ctrl + A copies it to loadrunner, and

Add the parameterised statement: verifyCode = lr.eval_string (“<rand6>”);

Report an error:

Notify: Found jdk version: 1.6.0. [MsgId: MMSG-22986]
Notify: classpath=E:\performanceTest\3-test\lr_hibox_script\;c:\program files (x86)\hp\loadrunner\classes\srv;c:\program files (x86)\hp\loadrunner\classes;.;C:\Program Files (x86)\Java\jdk1.6.0_45\lib\tools.jar;C:\Program Files (x86)\Java\jdk1.6.0_45\lib\dt.jar;E:\performanceTest\jar\fastjson-1.1.37.jar;E:\performanceTest\jar\hibox_for_lr.jar;E:\performanceTest\jar\protobuf-java-2.5.0.jar;;;;c:\program files (x86)\hp\loadrunner\lib\xstream-1.3.jar;c:\program files (x86)\hp\loadrunner\lib\xpp3-1.1.4c.jar [MsgId: MMSG-22986]
Error: Compilation process failed. [MsgId: MERR-22997]
Warning: Extension java_int.dll reports error -1 on call to function ExtPerProcessInitialize [MsgId: MWAR-10485]
Error: Thread Context: Call to service of the driver failed, reason – thread context wasn’t initialized on this thread. [MsgId: MERR-10176]

 

It turns out that it was copied over, causing the original statement import lrapi.lr; to be overwritten and the missing statement to report an error, add this statement to the top of the script and it will run fine

[How to Solve] Caused by: java.net.SocketTimeoutException: connect timed out

An error was encountered during deployment, as follows:

java.net.SocketTimeoutException: connect timed out
    at redis.clients.jedis.Connection.connect(Connection.java:)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:)
    at redis.clients.jedis.BinaryClient.multi(BinaryClient.java:)
    at redis.clients.jedis.BinaryJedis.multi(BinaryJedis.java:)
    at cn.edu.aynu.redis.TestTx.main(TestTx.java:)
Caused by: java.net.SocketTimeoutException: connect timed out
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:)
    at java.net.Socket.connect(Socket.java:)
    at redis.clients.jedis.Connection.connect(Connection.java:)
    ... more

This is actually a redis connection error, not a database connection error, the database connection error is this: jdbc connection refused

There are many specific reasons, such as: wrong ip, port not open, ip cannot be pinged and not allowed to access, etc.

I am here because the server ip cannot be pinged, it can be solved by releasing it in the security group.

Sudo starts Tomcat and reports an error. There is no Java environment

 Error:

Cannot find ./catalina.sh
The file is absent or does not have execute permission
This file is needed to run this program

Cause.

No executable permissions were granted to the files in the bin directory.

Solution:

chmod +x bin/*.sh

The error Neither the JAVA_HOME nor the JRE_HOME environment variable is defined.
The solution is as follows.

tomcat startup script file: startup.sh, startup.sh will load catalina.sh , catalina.sh will load setclasspath.sh

Linux: export JAVA_HOME=absolute path Windows: set

You can add directly to the second line.

#!/bin/sh
export JAVA_HOME=/usr/local/java1.8
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the “License”); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at

success

[root@hadoop1 apache-tomcat-8.0.43]# sudo  bin/startup.sh
/home/report/apache-tomcat-8.0.43/bin/catalina.sh:行143: -Xmx1024m: 未找到命令
Using CATALINA_BASE: /home/report/apache-tomcat-8.0.43
Using CATALINA_HOME: /home/report/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /home/report/apache-tomcat-8.0.43/temp
Using JRE_HOME: /home/jdk-10.0.1
Using CLASSPATH: /home/report/apache-tomcat-8.0.43/bin/bootstrap.jar:/home/report/apache-tomcat-8.0.43/bin/tomcat-juli.jar
Tomcat started.

The above was added to the catalina.sh file. There is still the problem that the shutdown command runs with an error shutdown.sh

[root@hadoop1 apache-tomcat-8.0.43]# sudo bin/shutdown.sh

/home/report/apache-tomcat-8.0.43/bin/catalina.sh: line 143: -Xmx1024m: Cannot find commands
Using CATALINA_BASE: /home/report/apache-tomcat-8.0.43
Using CATALINA_HOME: /home/report/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /home/report/apache-tomcat-8.0.43/temp
Using JRE_HOME: /home/jdk-10.0.1
Using CLASSPATH: /home/report/apache-tomcat-8.0.43/bin/bootstrap.jar:/home/report/apache-tomcat-8.0.43/bin/tomcat-juli.jar

./catalina.sh: 1: eval: usrjjdk-10.0.1re/bin/java: not found

It still says not found, and the path usrjdk-10.0.1jre is somehow missing the ‘/’.

Workaround.

rewrite the export JAVA_HOME environment variable you just modified to setclasspath.sh and remove the catalina.sh export one

Successfully solved:

[root@hadoop1 apache-tomcat-8.0.43]# sudo  bin/shutdown.sh
/home/report/apache-tomcat-8.0.43/bin/catalina.sh:行143: -Xmx1024m: 未找到命令
Using CATALINA_BASE: /home/report/apache-tomcat-8.0.43
Using CATALINA_HOME: /home/report/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /home/report/apache-tomcat-8.0.43/temp
Using JRE_HOME: /home/jdk-10.0.1
Using CLASSPATH: /home/report/apache-tomcat-8.0.43/bin/bootstrap.jar:/home/report/apache-tomcat-8.0.43/bin/tomcat-juli.jar

 

 

IDEA error: javax/xml/bind/DatatypeConverter [How to Solve]

Error in idea javax/XML/bind/datatypeconverter

java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

Solution:

Import required  javax.xml.bind.jar     Just download an import

The real solution: java.lang.noclassdeffounderror: javax/XML/bind/datatypeconverter

 

This error occurred when using hibernate in the JDK 12.0 environment today. The error log is as follows:
! [] ()
cause of failure:

JAXB API is the API of Java EE, so this jar package is no longer included in Java se 9.0
the concept of module is introduced in Java 9. By default, the jar package of Java EE will no longer be included in Java se
but this API is bundled in Java 6/7/8

solution 1:

Reduce JDK version to JDK 8

solution 2: (pro test feasible)

Manually add these dependent jar packages

<dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>

[Solved] Java.nio.file.AccessDeniedException is reported when moving excel files in Tomcat project

The company has a requirement to read excel on a regular basis to obtain the BOM structure. After reading it, the excel file needs to be moved to another folder.

1. When using the Files.move(source, target, options) method, the error is reported as follows
java.nio.file.AccessDeniedException: D:\DBdate\MID\DOC\PT038\20210726\CXDA-20016-0010 pack-410x180x180.xlsx -> D:\DBdate\MID\DOC\readedexcel\CXDA-20016-0010 pack-410x180x180.xlsx
It should be caused by Tomcat not having file delete permissions

2. Solution: Set the Tomcat service to log in with the local system account

JAVA: How to Solve @override error

Sometimes, when the MyEclipse project of Java is compiled on another computer, the @override always reports an error. Just remove the @override, but it can not fundamentally solve the problem, because sometimes there are too many @override places

[size=18.0180187225342px]        This is a problem with the JDK itself, @override is already available in jdk5, but it does not support the implementation of the interface, that is, when using @override, its parent class must be a class, not an interface, otherwise an error will be reported. JDK6 has corrected this bug, and @override can be added to both the method override of the parent class and the implementation of the interface

[size=18.0180187225342px]        To solve this problem, first ensure that JDK 1.6 is installed on the machine, and then select the MyEclipse menu windows – > Preferences–> java-> Compiler–> Compiler compliance level select 1.6, refresh the project and recompile

[size=18.0180187225342px]          If the problem has not been solved, right-click on the error reporting project and select properties — > Java Compiler–> Select 1.6 from compiler compliance level, refresh the project and recompile

 

How to Solve JAVA @override error

Today, when copying the eclipse project to another computer, there are always @override errors. The prompt is to remove @override. However, there are many annotations in the project. Java Xiaobai thinks that even if I don’t know the difference between the existence and non existence of this preparation, it must be useful since it exists, In addition, @override exists in many places in the project, so you can’t remove it all. I checked it and summarized it

Error reason:

At first, I thought it was a jar package reference problem. I tried to change the jar package, but it was useless. Only then did I know it was a JDK problem. @ override already existed when it was jdk5, but it did not support the implementation of the interface. I thought it was not an override and reported an error. JDK6 has corrected this bug, and @ override can be added to both the method override of the parent class and the implementation of the interface. To solve this problem, first make sure that JDK 1.6 is installed on the machine (in fact, I’m not sure about this problem here, because I only have version 1.8 on my computer, but there is no 1.8 in the selection, so I chose 1.6 according to the tutorial)

First, method 1: (I tried it in my project, but it’s useless)

 

Select the eclipse menu windows – > Preferences–> java-> Compiler–> Compiler compliance level select 1.6, refresh the project and recompile

Method 2: (problem solving)

Right click on the error reporting project and select properties — > Java Compiler–> Select 1.6 from compiler compliance level, refresh the project and recompile

Extension: Java   Override @ override annotation in   A little understanding of writing and not writing

Generally speaking, there is no difference between writing and not writing, and the JVM can recognize itself

In the case of writing: that is to say, the subclass must override the method of the base class, and the base class must have a method

(The control type (public, protected, return value, parameter list type) is consistent with the method completed by the subclass method, otherwise an error will be reported (the overridden method cannot be found).

When the @override annotation is not written, when the base class exists and all conditions of the subclass meet, the method is to implement the override;   If the conditions are not met, it is used as a newly defined method.

Therefore, if you want to override the base class method, you’d better write the @ override annotation, which is helpful for the compiler to help check for errors

[Solved] IDEA Warning: Information:javac 1.8.0_251 was used to compile java sources

Idea prompts Information: javac 1.8.0_251 was used to compile java sources error

 

 

 

This problem occurred after re-building a maven project. When writing a maven project before, I used the Lambda syntax after jdk8 and there was no error, but don’t panic.

Solution:

The focus is:
File -> Project Structure -> Project Settings
File -> Project Structure -> Module Settings -> Tab: Sources: Language Level
File -> Project Structure -> Module Settings -> Tab: Dependencies: Module SDK
File -> Settings -> Compiler -> Java Compiler -> Target bytecode version
The four versions must be the same

IDEA Error: java: Invalid source release: 11 error [How to Solve]

Today, I created a new springboot, and it failed when I started the project.

Error: java: invalid source release: 11 error

It may be that when creating springboot, you did not pay attention to directly selecting the 11 version. At this time, you need to modify the jdk version. Because the project has already started, I need to modify the java version of my project here.
The file—setting—build, execution, deployment—compiler—java compiler in the menu bar, I have 11

Change them to 8 and click apply because my version here is java 1.8

In addition, in some cases, you need to modify the configuration of the project settings (open the shortcut key ctrl+shift+alt+s), and then modify it to your own version if it is wrong:

 

 

 

 

The above is the solution to the Error:java: invalid source release: 11 error.