Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile error (missing javax.Servlet and Undertow) while importing in eclipse #9175

Closed
1 task done
Arnaud-Nauwynck opened this issue Feb 2, 2019 · 10 comments · Fixed by #9369
Closed
1 task done

Comments

@Arnaud-Nauwynck
Copy link

Arnaud-Nauwynck commented Feb 2, 2019

Overview of the issue

importing a jhipster project does not compile in eclipse, but compiles in maven

Eclipse complains about missing class: javax.servlet.ServletException

The type javax.servlet.ServletException cannot be resolved. 
It is indirectly referenced from required .class 
files	WebConfigurerTest.java	/test-1/src/test/java/com/mycompany/myapp/config	

The project was not built since its build path is incomplete. 
Cannot find the class file for javax.servlet.ServletException. 
Fix the build path then try building this project

Adding

		<dependency>
		    <groupId>javax.servlet</groupId>
		    <artifactId>javax.servlet-api</artifactId>
		    <scope>provided</scope>
		</dependency>

solved this first error, but there is 16 others (all concerning undertow) after:

The type io.undertow.Undertow$Builder cannot be resolved. It is indirectly referenced from required .class files	WebConfigurer.java

Adding this solves the remaining errors:

	 <dependency>
        	<groupId>org.springframework.boot</groupId>
	        <artifactId>spring-boot-starter-undertow</artifactId>
	        <scope>provided</scope>
	  </dependency>
Motivation for or Use Case

using eclipse..

Reproduce the error

create empty jhipster project, choosing maven
then import in eclipse using "import ... > existing maven project"

eclipse version : 2018-12, with jdk8, standard eclipse java, no plugins

Related issues
Suggest a Fix

adding this in the pom.xml solves the issue:

		<dependency>
		    <groupId>javax.servlet</groupId>
		    <artifactId>javax.servlet-api</artifactId>
		    <scope>provided</scope>
		</dependency>
		<dependency>
        	<groupId>org.springframework.boot</groupId>
	        <artifactId>spring-boot-starter-undertow</artifactId>
	        <scope>provided</scope>
	    </dependency>
JHipster Version(s)

JHipster version v5.8.1

