commiting the deletion of Java files and the containing package in Subclipse - java

Lately we had to switch at work from Subversive to Subclipse because we needed to upgrade to Java 11 and Subversive is no longer supported in recent versions of Eclipse. This has worked somewhat fine, but we're encountering problems when trying to delete files sometimes. For example, suppose you have the below Java package tree that you want to delete with no other packages or files inside the tree.
package
|---file1.java
|---file2.java
The problem I encountered is that no matter how I commit the deletion of this, it causes problems with the subsequent update by my coworkers. I have tried to commit the entire delete operation at once, and I've tried commiting the deletion of the Java files and of the package in separate commits. No matter how I commit it, my coworker ends up with his local work copy that he's updating in a broken state.
Turns out that when he synchronizes with Subversion, for some reason some of the commits get squashed in a single commit of the deletion of the package, with no deletion of the underlying java files. When he then tries to update that deletion to his local work copy, it only half deletes the files: they still remain in his Eclipse project explorer view, but they are successfully deleted in the Windows file system.
Because they remain in his Eclipse project explorer view, he gets warnings and errors related to the deleted files such as import statements that don't resolve and build path errors. However, because they are removed from the file system, Subclipse can't update them because as far as Subclipse is concerned, his local work copy is up to date! He has to recreate the files in Windows Explorer manually and then is able to override and update to fully get the changes in.
We also have the problem that some of the changes we commit, when synchronizing, appear to belong to random older commits changing that file, even if they are over a decade old, with multiple machines weirdly enough resolving the changes to different commits. Weirdly enough, a committed change often only gets partially resolved to an older commit, usually only 1 or 2 files, with the rest of the changes resolving to the recent commit.
We think these issues could somehow be related. Is this a known issue with Subclipse in certain environment? And if so, how do we fix it?

Related

Intellij Compiled classes not reflecting changes to java files

I have a maven project written in Java. I was able to make changes to code and see its updates until the beginning of this week. For past 2 days however, I am seeing a strange issue where no matter what changes I make to my java files, the compiled classes in target are not reflecting the changes and somehow seem to point to an older version of the compiled classes. I deleted target, invalidated cache, deleted .idea, changes the project folder to a different location and pulled again from git and nothing worked. I tried all comments listed at: Intellij IDEA does not detect file changes
I have Intellij version - 2022.1.3
Still no solution. I am not sure what is causing this issue. Any assistance in this would be greatly helpful. Thank you.

Worklight/MobileFirst Application Temp and Working Directories for Studio, clearing

With the Worklight/MobileFirst Studio application development for local development, I see many temporary or working files. My main issue, I may develop Java code for the server side used by an adapter and I assume that is pushed to the war file. But I sometimes don't see the change reflected. And sometimes I am working with the desktopbrowser/common web-application and I don't see those changes reflected. I may do a clean and build-all and Build All Environments.
I finally just scanned my entire Mac hard drive for those App-common and App-desktopbrowser files and found several. When I delete all of these, it looks like the working directory or cache issue is cleared up. I assume these are used internally and not documented. But I was curious if there is a clean way to delete these? Also, this is an older version of Worklight, will the same issue exist with future release? But at least I commented on directories you may not know about.
Here are the file paths that have a war file or wlapp file. Deleting these fixes my caching issue but is there a better way?
My version of Worklight: 6.2.0.01.20150430-1522
berlins-imac$ echo $TMPDIR
/var/folders/dl/abcgq/T/
Delete the wlPreview and wlBuildResources
There are cached files here:
/Users/user/Documents/workspace62LunaNewNew4/WorklightServerConfig/servers/worklight/workarea/org.eclipse.osgi/bundles
rm -Rvf ./75/data/temp/default_node/SMF_WebContainer/MyApp/MyApp/widget-resources/MyApp-common-c2713f1cefc5f5f35bec867386f2344632197fcf
cd /Users/ap123User/Documents/workspace62LunaNewNew4/WorklightServerConfig/servers/worklight/apps/myApp*
You can safely delete these folders from the TMP folder in any way you'd like.
They get re-generated everytime you open Eclipse (with Studio installed). At least that's the case in newer releases of the product.

Changes to my classes in Eclipse are not reflected when I run the project

I recently wiped my disk, but I have numerous backups of all Eclipse-related files. Everything that I need seems to be here, but whenever I make changes to my classes, even after I quit and restart Eclipse, the changes aren't reflected when I run the program. The changes still have been saved in my .java files, but they don't get compiled when I run.
Things I have done:
Project > Clean (numerous times)
Project > Build Automatically is checked
I tried building manually several times to no avail
All my hot code replace options are enabled
Downloaded a fresh copy of Eclipse
Restored my old Eclipse folder from before the wipe
I should be using the same settings as before, back when everything worked, and I haven't changed any operating procedures. The project is a simple game, nothing outside the box. I checked the build path, the only things there are the old class files.
So that's my situation. Thoughts?
Not sure the reasoning behind why it happens, but a quick fix is to copy the class to a separate project, then copy it back. Fixed the issue for me.

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file "name of class"

