Eclipse Java Remote Project won't build and run - java

I have spent 6h+ and finally I've decided to seek the community's help.
I have a Java project on a remote SSH cluster and I have imported it into eclipse using RSE (Remote System Explorer). This project used to be a local project and has many libraries/dependencies. I have configured all of them and all of the paths are accessible on the remote cluster.
I want to run it on the remote cluster using SSH as well (via Eclipse External Tools). I have configured EVERYTHING and have even successfully ran another project. However, right now the problem is that Eclipse does not create even a SINGLE .class file on the remote server!!!
The project does not have any errors (if I just copy its bin folder from my computer to the remote cluster it works) but, since Eclipse does not produce a single .class file, there is nothing to run in its bin folder on the remote cluster.
It's also worth mentioning that for some reason that I don't understand, there is a red x on the projects name in Project Exlorer (indicating error) but there is no such thing on any of the source codes/packages in this project.
The "Build Automatically" option is active and cleaning and building it manually won't work either.
Any help is hugely appreciated as I am really desperate and need to get this thing working.
Thanks in advance.

I had a similar problem and this solution worked for me:
In my java context.xml file in the META-INF folder (local project context), I added path="/myProjectName" and it started building automatically.
<Context path="/jvals" antiJARLocking="true" antiResourceLocking="true">
<Resource name="jdbc/jvals"....

I was never able to solve this problem and the only thing I could think of was a bug within Eclipse. It seems that because of slow transfer rates to/from cluster, some of the files could not be built as they were partly fetched/stored. I ended up writing a shell script that would transfer the files to the remote cluster and compiled and ran it on there.
If anyone has a better suggestion, I will be very grateful.

I solve the problem in another way ;
go to the remote project in linux ;
cd youRemoteProject/build/classes
if your jars is in xxx\lib\a.jar, b.jar
java -cp ".;xxx\lib*" package.package.className
( you must using Java 6 or later, classpath wildcards are a part of the JVM )

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.

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.

fail to remote debug tomcat with eclipse after deploy a modified jar

I'm developing a datastore plugin to Geoserver, to develop it faster I am trying to remote debug it. Geoserver uses Tomcat behind the curtains. I prepared everything to remote debug via Eclipse and accomplished it. Now I can remote debug my plugin. However, when I modify my code (I tried to add a harmless line like: int noHarm = 5;) and then export it as jar and copy that jar to webapps\lib\ under Geoserver installation directory, I fail to remote debug the plugin. After that I changed that modification back to when it was worked(deleted int noHarm = 5;) and created the jar again, then copied it under webapps\lib\ , now I am able to remote debug again.
When I open stores page in Geoserver, it stops at breakpoints in the canProcess() method with the jar exported from not modified code or when I try to add new Store it stops at breakpoints in the createDataStore() method with the jar exported from not modified code. But if I change even a tiny line or add it won't stop at breakpoints even though it connects to virtual host succesfully(I use vmware workstation with windows 7-32 bit on it if it helps).
What could be the problem?
Thanks very much in advance.
I found the solution, it was about eclipse. My source files was not in the workspace so, in the project build path --> under the source tab I was using Link Source button. That button allows you to link java files (which are not under your workspace) to your project and let those files act as source. What I did to solve this problem:
I then moved those files under project's real source folder
With that I created jar.
I stopped Geoserver(Tomcat) and copied my jar under webapps\lib\
I started Geoserver(Tomcat) and connected to server via eclipse remote debug.
After these steps I was able to remote debug with every jar I deployed.

JBoss Tools deploy error: This may be caused by your server's temporary deploy directory being on a different filesystem than the final destination