JHipster configuration

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
test-1@0.0.0 D:\test-jhispter\test1                                                                        
`-- generator-jhipster@5.8.1                                                                                            
                                                                                                                        
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
                                                                                                                   
{                                                                                                                       
  "generator-jhipster": {                                                                                               
    "promptValues": {                                                                                                   
      "packageName": "com.mycompany.myapp",                                                                             
      "nativeLanguage": "en"                                                                                            
    },                                                                                                                  
    "jhipsterVersion": "5.8.1",                                                                                         
    "applicationType": "monolith",                                                                                      
    "baseName": "test1",                                                                                                
    "packageName": "com.mycompany.myapp",                                                                               
    "packageFolder": "com/mycompany/myapp",                                                                             
    "serverPort": "8080",                                                                                               
    "authenticationType": "jwt",                                                                                        
    "cacheProvider": "ehcache",                                                                                         
    "enableHibernateCache": true,                                                                                       
    "websocket": false,                                                                                                 
    "databaseType": "sql",                                                                                              
    "devDatabaseType": "h2Disk",                                                                                        
    "prodDatabaseType": "postgresql",                                                                                   
    "searchEngine": false,                                                                                              
    "messageBroker": false,                                                                                             
    "serviceDiscoveryType": false,                                                                                      
    "buildTool": "maven",                                                                                               
    "enableSwaggerCodegen": false,                                                                                      
    "clientFramework": "angularX",                                                                                      
    "useSass": true,                                                                                                    
    "clientPackageManager": "npm",                                                                                      
    "testFrameworks": [],                                                                                               
    "jhiPrefix": "jhi",                                                                                                 
    "entitySuffix": "",                                                                                                 
    "dtoSuffix": "DTO",                                                                                                 
    "otherModules": [],                                                                                                 
    "enableTranslation": true,                                                                                          
    "nativeLanguage": "en",                                                                                             
    "languages": [                                                                                                      
      "en"                                                                                                              
    ]                                                                                                                   
  }                                                                                                                     
}                                                                                                                       
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
                                                                                                                   
                                                                                                                        
Environment and Tools

java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

git version 2.17.0

node: v10.15.1

npm: 6.4.1

yeoman: 2.0.5

yarn: 1.13.0

Entity configuration(s) entityName.json files generated in the .jhipster directory

none

Browsers and Operating System

Windows 10.
browsers: any (compile time error)

  • Checking this box is mandatory (this is just to show you read everything)
@pmverma
Copy link
Member

pmverma commented Feb 2, 2019

I can confirm both the problem and suggested fix. I have encountered this a few times (randomly) with my STS 3 while the maven compiles fine. This is really an annoying error and you can not run the project or tests from the IDE.
It seems this is specific to eclipse IDE and its maven plugin.
I also would like to suggest to apply the fix in the jhipster pom.

@pascalgrimaud
Copy link
Member

@Arnaud-Nauwynck @pmverma : can one of you do a PR to apply the fix ?

@cbornet
Copy link
Member

cbornet commented Feb 6, 2019

Are you sure you activated either the "dev" or the "prod" Maven profile ?

@pmverma
Copy link
Member

pmverma commented Feb 7, 2019

@cbornet No, I didn't activated maven profile manually in eclipse. I assume that it should work out-of-the-box and we have not to do so previously either. I will try it tonight and update here.

@jaydeep-punjani
Copy link

Hi @cbornet I can confirm, that after manually selecting the dev profile in eclipse. It works. But we didn't need to do this step previously, anything has changed?

@jaydeep-punjani
Copy link

@pmverma @cbornet on more observation related to this issue is, this does not occur when importing a freshly generated app and only happens after running jdl-import.

@pmverma
Copy link
Member

pmverma commented Mar 3, 2019

This is also happening inside vscode and it is really annoying. I will do a PR with suggested fix very soon.

@cbornet
Copy link
Member

cbornet commented Mar 4, 2019

The issue if I'm not mistaken is that the dev profile is not set. Adding the deps to the pom will probably not be enough as you should be either in dev profile or prod profile. We should even check that at runtime.

@jdubois
Copy link
Member

jdubois commented Mar 4, 2019

yes that means the profile is not set, even though it's active by default in Maven (and that used to work!). So I'm guessing there is an issue in the Eclipse Maven plugin -> we should find a workaround, but most importantly this bug should reported to them (or we should find the existing ticket and link it here)

@pmverma
Copy link
Member

pmverma commented Mar 4, 2019

Of course activating the profile manually in the eclipse project setting works fine. But I'm not sure how to do it in visual studio code. And yes this issue seems related to the eclipse Maven plugin.

@jdubois jdubois added this to the 6.0.0-beta.0 milestone Apr 4, 2019
mraible pushed a commit that referenced this issue Dec 16, 2019
* add support for thin jar in gae

Only adds to maven build; work in progress

* correcting mistake introduced in a pervious pull request

A previous pull request incorrectly removes the com.google.cloud.tools when gaeCloudSQLInstanceNeeded is set to false

#10362

* add correct handlers for retrieving static files

* remove bootWar from gradle

The new GAE with Java 11 builds on JAR; this has been done on the maven side.

* correcting mistake introduced in a pervious pull request

A previous pull request incorrectly removes the com.google.cloud.tools when gaeCloudSQLInstanceNeeded is set to false

* replace deprecated value "project" by "projectId"

* testing with cloudsql; change string to single quotes

If this is not done the following error is created;

yntaxError: Multi-line double-quoted string needs to be sufficiently indented (16:14)
  14 |     datasource:
  15 |         type: com.zaxxer.hikari.HikariDataSource
> 16 |         url: "jdbc:mysql://google/mysql?cloudSqlInstance=abstract-block-253023:us-central1:testjhipster
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Add copyright information

* add mainclass name instead of basename

* add gradle support for unjaring the original jar

This adds Gradle side support for thin jars

* missing symbol from previous commit

* remove the original jar as per discussion

* minor bug fix per code review

* add max heap size to entrypoint field in app.yaml

* Revert Xmx change

* correction of the url strings

* remove whitespaces in project ID

* simplify the prod-gae profile definition

* thin jar generation support for maven

* thin jar generation support for gradle

* adjustments to the maven and gradle deployment commands

* add thinResolve step before staging

* prettier issue fix

* add error code checking for gcloud

- gcloud seems to print out info messages to the error stream as well. We need to check whether it's an actual error

* add trim to remove unnecessary newline and remove silent mode for prompt in order to trigger cloud sql api

* fix the trim line more elegantly

* add missing maven dependency

* refactor code to include application-prod-gae.yml file regardless of Cloud SQL

- this makes sure the correct port environment variable is passed whether the user chose to use cloud sql or not.

* fix dependency problem (similar to #9175) to get rid of the clean option

* add dependency before the check for cloud sql

* changed per code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants