Tag Archives: IDEA

[Solved] IDEA: JSP Could Not Use session Build-in Object

Problem description

Cause

since the author uses Tomcat 10, the servlet dependency used is Jakarta Servlet. For details, see building a servlet using Tomcat 10. An error is reported: class XXX is not a servlet. The error is because the servlet API package is not imported.

Solution:

Import servlet API dependencies.

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
</dependency>

[Solved] idea Remote Submit spark Error: java.io.IOException: Failed to connect to DESKTOP-H

Idea remotely submits spark job Java io. IOException: Failed to connect to DESKTOP-H

1. Error report log

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1713)
	at org.apache.spark.deploy.SparkHadoopUtil.runAsSparkUser(SparkHadoopUtil.scala:63)
	at org.apache.spark.executor.CoarseGrainedExecutorBackend$.run(CoarseGrainedExecutorBackend.scala:188)
	at org.apache.spark.executor.CoarseGrainedExecutorBackend$.main(CoarseGrainedExecutorBackend.scala:293)
	at org.apache.spark.executor.CoarseGrainedExecutorBackend.main(CoarseGrainedExecutorBackend.scala)
Caused by: org.apache.spark.SparkException: Exception thrown in awaitResult: 
	at org.apache.spark.util.ThreadUtils$.awaitResult(ThreadUtils.scala:205)
	at org.apache.spark.rpc.RpcTimeout.awaitResult(RpcTimeout.scala:75)
	at org.apache.spark.rpc.RpcEnv.setupEndpointRefByURI(RpcEnv.scala:101)
	at org.apache.spark.executor.CoarseGrainedExecutorBackend$$anonfun$run$1.apply$mcV$sp(CoarseGrainedExecutorBackend.scala:201)
	at org.apache.spark.deploy.SparkHadoopUtil$$anon$2.run(SparkHadoopUtil.scala:64)
	at org.apache.spark.deploy.SparkHadoopUtil$$anon$2.run(SparkHadoopUtil.scala:63)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
	... 4 more
Caused by: java.io.IOException: Failed to connect to DESKTOP-HSVM
	at org.apache.spark.network.client.TransportClientFactory.createClient(TransportClientFactory.java:245)
	at org.apache.spark.network.client.TransportClientFactory.createClient(TransportClientFactory.java:187)
	at org.apache.spark.rpc.netty.NettyRpcEnv.createClient(NettyRpcEnv.scala:198)
	at org.apache.spark.rpc.netty.Outbox$$anon$1.call(Outbox.scala:194)
	at org.apache.spark.rpc.netty.Outbox$$anon$1.call(Outbox.scala:190)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: 拒绝连接: DESKTOP-HSVM
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
	at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:323)
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:633)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
	... 1 more
Caused by: java.net.ConnectException: denied to connect
	... 11 more

2. cause analysis

Idea cannot establish a connection with the local machine while submitting spark jobs to the remote cluster and returning the results to the local machine.

Caused by: java.io.IOException: Failed to connect to DESKTOP-HSVM

3. solution

Add the native name desktop-hsvm and IP to the/etc/hosts file of the remote cluster, as shown in the following figure

[Solved] IDEA Startup Error: Cound not Find or Load the main class

Problem Description: because computer is so laggy, after restarting, it opens the project. It finds that the function before is unable to use, and the wrong report: unable to find or unable to load the main class. Mainly clear the cache: use file → invalidate caches/restart, Select invalidate to clear the cache.

Solution:

1. Because I knew that the module name could not be started after changing the module name, I guess it caused the compilation problem, so try to rebuild, use Build→Rebuild Project.

But the problem has not been solved yet, and it is suspected to be a caching problem.

2. Use File→Invalidate Caches/Restart…, select Invalidate, and clear the cache.

 

3. Use File→Project Structure, select Modules on the left, click the minus sign to remove the problematic module, and then click the plus sign to re-import the module.

 

4. Restart the module and find the problem solved.

[Solved] IDEA javaweb web.xml File Error: Invalid content was found starting with element

Error reporting site restore

The header of the web.xml file is declared as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

The servlet elements reporting errors are as follows:

<servlet>
    <description>Enter Dispatcher</description>
    <servlet-name>xxxMVC</servlet-name>
    <servlet-class>com.xxx.web.servlet.RequestDispatcher</servlet-class>
    <load-on-startup>1</load-on-startup>
    <init-param>
        <param-name>xxxName</param-name>
        <param-value>xxxValue</param-value>
    </init-param>
</servlet>

Or maybe this

Error prompt in <init-param>the line, given the specific contents are as follows:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":enabled, 
 "http://xmlns.jcp.org/xml/ns/javaee":async-supported, "http://xmlns.jcp.org/xml/ns/javaee":run-as, "http://xmlns.jcp.org/xml/ns/javaee":security-
 role-ref, "http://xmlns.jcp.org/xml/ns/javaee":multipart-config}' is expected.

Or the following error

Invalid content was found starting with element '{"http://xmlns.jcp.org/xml/ns/javaee":servlet-class}'. 
One of '{"http://xmlns.jcp.org/xml/ns/javaee":description, "http://xmlns.jcp.org/xml/ns/javaee":display-name, 
"http://xmlns.jcp.org/xml/ns/javaee":icon, "http://xmlns.jcp.org/xml/ns/javaee":servlet-name}' is expected.

