I've been learning the basics of Spring MVC by writing a very simple CRUD app and running it with Jetty. (I've been following a mix of this mkyong tutorial and this journaldev tutorial)
When I run mvn compile it compiles without error. But when I start jetty with mvn jetty:run, I get
A required class was missing while executing org.eclipse.jetty:jetty-maven-plugin:9.2.11.v20150529:run: Lcom/mkyong/model/stock/StockDao;
Technically it's correct because I don't store the stock DAO at that path. It's at com/mkyong/dao/StockDAO.java.
But obviously something, somehwere, seems to be referencing it at that path it's complaining about? It's a small app and I've combed it several times and pulled out some hair in frustration trying to find it. I'm still incredibly new at debugging java so the verbosity of the errors is really confusing as well.
Here is the full source code of the app. Any thoughts on where the issue might be?
Thanks so much!!
EDIT:
Adding screenshots to address a comment below.
Github appears to lowercase parts of the word Dao in the filename, but they are most definitely all upper case on my local machine
The names of some public classes differ from their related source files. Change StockDao.java to StockDAO.java and StockDaoImpl.java to StockDAOImpl.java.
Related
I'm creating some rules to SonarQube where it will analyze a Android Project and raise some Security vulnerabilityes points on code.
I've already created a custom rule by Sonar Tutorial to create my own rules following the same structure, but I had some complications. For instance, when I tryed to run the test classes, I've found some problems to identify Android Classes and validate my rule, and after some research, I solved the problem, but seems like when I put my plugin on SonarQube and run it, the problem remains with the tool not identifying Android Classes (I coudn't comprove this because coudn't find a way to debug the web tool and see why the Rule is not checking).
By this, I need to know if I'm really doing this of the right way. Analyze with custom rules a Android Project directly by SonarQube can be done just following the Sonar Tutorial? Do I need of custom configurations inside my template or any other step to do it?
If beyond the answer or the instruction, someone could provide some documentation to help me, I would be deeply grateful.
Since now, thanks for your attention!
A wild idea just popped in my head to express a Maven project, which is described in pom.xml, with Java annotations in Java and generate "effective" pom.xml out of Java code with help of a maven plugin.
It looks like an obvious idea and most probably somebody tried to implement this and stepped on a pitfall, but I haven't found any attempt to do so on the Internet. So I just curious to ask. :)
At first glance it's apparent thought, because Spring and even EJB started with XML and now where is it?! Maven reached version 3 years ago and I don't see any move away from XML.
I am aware of Gradle existence but it's completely different system with its own strong and weak points, I want a light restyle.
To be fair, i first asked this question in the official GitHub-Repository of the example-project. However since i didn't get an answer for one week now, i felt that stackoverflow might be a better place to ask. I'll do my best to keep findings and updates in synch beetween these threads, so that the efforts made at one place or another are shared.
I am charged with the task to migrate a Oauth2 single sign on system to an inherited Spring-project. Therefore i decided to go with Spring Cloud Security. Sadly i cannot even get the most basic example to work, that is shipped together with Spring Cloud itself. I cloned the project from GitHub to my desktop and then run it from eclipse. I tried to run it with different arguments, to choose between different profiles: the official github-profile, which is included already, and a custom profile for our own oauth2-authentication-server. But all i can get are 403-errorpages on all routes. Here are some example urls, i tried out:
http://localhost:8080/
http://localhost:8080/dashboard/
http://localhost:8080/dashboard/login
http://localhost:8080/resources/static/index.html
http://localhost:8080/foo/bar (non-existent fantasy url)
Obviously i must have missed some instructions, but i don't know where to look. The console-output does not show any meaningfull messages, in particular there are no warnings and errors, this suggests that the application is running just fine.
Shame on me, i tried to reproduce the error on a different machine with a different eclipse-version installed. It turned out that my run configuration has been set up in a wrong way. Deleting it and setting up a new run configuration solved the problem.
unfortunately googling didn't help :(
I have deployed a simple project on JBoss5.x integrated in my Intellij IDEA.
I use some mvc frameworks with JSP pages.
So I run my project, works with it and when I edit any JSP I can just click "Run" >> "Update JBoss" >> "Update resources" and all my changes to JSPs will be applied without redeploying the server.
But this doesn't work with LESS files (LESS is for dynamic css). I cannot figured out why? Any hints?
PS: less file is mentioned on JSP correctly, so it is applied normally, but changes to it cannot be applied without redeploying.
Try deploying the files directly, not through IDEA, to see if it's a problem of your IDE configuration or a server-side issue.
If it's a server-side problem (the files don't get deployed even with the direct deploy), then try checking stuff like permissions on files, if the deployer works and if it's listening for new files, etc.. Also some files cannot be "hot-deployed" without actual redeploying of the whole module of your application.
If it's a problem with your IDE then try checking your configuration. Here are some links which should help you get started:
http://www.jetbrains.com/idea/training/demos/JBoss_server.html
https://community.jboss.org/thread/202446?start=0&tstart=0
How does Intellij deploy to JBoss?
If you have any further questions, please ask in the comments. Cheers!
Edit: I am not an expert on hot deployment, nor can I specify exactly which files can or cannot be hot-deployed, but AFAIK you can hot-deploy changes to your classes which do not change the structure of your class. This most of the time means that you can change the body of a method and hotdeploy it without any problems, however if you rename it or add new methods completely you won't be able to hot-swap them. Another thing is file discovery - files which are discovered during the startup phase of the server cannot be hotdeployed without a restart or some other way which tells the server to reload them. This might be your case.. I hope that someone will specify these hot-deploying limits better.
I want to compile multiple java files in my Application without restarting Weblogic and Tomcat. Otherwise, this takes a lot of time. For this I got one Hotswap plugin in Eclipse, but this is not working in all the cases. It says it works for single file compile. Even if I use that it is not working in all the cases.
Is there any other way that I can do this or is there any other plugin/script/software which can help me in this?
If there are some open source ones, it will be very helpful.
Thanks in Advance.
One thing is compiling the classes, but you also need the JAVA VM to reload the classes and use them, which is called hot-swapping. For the best available hot-swapping of classes you'll need something like javarebel. It allows you to hot-reload a lot more types of code-changes than the regular SUN JVM. If you run your deployment in exploded-mode you're home free, and can test any code change in a second or so. We're fairly test-driven, so I only use javarebel in that short phase when I assemble the whole application, but it works really well.
The Java HotSpot VM does this automatically, but not in all cases...
First, you must be running a "debug" session, not a "run" session.
Next, some changes will force a restart. The basic idea is that if the interface to the class change (the method sigs, not an actual Java interface), the VM can't replace the class contents inline.
You shouldn't need a plugin for this, just a recent-ish VM.
This happens under several circumstances like
adding methods
removing methods
changing method signatures
changing the class hierarchy (superclasses, implemented interfaces)
It can also happen if you introduce an error into the class. (For errors like mismatched curly braces)
When you save a Java file, eclipse compiles it. If there is an error, eclipse inserts an exception throw to indicate that there is an unresolved compilation error. (It does this so when you run you don't just see the last successful compilation, making it obvious you have a compiler error)
I don't know Eclipse, but I do use Netbeans. Netbeans does this pretty well. The latest version even has an option to automatically recompile when you save a java file.
I know this doesn't exactly answer your question. You can probably use both Netbeans and Eclipse depending on what part of the project you're working on.
EDIT:
With Tomcat you can reload the web app. This is really only useful if Tomcat is looking at the new class. If your project is compiled to a build directory first and a WAR is then created from this you can go into Tomcat and install the web app and instead of pointing at a WAR point at the build directory.
In Tomcat you may have to put a site config file under tomcat/conf/Catalina/localhost. The contents of this file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="C:/Projects/MyWebApp/build/web" path="/MyWebApp"/>
Instructions for reloading here:
http://www.cs.ucl.ac.uk/teaching/java/tomcatfaq.html#changeservlet
If you do this a few times though Tomcat will run out of memory. This is because of something called PermGenSpace. Read up about it if you want to know more. The solution is to increase the JVM memory, the PermGenSize (with -XX:MaxPermSize) and finally restarting Tomcat occasionally.
EDIT2:
If reloading the app causes you to be logged out you may be able to easily get the container to serialize your session data to disk by adding 'implements Serializable' to some of your classes. Then you should not need to login after reloading the app.
I agree that it is very tedious to redeploy all the time when developing.
I would suggest you look into MyEclipse which has a very good hotdeploy mechanism which works well with Tomcat, and which is quite affordable and has a 30 day trial.
The stock Java EE mechanism in Eclipse for redeploying to servers is nowhere as fast.
I guess I don't really see where the problem is. Here is what I do and the changes load almost instantaneously. I have an Ant script that compiles the .java and .jsp files for me, puts them in the appropriate directories under webapps and changes the web.xml file if necessary (or at least touches it to notify tomcat of the changes). If you need help on doing any of that with Ant, I'd be happy to help. Btw I do not use WAR files for deployment on my testing machine. That would be a lot slower I guess.
very easily done if you read this page:
See http://blog.redfin.com/devblog/2009/09/how_to_set_up_hot_code_replacement_with_tomcat_and_eclipse.html
Thank you Dan Fabulich