Tag Archives: solution

Solve the problem that the native machine cannot use ant script checkout project

Problem Description: the local machine contains SVN command line. If svnsetting svnkit/javahl = true, there will be a conflict with the local SVN command line, resulting in the failure to check out items normally

solution: if both svnsetting svnkit and javahl are false, the program will automatically call native SVN in path.
example: & lt; svnsetting ID=“ svn.setting ” svnkit=”false” javahl=”false” username=”${svn_ user_ name}” password=”${svn_ user_ PWD} “/ &>
extension of the problem: if SVN command line is not installed on this machine, Download svnant and introduce svnkit/javahl jar package into ant/lib, svnkit/javahl corresponds to true

 

Java handles special characters in URL

The URL can’t display some special symbols, so the encoding will be used at this time. The encoding format is: a percent sign followed by the ASCII (hexadecimal) code value of the corresponding character. For example, the encoding value of a space is% 20. (ASCII reference)
some characters have special meanings in the URL, and the basic coding rules are as follows:
special meaning
hexadecimal value
1. + indicates empty space (spaces cannot be used in the URL)% 20
2/ Separate directory and subdirectory% 2F
3.?separate actual URL and parameter% 3F
4.% specify special character% 25
2 5. # indicates the separator% 26 between the parameters specified in the bookmark% 23
6. & amp; URL

For example: http://192.168.xxx.xxx/source/20190112 121000.txt

Note: such a URL cannot be successfully requested because the URL contains special words. The example URL contains special characters for spaces, so it needs to be converted to http://192.168.xxx.xxx/source/20190112%20121000.txt

Such a URL can request success.

Supplementary points:

Encoding and decoding functions of URL in Java java.net.URLEncoder . encode (string s) and java.net.URLDecoder . decode (string s);
URL encoding and decoding functions in JavaScript
escape (string s) and unescape (string s);
JavaScript

 

Kill Tomcat process in windows and Linux environment (solve the problem of other ports being occupied)

Killing process in Windows

1. First of all, find out the PID of the process number that occupies port 8080 ( tomcat, the default is port 8080. If you modify the monitoring port of tomcat, please write in your Tomcat port number or other port numbers ) what I query is port 7777

​netstat -ano | findstr 8080

The last column of the command output indicates the number of the process occupying port 7777, assuming 10976

2. Kill the process, thus freeing the port

taskkill /f /pid 10976 

 

 

Closing Tomcat process under Linux operating system

1. See if Tomcat is already running

ps -ef |grep tomcat 

If Tomcat is running, the result will be similar to the following:

sun 5144 1 0 10:21 pts/1 00:00:06 /java/jdk/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

-Djava.endorsed.dirs=/java/tomcat/common/endorsed -classpath :/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar

-Dcatalina.base=/java/tomcat -Dcatalina.home=/java/tomcat -Djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap start

From the above output information, we can know that the process number of Tomcat execution is 5144.

2. Execute the following command to kill the 5144 process

pid = 5144 kill -9 5144 

3. Get the occupancy of a certain port (for example, get the occupancy of port 5533 below)

sudo lsof -i :5533

The result is as follows: you can see that the process number is 2960, we just need to kill it.

COMMAND  PID        USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    2960 zhengcanrui   55u  IPv6 0xb866409b03202701      0t0  TCP *:5533 (LISTEN)

Kill process command:

kill -9 2960

The imported project “c:\Microsoft.Cpp.Default.props” was not found

npm is installed in this situation.

Theme:

Detection Method:

1, download Visual C++ 2015 Build Tools

Downloaded 38142142;: http://go.microsoft.com/fwlink/?LinkId=691126&_hstc=268264337.464d867a453cb3e0785b9f7f82b81bb9.1517626516073.1519263951770.1519269195452.4&_hssc=268264337.1.1519269195452&_hsfp=3527706607&fixForIE=.exe

2.download GTK, because you need to load some of it, download complete to C:\GTK immediately; download 3814214;(64 seconds): http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip

3. This is a very dependent step, inspiring cmd command, input set VCTargetsPath=C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \v4.0\v140;

net.sf.json .JSONObject maven20381;- 36182;

The last time you need to keep it, there are only two versions of jdk: json-lib-2.1-jdk13.jarand json-lib-2.1-jdk15.jar

: <   <dependency&>

: <� � � � � → <groupId&> net.sf.json -lib</groupId&>

: <     <artifactId&>json-lib</artifactId&>

: <     <version&>2.4</version&>

: <    <classifier&>jdk15</classifier&>

: <  </dependency&>

Solution of Java resources error reporting

These two items are very annoying when encountering this problem. Although they have no actual impact, programmers don’t like to see errors reported.
it’s generally good to make three changes

1. Change other versions to 3.0

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0"
 xmlns="http://java.sun.com/xml/ns/javaee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <display-name>Archetype Created Web Application</display-name>