The solution is as follows:

The init-paramelement to move the entire load-on-startupelement before, after modification, as follows:

<servlet>
    <description>Enter Dispatcher</description>
    <servlet-name>xxxMVC</servlet-name>
    <servlet-class>com.xxx.web.servlet.RequestDispatcher</servlet-class>
    <init-param>
        <param-name>xxxName</param-name>
        <param-value>xxxValue</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

Or

Error cause analysis (only for the first error):

Because it is the servletelement of error, so we try to find the corresponding xsd file, look at the error place in violation of which of the restrictions or constraints. According to the statement xml file header, we know that the corresponding xsd files are http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd, but from the web-app_3_1.xsdfile, we define the corresponding constraint did not find. However, we found the following code snippet:

<xsd:include schemaLocation="web-common_3_1.xsd"/>

So, we try to continue to web-common_3_1.xsdfind the corresponding limit or constraint, we find the following two snippets:

<xsd:element name="servlet" type="javaee:servletType"/>
<xsd:complexType name="servletType">
    ......
    <xsd:sequence>
        ......
        <xsd:element name="init-param"
                     type="javaee:param-valueType"
                     minOccurs="0"
                     maxOccurs="unbounded"/>
        <xsd:element name="load-on-startup"
                     type="javaee:load-on-startupType"
                     minOccurs="0">
        </xsd:element>
        ......
    </xsd:sequence>
    ......
</xsd:complexType>

From the above two pieces of code, we know that, for the servletelements, by <xsd:sequence>limiting the order of appearance of the child elements init-parammust appear load-on-startupbefore. At this point, we finally understand that the reason for the error is that we set the wrong order of the child elements.

 

[Solved] idea connect to remote Hadoop always error: org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0(Ljava/lang/String;I)

Error content: org.apache.hadoop.io.nativeio.nativeio $windows.createdirectorywithmode0 (ljava/Lang/string; I)

1. There is a problem with the downloaded Hadoop/bin,

Refound some winutil.exe related to Hadoop/bin, and then replaced the old one and tried again. It was really successful!!!

Make sure the version is similar!!!

My Hadoop version of Linux is 3.1.4. Later, when connecting, I need to configure windows, which is 2.6.0. Then I keep reporting errors, so I changed it to 3.0. Be sure to choose a version similar!!!

2. Add static code blocks

static {
        try {
            System.load("D:\\install\\winutils-master\\winutils-master\\hadoop-3.0.0\\bin\\hadoop.dll");
            //We recommend using the absolute address, the path to the hadoop.dll file in the bin directory
        } catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load.\n"+ e);
            System.exit(1);
        }
    }

Error in idea project startup: lambda expression is not supported in Java: – source 1.5

Error: lambda expressions are not supported in Java: – source 1.5

Reason: the JDK version used in this project is less than 1.8

The error information is as follows:

  The solution is as follows:

First, judge whether it is a POM problem: it will automatically change to 1.5 after modifying the environment

Solution: https://www.cnblogs.com/shining-feifan/p/15587151.html

Step 1: click “project structure” in the menu bar in the upper right corner

  Step 2: on the “project structure” page, select “SDKs”, select jdk8, and do not click the “+” button to add.

  Step 3: on the project structure page, select a module and modify the sources configuration

   Step 4: on the project structure page, select a module and modify the dependencies configuration

 

Maven: idea cannot download the source code Issue [How to Solve]

Download the source code sources by clicking into the decompiled code file of idea.

The idea prompts an error and cannot download the source code.

Solution:

mvn dependency:resolve is to resolve all dependencies of the project. Finally, it prints out the details of the resolved dependencies. Specify the optional parameter classifier = sources to try to analyze and download the corresponding dependent source code. Open teminal, execute it using the local maven, and then download it.

1 mvn dependency:resolve -Dclassifier=sources

Later, I encountered the problem that idea could not download the source code.

First confirm the file | settings | build, execution, deployment > Maven settings, Maven version is 3.8.3, configuration file is also 3.8.3, and local Maven warehouse also has settings.

Click to download the source code again, and you still can’t download it.

First, check whether the local Maven warehouse has downloaded the source code, and find a file about slf4j-api-1.7.21-sources.jar.lastupdated. This file is a record file of Maven’s failure in trying to download the slf4j API source code.

Open the file with Notepad + +. According to the contents, it seems that the failure to download is closely related to the Maven default HTTP blocker.

1 #NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
2 #Sun Nov 21 16:52:48 CST 2021
3 http\://0.0.0.0/.error=Could not transfer artifact org.slf4j\:slf4j-api\:jar\:sources\:1.7.21 from/to maven-default-http-blocker (http\://0.0.0.0/)\: Blocked mirror for repositories\: [nexus-aliyun (http\://maven.aliyun.com/nexus/content/groups/public, default, releases)]
4 @default-maven-default-http-blocker-http\://0.0.0.0/.lastUpdated=1637484768579

Check the setting.xml file, find the following related configurations, and comment out the Maven default HTTP blocker image, which prevents you from finding dependencies in Alibaba’s image library. At that time, I didn’t know what the problem was to solve. I set it up and commented it out first.

After saving, restart idea, and then you can download it. The problem is solved.

The source code files are also downloaded from the local repository.