1

I'm trying to stop using Eclipse JEE as my main IDE, and since VSCode has some Java support nowadays, I'm attempting to jump ship. I have two issues right now, and if I'm unable to correct them I'll be forced to use Eclipse as just a Tomcat .war deployer.

Is it possible to have VSCode act or have the same functionality that Eclipse has of auto-deploying .war and publishing changes on the fly?

I know that the current Tomcat For Java extension for vscode has the option to deploy an exploded .war, but this gives me javax.serverFilter errors even though I added the javax.servlet-api dependency as provided on my pom.xml.

It also gives me the option to manually create and deploy a .war, and it works, but this is extremely annoying for small modifications.

I tried to add the tomcat7-maven-plugin on my pom.xml and run the following command for a more automated deployment:

cmd /c mvn tomcat7:deploy -DskipTests -f "c:\Users\user\git\MyWebApp\pom.xml"

But every configuration I've tried gave me the same error:

I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error

And I did try all of the solutions presented on these links:

Tomcat 7: Connection reset by peer or Software caused connection abort

Tomcat deploy using tomcat7-maven-plugin fails with error "Cannot invoke Tomcat manager: Connection reset by peer: socket write error"

maven tomcat deployment producing error

Socket write error when I try to deploy maven project to tomcat

Now even if I manage to fix my socket write error, I still have no idea if I'll be able to create a task or something that detects modifications and republishes my changes to my Tomcat. Any ideas?

I'm using:

Tomcat 9

Apache Maven 3.6.1

tomcat7-maven-plugin 2.2

javax.servlet-api 3.1

Tomcat For Java 0.11.1

VSCode 1.35.1 with all the relevant Java extensions

Edit: Here's my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyWebApp</groupId>
<artifactId>MyWebApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>
</dependencies>
<build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>test</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>TomcatServer</server>
                <username>admin</username>
                <password>admin</password>
                <path>/MyWebApp</path>
                <update>true</update>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.1</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

And my settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 <servers>
     <server>
       <id>TomcatServer</id>
       <username>admin</username>
       <password>admin</password>
     </server>
 </servers>

And tomcat-users.xml

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
          version="1.0">
<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-script"/>
</tomcat-users>
D.Diniz
  • 41
  • 1
  • 4

1 Answers1

1

try to change the tomcat-user.xml like this :

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
      version="1.0">
   <role rolename="admin"/>
   <role rolename="manager"/>
   <role rolename="manager-script"/>
   <role rolename="manager-gui"/>
   <user username="admin" password="admin" roles="admin,manager,manager-script,manager-gui"/>
</tomcat-users>
Leo Zhu
  • 15,726
  • 1
  • 7
  • 23