zengkid / SmartTomcat

The Tomcat plugin for Intellij IDEA
Apache License 2.0
126 stars 55 forks source link

Does not find classes in lib subfolder #48

Closed karge-itestra closed 4 years ago

karge-itestra commented 4 years ago

When I add additional classes (not jar-based but folder-based) to the lib folder of my tomcat, they are not taken into account for the deployment.

e.g., adding .class files to /lib/com/companyname/project/ does not result in that class to be found from the deployed project, whereas deploying the project as war directly will find those classes.

I can add a lib folder to the deployed project directly in the .SmartTomcat directory and add my classes there, however, that needs to be done manually.

I would appreciate a fix or a pointer to where to start with a contribution to fix the issue.

Thanks for building and maintaining this plugin!

zengkid commented 4 years ago

When I add additional classes (not jar-based but folder-based) to the lib folder of my tomcat, they are not taken into account for the deployment.

e.g., adding .class files to /lib/com/companyname/project/ does not result in that class to be found from the deployed project, whereas deploying the project as war directly will find those classes.

I can add a lib folder to the deployed project directly in the .SmartTomcat directory and add my classes there, however, that needs to be done manually.

I would appreciate a fix or a pointer to where to start with a contribution to fix the issue.

Thanks for building and maintaining this plugin!

you can create xxxx.jar folder under %tomcat_home%/lib, and then put your classes into the xxx.jar folder.

karge-itestra commented 4 years ago

I am afraid that this is not an option, since the folder names are determined by the package names. The line responsible for searching the jars is here: https://github.com/zengkid/SmartTomcat/blob/76320eba73fee5117240790b52b8db007a119e95/src/main/java/com/poratu/idea/plugins/tomcat/conf/AppCommandLineState.java#L263 The cleanest option probably would be to put the path to the lib folder into catalina.properties common.loader entry of catalina.properties, instead of collecting the .jar files and putting them into the classpath directly.

karge-itestra commented 4 years ago

After researching the documentation, my approach only ever worked because Tomcat did not stick to its specifications too much. We just compiled the dependency into a jar instead, which works fine with SmartTomcat.