I know this question may seems stupid since i cannot give a lot of infos about it, but I think that the problem has to be some kind of bug...
I have written a java program whith NetBeans 7.1, which now gets me this error when trying to run. 10 mins ago it was perfectly running, and i have changed nothing to the class the error refers to
Could this be some kind of NetBeans error? Maybe it is a well know problem?
It also got this exception in NB 7.2
'clean an build' and restarting NB didn't work
updating NB with the latest updates and performing 'clean and build' also didn't work.
So i renamed the cache directory:
c:\Users\userabcd\AppData\Local\NetBeans\Cache\7.2\index\
started NB, waited for it to finish 'background scanning' and pressed 'Debug project' and voila. The cache gets corrupted every once in a while :-/
EDIT: Added Solution B below.
Solution A:
Project Properties
Build >> Compiling
un-check: Compile on Save
Clean and Build
Notes A:
If you leave Compile on Save un-checked, you won't have this problem any longer for this project.
If you enjoy the benefits of the Compile on Save feature, you can re-check the option after you clean and build, and continue work on your project as normal.
Compile on Save is meant to save time by constantly recompiling your .java files into .class files in the background as you save changes to your source code. That way when you build or run your project, most of the compiling work has already been completed allowing you to run and test your code quickly, even for large projects.
NetBeans uses some fancy caching and versioning to avoid having to recompile your entire project every time you save a file. That's why the other solutions listed here will often work; they are ways of defeating this caching-and-versioning system when it occasionally fails, as it has above.
Solution B:
Create empty folder e. g. C:\Temp\mine
Create a new shortcut for NetBeans
with command line parameter in Target:
"C:\Program Files\NetBeans 8.2\bin\netbeans64.exe" --userdir "C:\Temp\mine"
When compile errors occur
(ClassNotFoundException, MethodNotFoundException, etc...)
delete C:\Temp\mine\var\cache
Notes B:
You'll lose all your NetBeans settings the first time.
Much easier to solve future compile errors caused by caching bugs.
Allows running multiple copies of NetBeans, one per userdir.
I got also this exception. My solution was:
edit and save mentioned class (.java file)
clean & build project
deploy to tomcat server
I just had this happen to me with Netbeans 7.4 Beta.
Things I tried:
Restarting Netbeans.
Clean and build.
Shutting down netbeans, renaming the cache dir, starting netbeans and waiting for scanning to complete.
What worked for me:
Making the source file writable and saving a meaningless change (inserting a space).
I don't know why any of the other steps didn't fix the error. Maybe it would have worked if I had done a clean and build after renaming the cache dir?
Its a very frustrating situation to be in - Hopefully this helps someone (perhaps a future me?).
The JDK says for ClassFormatError:
Thrown when the Java Virtual Machine attempts to read a class file and
determines that the file is malformed or otherwise cannot be
interpreted as a class file.
Perhaps a class file has become corrupted. I am going to do the standard IT support statement.
Have you tried restarting NetBeans?
Hope that helps
Got right the same thing with Netbeans 7.1.
Working on a project that works fine for several months.
Now I changed a bean which gets persisted with javax.persistence and now this exception got thrown. Reverted my few changes, clean and compile the project, reboot the whole system: still exceptions.
The curious thing about it: the generated .war works perfectly in a Tomcat at another machine.
UPDATE:
Today I got the same problem again and I couldn't recall how to solve it, but I found this post again. ;)
After a half hour I found the solution: Just change value of the property serialVersionUID, redeploy the app and then you can change the value to its original value and redeploy again -> working.
Seems like Tomcat is holding that class somewhere deep inside – deleting working directories didn't led to success.

Subversion on Eclipse

I updated a projected on my SVN using Subversion on Eclipse and there was a conflict. I resolved it by removing my version and just keeping it the way it is on the server. Now whenever I commit, it says there is still conflict. In the Team Perspective, I see zero differences! How can I sort that? I don't see how it still conflicts. When committing, it says the status of that class is still conflicted.
When I update, I get "At revision 21."
Btw, I run Mac OS X so I can't use Tortoise, and I won't use versions, its expensive.
Can I just overwrite the server with my file? This is really frustrating.
Copy the modified files out, revert on the parent folder above the conflicts, move the files back in. It's a pain but it works :)

Categories