I have the following error when deploying an application with JBoss Tools in Eclipse:
Error renaming C:\wildfly-8.1.0.Final\standalone\tmp\tmp7858611943756287857.xhtml to C:\wildfly-8.1.0.Final\standalone\deployments\.war\403.xhtml.
This may be caused by your server's temporary deploy directory being on a different filesystem than the final destination.
You may adjust these settings in the server editor.
And here is a screenshot of the error:
On the documentation, I found this:
You can customize the deployment location and packaging type:
To select the workspace deployment folder for the server, click Use workspace metadata.
To select the deployment folder of the application server, click Use the JBoss deploy folder.
To select a folder of your choice, click Use a custom deploy folder. With this option, complete the Deploy directories and Temporary Deploy Directory fields. The temporary folder must be on the same file system as the final deploy location otherwise publishing often fails.
For all modules to be archived for deployment, select the Deploy projects as compressed archives check box. This avoids exploded
deployments and reduces the amount of memory deployments occupy but
may result in slower deployment.
What does The temporary folder must be on the same file system as the final deploy location mean? How can I solve it?
I've realized that the error doesn't occur when the check box Deploy projects as compressed archives is checked.
I solved this problem following the steps below:
Restarted the computer
Deleted the project files from the folder "standalone\deployments"
Deleted all files in the folder "standalone\tmp"
Clean project in Eclipse
In Eclipse, removed project from Wildfly and then added again
In Eclipse, right click on "Wildfly" and then "Clean..."
In Eclipse, right click on the project module and then "Full publish"
I get this error right after I updated a dependency in my pom.xml and tried to republish.
The thing that worked was to uncheck the setting in the server deployment for "Deploy projects as compressed archives"
I had the same problem and the only solution after hours looking for in google, I solved closing eclipse, deleting the folder ".metadata" of the workspace restarting eclipse and creating the server of JBoss AS 6.x again and deploying again and everything worked for me correctly. I hope this help.
I've had the same problem. Files of the .metadata and .recommenders workspace folders were corrupted. I took those folders from a colleague and replaced mine. It worked!
The hermeslm solution fixes most (if not all) problems with workspace, but it is final and robust weapon of choice. Be advised that if you have highly configured eclipse (custom code assist, formatting definitions, plugins config, UI look) you'll lose it all. You'll have to import all projects and configure it all over again.
I had the same problem but from time to time I do full workspace file-system backup and restore from it when such crap happens.
From what I have observed on backup restore so far, this particular problem may be in configuration jboss server in eclipse and files/plugins related to it. In other words if you don't have backups, try deleting and rebuilding your servers definition in eclipse before you'll delete .metadata dir.
If you go to file --> C:\Users\yourusername\wildfly-10.0.0.CR4\standalone\deployments and delete your projectname.war file, server should be able to restart.
I was getting the same error message, turns out it was because something went wrong in the deployments folder of JBoss, it wasn't even allowing me to delete my project ear folder from deployments.
My solution was, unzipped another instance of JBoss and pointed my Eclipse to this JBoss and then it worked fine.
I had the same problem several times in my windows 10 machine. Since I did not have admin rights it was a hectic process to troubleshoot this issue. Simple fix would be moving JBOSS_HOME closer to root. However, you need to do a proper restart of your eclipse. I rather recommend a complete restart of your computer because after all you are going to change JBOSS_HOME in windows environmental variables.
rather old...but still takes place in NEON version of eclipse and Wildfly.
and the problem is that Eclipse didn't stop normally the webserver.
(Something very usual for Tomcat at least I do most of the work)
Solution:
I opened the "Debug" presentation. I killed the process. ( and cleaned-cleared the Server - just in case).

What needs to be set up on Unix for a java web client?

I created a client using proxy in Oracle JDeveloper to call web service. JDeveloper deployed automatically and the code works well under windows environment. But now I'm required to migrate the code to unix server. I deployed the project to a .war file and copy it to unix which cannot be executed correctly using "jar" command.
Could anybody give me a whole picture or a high-level step-by-step instruction about what I need to set up to execute war on unix? I'm new to this area, and for now I got some suggestions like installing a Tomcat first.
What I have now:
1. a war file including .class, .java, WEB-INF, META-INF, MANIFEST.MF deployed from JDeveloper
2. JDK 1.6.0_25 installed on unix usr/java/
3. Tomcat installed on unix, but not under bin or local or usr directory(is it ok?)
Some specific questions:
1. what else do I need?
2. where to drop the .war?
3. do I need to unzip or re-compile the war?
4. how can I run the main class in the war?
Errors poped-up now:
1. cannot find main class
2. I tried to un-zip war and compile the class including main, and get "cannot find symbol" for the webservice specified classes' name.
Thanks to whoever attempt to help!
Even though this question probably should've been asked on ServerFault instead of here, sounds like you got all you need. Try dropping the .war on tomcat's webapps directory.
You should be able to just drop the .war file in $CATALINA_BASE/webapps and tomcat should pick it up when you start it.
$CATALINA_BASE is where you installed tomcat, unless you've configured tomcat for multiple bases.
You only need a war file if you are developing web application. From what you describe, you need to create a zip file which contains all the libraries and classes you need and copy it to Unix. Then you unpack it and execute it using java command.
Alternatively you can create a jar file with all dependencies included using Maven Shade Plugin and execute your code using jar command.

Categories