</web-app>

2. Find the root directory of the project, an XML in the. Setting file, or change the version to 3.0

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="3.0"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.8"/>
  <installed facet="jst.jaxrs" version="2.0"/>
  <installed facet="jst.jsf" version="2.2"/>
</faceted-project>

3. Another possibility is to see the directory missing and build path, and then create a new directory

Solution of fileuriexposedexception for Android 7.0 behavior change

The source of this article is as follows http://blog.csdn.net/qq_ 27512671/article/details/71439571

When we develop functions related to [sharing files between applications], we often report this runtime exception on Android 7.0. Why do we run the code with no problem below Android 7.0 on Android 7.0 +?This is mainly from a behavior change in Android 7.0!

For Android 7.0-oriented applications, the strictmode API policy implemented by the Android framework prohibits the disclosure of file:// URI outside your application. If an intent containing a file URI leaves your application, the application fails and a fileuriexposedexception occurs. As shown in the figure:

To share files between applications, you should send a content:// URI and grant temporary access to the URI. The easiest way to do this is to use the fileprovider class.

Usage of fileprovider class:

Step 1: define a fileprovider list entry for your application. This entry can declare an XML file, which is used to specify the directory that the application can share.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
        ...>
        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.example.myapp.fileprovider"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>
        ...
    </application>
</manifest>

In this code, android:authorities Attribute should be unique. It is recommended to use [application package name + fileprovider]. It is recommended to write this android:authorities= ”${applicationId}.file_ The application package name can be found automatically.
The meta data tag specifies a path, which uses the XML file specified by resource to indicate the path:
the XML file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-files-path name="bga_upgrade_apk" path="upgrade_apk" />
</paths>

The way to obtain URI should also be treated differently according to the current Android system version

      File dir = getExternalFilesDir("user_icon");
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
            icon_path = FileProvider.getUriForFile(getApplicationContext(),
                    "com.mqt.android_headicon_cut.file_provider", new File(dir, TEMP_FILE_NAME));
        } else {
            icon_path = Uri.fromFile(new File(dir, TEMP_FILE_NAME));
        }

So the problem is solved. Paste an example of installing APK adapter 7.0: http://blog.csdn.net/qq_ 27512671/article/details/70224978


Reference:
1 https://developer.android.google.cn/about/versions/nougat/android-7.0-changes.html#accessibility
https://developer.android.google.cn/training/secure-file-sharing/setup-sharing.html#DefineProvider

java.lang.IllegalStateException Exception: cause analysis and solution

Today, I write a java file download program. After it’s finished, everything is normal, but it always throws out java.lang.IllegalStateException Abnormal, although it does not affect the normal use, but it always makes people feel very uncomfortable. There is nothing wrong with checking the code. Finally, I checked a lot of information on the Internet and finally found out the reason.

When we upload or download files, or filter files, we may need to use the output stream of the page.
for example, when we use it in action:
for example, when we use it in action response.reset ();
     response.setContentType (”application/ vnd.ms -excel”);
    OutputStream os = response.getOutputStream ();
throw an exception: java.lang.IllegalStateException

Cause analysis:
this is a problem in the servlet code generated by the web container out.write (), which is invoked in JSP. response.getOutputStream () conflicts.
that is, the servlet specification states that it cannot be called either response.getOutputStream (), and then call response.getWriter (), no matter which one is called first, an IllegalStateException will be thrown when calling the second one,

Because in JSP, the out variable is generated through the response.getWriter It is used in the program response.getOutputStream , and the out variable is used, so the above error occurs.

solve:

Method 1: add the following two sentences to the JSP file

<%
out.clear ();
out = pageContext.pushBody ();
%>

Defects of this method:
many development projects are not caused by JSP front-end, such as freemaker, velocity and so on“ response.getOutputStream () “not in JSP, but in servlet/action

Method 2: in action, do not return to the specific result file, return null
instead

//return SUCCESS;
return null;

Solution of server not running yetexception in HBase

I encountered a server not running yetexception error while working today. The symptom is that it is normal to enter HBase shell, but this error will be thrown when executing any instruction.

There is no error message when checking the log. At first I thought there was HBase process not up, but the JPS command showed that all started.

It’s a little tricky.. Because the test server was restarted a few days ago, and then I did some other work on it. So it is suspected that the problem is port occupancy.. However.. Neither..

I had no choice, so I moved out the ultimate solution: reloading Hadoop and HBase. After the official configuration is completed. HBase is miraculously good..

I once suspected that it was my configuration.. However.. Neither..

Finally found a solution on the Internet, because Hadoop is in a safe mode. So HBase operation will be abnormal. I’m not sure how it works. The solution is to manually exit safe mode

./hadoop dfsadmin -safemode leave 

Then restart HBase and solve the problem