Roo doesn't update class-files anymore - java

After working for weeks on a Roo Project mine stopped to update the .class-files inside the directory:
Project\src\main\webapp\WEB-INF\classes\com\company
and
Project\src\main\webapp\WEB-INF\classes\com\company\web
When I deploy with STS on the local Tomcat it used the new class-files but perform package command used the old one from the locations mentioned above.
Once I deployed the war-file to a remote server I got silly errors.
It took me like one workday to figure out what is going wrong.
How can I make Roo update the .class-files again? I tried poll now but it finishes within one second without any results.

Have you tried doing a perform clean from within the roo shell? This should remove the target folder and rebuild all your class files.

Related

How to build, deploy and run Java application on JBoss WildFly from the command line?

My team is working on a Java application that runs on Jboss WildFly, using Maven to resolve dependencies and Primefaces.
We're using Eclipse to build, deploy and run the server. Eclipse does most of the work, building the WAR file, deploying it to server and running it.
Now we need to create an script that performs all those steps because it has to run on remote server.
.
The steps would be something like this...
1 Run Maven:
$M2_HOME/bin/mvn clean install
2 Build project to a war file
3 Deploy war file into the WildFly deployment folder
$WILDFLY_HOME/bin/jboss-cli.sh --connect --command="deploy --force [PATH_TO_WAR]"
4 Start server
$WILDFLY_HOME/bin/standalone.sh
.
I can perform every step but once the server is running it don't seem to be any changes in the application. I think this is because the WAR file has to be built optimizing it for JBoss. Eclipse has a way to do this when exporting the project. I need to know how to do that from command.
EDIT:
The real problem is that Jboss is not updating the published project when i run it from bash script. I thought it was because i had to build it on a specific way. I was wrong. The build is fine, just running Maven the deploy is done. The thing is that even if i rebuild project and redeploy it, server doesn't seem to notice at all.
I've tried deleting tmp, lib and data folders from standalone folder, and nothing happens. I also deleted standalone/deployed sub files and folders and got the same result.
The only way i achieve the result i'm expecting is getting into Eclipse, go to Servers tab, right click on JBoss Wildfly and click on 'Clean...'. This options seems to clean cache, rebuild and re publish the application in a right way that i don't know. I didn't find any answers on google.
eclipse server clean option
Give a look on Eclipse war export: optimize for a specific server runtime.
Quoting from #Konstantin Komissarchik's answer :
Eclipse itself doesn't do anything with that option. What happens is
dependent on a particular server adapter. Many of the adapters don't
do anything with this option either, but they might in the future.
If a server adapter does support export optimization, it has the
option of displaying custom options beneath that pop-up list of
runtimes, so that's a good cue to use to see if something will
actually happen.
So taking in consideration that in your provided image there is no custom options below Wildfly 9 selection, I am pretty sure that this option does not perform any optimization at your exported war so you can totally omit it in your new build-deploy process.
How can i build the war file from command, knowing it will have to run on Wildfly?
We are also deploying applications for a long time on several versions of Widlfy with the same approach as you are planning to, without the optimization thing. I can ensure you that we have not faced any performance issue.

create exeutable WAR file springboot without maven/Gradle

I have created a simple springboot application with inbuild tomcat which works fine when I am running it as JAVA Application in Eclipse. I tried to export this as a WAR file and tried to run it in Windows command line and also in UNIX box. I tried to execute it like below,
java -jar C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: An unexpected error occurred while trying to open file C:\Users\Iam\Documents\SpringHelloWorld.war
java -cp C:\Users\Iam\Documents\SpringHelloWorld.war main.java.com.controller.SpringBootWebApplication
Error: Could not find or load main class main.java.com.controller.SpringBootWebApplication
I just export it as a WAR file, should i need to define anything before exporting it as WAR in Springboot ( note: i am not using maven or gradle )
Below is my project structure :
enter image description here
Probably it is possible to do this without Maven/Gradle, but I would never take this approach.
Even considering the best case, you will end up re-creating what others have created in the Spring Boot parento pom.xml or in his Gradle equivalent, so why you would waste a lot of time recreating what is already created by someone else? If you really want to know how the war is created, then take a look in Spring Boot parent pom, but you should limit your work to wrap what is ready for production in order to compose your solution.
Also consider that Maven and Gradle are constantly developed and updated, along everything belongs to their ecosystems. If you plan to replace them, then you should be prepared to mantain and develop alone your own build platform, which is a non-trivial effort.
Better include Maven or Gradle, you'll be more productive.

Spring Boot 1.3 : error on init.d service but "java -jar" working

I have an app that runs properly when I execute java -jar myapp.jar but when I link it to run as process I'm getting 404 error. So I made an gitHub repository only with the relevant classes to show you the error. Could you try to reproduce it?
Here is the code
https://github.com/alephlm/spring-boot-1.3-error-executable-service
I'm using ubuntu 14.04
Thanks.
Your maven script never explicitly packages the webapp contents, and even if it did, Tomcat will not pick it up. But, there is a work around, do the following:
create a META-INF/resources in your resources folder (e.g. src/main/resources/META-INF/resources/)
now move everything from under webapp to your new META-INF/resources folder (e.g. ..META-INF/resources/WEB-INF/views/hello.jsp)
I recently read about it on Gunnar's blog. The great thing about this solution is that you don't have to mess with the maven copying resources, it will automatically get picked up since it's in src/main/resources.

Classes not pushed to bin folder - eclipse spring boot

I am working on a spring boot project. Whenever I make a change & run as spring boot app , the latest changes are not reflecting. This was working fine for past 3-4 month and I started seeing this issue in the past couple of days. I have been trying to unsuccessfully find the change that may have triggered this issue. For instance , I change the application.properties and run a gradle build. I see the latest application.properties in build folder but the old one in the bin folder. So I am having to manually copy all the modified files under bin folder before running the project as spring app. Can you please suggest as to how I can investigate this further? Thanks.
EDIT: This seems to be impact one specific application and not all the applications in the workspace.

NetBeans not correctly compiling my Java sources

I am encountering a problem with NetBeans 7.4 (but also previous versions such as NetBeans 7.3). When I clean & build my Java Web application, it gets successfully built, but my newly added code is not included with that build.
I confirmed this by decompiling the classes to check whether my changes got through, but they did not.
I have tried different versions of NetBeans to see what happened. At one point in time, I also compiled the application through command line using ANT. I have also tried deleting the build and dist folders manually. None of these methods solved my issue.
The only, not acceptable solution is that I compile the class individually, then it is ok. But when I clean and build the whole application, the older sources are compiled.
Looking forward for some help, because I'm really lost, and compiling individually is not an option, since before releasing, I would like to use a single .war file.
This issue was a silly mistake. The web part of this project was retrieved by copying the web folder from the server in order to make sure that my team has the latest sources. By doing this the class files were being included within the WEB-INF folder, therefore, when attempting to rebuild the application, for some reason, the build was retaking the files within the Web/WEB-INF folder and not generating the classes from the sources.
When that folder was cleaned up from any class files, the project now builds successfully.

Categories