Mule -Local Deployment issues on Mule using AnyPointStudio 6 on Windows 10 - deployment

I have an application which uses files in src/main/resources. When I do a maven clean install it generates a zip file which it puts in my local .m2 repository and in the the target folder. However, when I choose the Run As-> Run Configurations so that I can run the app locally, Mule chooses the wrong folder, which is in my workspace. That folder doesn't have the resources folder. How can I change the location of the file that Mule should use to run the local deployment, i.e. the embedded local server? The same application deploys correctly on windows 7 and with Anypointstudio 6.
The option Mule -> mavenize is grayed out in my IDE. However, when I select Run As-Run Configuration I can see Run As Maven Application. I choose that option and added the JVM arguments and tried to deploy. The build succeeded as shown:
INFO] Adding as a lib
[INFO] C:\Users\orbee\AnypointStudio\workspace\TestProject\mappings
does not exist, skipping
[INFO] Building zip:
C:\Users\orbee\AnypointStudio\workspace\TestProject\target\TestProject.zip
[INFO] ----------------------------------------------------------------------- -
[INFO] BUILD SUCCESS
The deployment failed however, with the error:
Unable to copy project zip file to the embedded Mule instance. Project:
[Mule Project]
Name: TestProject - Domain: default
Source 'C:\Users\orbee\AnypointStudio\workspace\TestProject\target\
TestProject-0.0.1-SNAPSHOT.zip' does not exist
It fails because it is trying to use the Snapshot zip whilst the zip that was actually built TestProject.zip and hence cannot find it. Is there a way to change the path to use the snapshot zip?

Right-click your project, Run As -> Mule Application with Maven. This will run the maven build, and then deploy it to the embedded server.
If the Run As menu has 'Mule Application' as the option instead of 'Mule Application with Maven', then Anypoint Studio has not determined that your project uses maven. In that case, right-click the project, Mule -> Mavenize or Mule -> Enable Support.

Related

Gradle Multiproject War withEclipse gradle plugin. Not including project dependencies in tomcat webapp/app/WEB-INF/lib

In a gradle multiproject, I have 3 projects:
The first one contains basic utils (plugin; java-library)
The second is a java application that depends on the first project (plugin: java)
The third is a web application, that depends on the first project (plugin: war)
All 3 projects are declared in settings.gradle of the parent project
The first project is referenced from the second and third project setting:
api(project(":FirstProject"))
The second project runs without problems from Eclipse (Run As- Java application)
The third project cannot run properly as has missing dependencies at run time (Run As - run on server)
Looking in the directory where local tomcat resides in eclipse
/home/ximo/WORKSPACES/WS01/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/CSV01/WEB-INF/lib
I have detected that the first project jar is missing (firstproject.jar)
But when executing the build task from the "Gradle tasks" view, the generated war does contain the "missing" jar.
So the problem only arises when Eclipse deploys the application to the local tomcat for running (or debugging) locally the application.
I have used 2 possible "dirty" solutions for this problem:
Copying this jar by hand to the referenced deployment lib folder.
Adding to the build.gradle a reference to the missing jar
implementation files('path_to_jar/firstproject.jar')
Any idea for solving this issue?
Thanks.

Eclipse Wildfly integration: Missing webapp resources on server

I'm building a java web application with Vaadin, which generates some config files on maven build. For some unknown reasons, only a part of the generated files in WEB-INF are present on the when trying to full publish to Wildfly in Eclipse. (In particular, WEB-INF/classes/META-INF/VAADIN/config/stats.json is not present which results in an error in the Vaadin application.)
Several things that were tested
Maven build does generate the file in the said location.
Copying the War built by maven directly to /standalone/deployments results in a working application without error.
After maven build and refresh in eclipse, the generated file is correctly shown in project explorer, indicating a successful refresh (right?)
Another generated file in the same directory DO get copied (flow-build-info.json). The difference between these two files may be, that flow-build-info.json exists twice in target, in classes/META-INF/VAADIN... as well as in /[final name]/WEB-INF/classes/META-INF..., while stats.json only exists in /[final name]/WEB-INF/classes/META-INF....
Used versions
Eclipse version: 21.12 & 21.9
JBoss AS, WildFly & EAP Server Tools: 3.9.106.v20210618-2025
Wildfly 17, 20, 22
Vaadin 14.7.5
I found out the problem: Maven build generates the Vaadin files just fine. However, if a maven update is executed afterwards in Eclipse before publishing to the server, the maven update would modify the target/classes directory. This modification somehow removes all files but the flow-build-info.json (still don't understand this part). This results in the missing resources after publishing.
So basically, maven build -> refresh in eclipse -> NO MAVEN UPDATE -> full publish works.

How avoid Eclipse load test-class file in to classpath when Java app run?

I am using STS to develop a large Spring Boot based application. We have multiple maven projects and a parent project to include them all. Each project has own testing code and config files.
When I run the Spring Boot application in the main entry class. The test-classes folder of the depended projects will be loaded into the app running classpath, that causes some conflict of spring bean definition. I have to config every project removing [src/test/java and src/test/resources] from the 'source folders on build path'.
The whole project structure is like below:
app-parent
sub-app-1
sub-app-2
sub-app-3
main-app [running from this project]
main-app project has dependencies on the sub-app-1 ~ 3.
Is there any way to let STS (Eclipse) run a Java App excluding the test-classes folder from classpath? I really do want the testing code under source folder but not have them when the App run.
Besides, I tried open the [run configuration], but it can only add more file to the classpath.
As pointed out by #torsten-crass, verify that Exclude test code is ticked in your Classpath tab of Run configurations in Eclipse.
Here is the screenshot.

How to deploy generated resources to tomcat with m2e-wtp?

I am pulling JavaScript from a jar as part of my build process. I wish this js to be part of my web resources for the app deployed on tomcat and I have updated my build process to allow this to happen. Doing a maven build (outside eclipse) works as expected and I can package up a war with everything in its proper order.
However, when building with eclipse I have run into some headaches. My understanding was in order to have web resources deployed to tomcat through an incremental build, I needed to put these build-time generated js files into the target/m2e-wtp/web-resources directory. However, when I publish these new files are ignored and the web-resources deployed to tomcat seem to be pulled from my source.
I also adjusted my project's deployment assembly settings. Through this I still don't have it working. I have the entry [source:/target/m2e-wtp/web-resources, DeployPath:/] which should find the newly generated files when I perform a "publish" to the server. However, the same thing happens where m2e-wtp seems to be pulling from source.
Am I missing something? How can I get standard behavior from m2e-wtp (i.e. make it comparable to a build done outside of eclipse)? Or can I have eclipse just build the war and deploy it as such (not do the incremental builds, I can sacrifice some speed)?
FYI (versions):
eclipse: (Using Spring Tool Suite) 3.2.0
m2e: 1.3.1
m2e-wtp: 0.17.0
tomcat: 7.0
Experiment added later:
After deleting my target dir, I performed a publish to Tomcat and all the web-resources were copied from my source. I also got a popup about files not found, most of which are compiled classes. However, it was looking for three files in the /target/m2e-wtp/web-resources/META-INF. Does the m2e-wtp plugin only look for specific files in a folder rather than the entire specified folder?
The problem is that the target directory was not being refreshed. Eclipse (or m2e plugin for that matter) doesn't recognize or care that files change in the target directory during a build, something that I was assuming. For now I have the auto-refresh (for the workspace) option on. The refresh on access option didn't working as it seemed to trigger the refresh only when I was publishing to tomcat for the first time.

Intellij GWT project does not create /WEB-INF/deploy directory

By default gwt applications should have a directory in WEB-INF called deploy/yourmodulename which contains the .symbolmap files which are needed to de-obfuscate client side stack traces.
When I compile via Maven it automatically creates this directory. Unfortunetly this directory is never created when I run my project via Intellij.
I am not running a "GWT" Run/Debug configuration but rather a Jetty configuration that actually runs the GWT compiler with the settings set for your GWT facet and deploys the intellij "artifact".
Any idea why this directory is not present?
Support for 'deploy' directory is added in IDEA 12 EAP builds. Open the artifact editor, press '+' button on 'Output Layout' tab and select 'GWT Compiler Deploy Output' to add 'deploy' directory to the artifact.