We have a vast Documentum application which I have deployed in Tomcat. The code is being maintained and compiled in Eclipse IDE.
It is very hard to track where and what data is going through which code, I have a decompiler plugin to help with this task, but it does not work with most of my code as the classes are without a main method. These classes cannot be decompiled by the plugin.
Is there any method to overcome this? So that I can see the flow of data from JSP to backend class to repository, and vise versa.
Sure. You can either connect to tomcat using remote debugging (see here) or run tomcat into eclipse itself. You need appropriate plug-in for this but typically standard eclipse distributions for server side development already have one. Open Servers view, create new server, follow the wizard and you will be done in a minute.
JPDA is a java standard tool.
It is designed for use by debuggers in any environment on any java application.
For details you can look at
http://www.ibm.com/developerworks/opensource/library/os-eclipse-javadebug/index.html
http://www.ibm.com/developerworks/library/os-ecbug/
The 1st link gives a detailed view with screen shots of remote debugging using eclipse.
Related
I have an Eclipse plugin that works as a light host and it is possible to run applications on it. I am trying to improve the development process and thought about using JRebel.
According to what I am reading in the FAQ, the JVM runs happily with JRebel jar as a plugin and any class declared for JRebel is reloaded at change, while the appropriate application jar is running.
So, I "simply" launch the Eclipse or IntelliJ with JRebel plugin for IDE, launch the host in it with JRebel plugin for JVM, install applications in host, launching their jars again with JRebel plugin for JVM, and I happily see the lines of code connected with running jars and classes reloaded at change.
But... Reading JRebel https://zeroturnaround.com/software/jrebel/download/ , along the bottom of the page I can see servers and other applications supported by JRebel.
I understand the need of support for IDEs, for JRebel must connect the lines of the source code, as I see them in IDE with the byte code, running in JVM. OK.
But what does it mean - server or other app supported by JRebel? If any jar can be run in JVM using JRebel jar as a plugin, as they explain in FAQ, where is the need for some special support? In other words, in what sense an application can be unsupported? In yet other words, our plugin and applications are not supported?
The core of JRebel enables classes to be reloaded so you see results as if you restarted the application. This includes accessing class info via reflection and other JDK tools that operate on class metadata.
As this hints, the main problem with only doing class reloading is that almost everything is caching intermediate results and computing some information only at the start of the application. Assuming a class or framework configuration file does not change at runtime is usually a good one.
For this reason, JRebel must provide additional integration to preserve the illusion of class reloading as most applications these days depend on a large number of libraries, application servers and frameworks. For example, a spring application would scan for components and do wiring of beans only on startup. A simple class reload isn't enough and the additional integration must therefore re-scan and re-wire beans if needed.
However there are also a lot of libraries that don't need additional support. The term supported means that a specific server or framework has the required integration and has integration tests running daily. If any library or framework is not listed, it means it's untested or requires no additional integration.
As a side note, JRebel works on compiled class files so an IDE doesn't need support aside from the debugger. Anyone can develop java with vim and use JRebel just fine for example.
I have a Java Spring Boot Application, and I build it with Maven. With
spring-boot-maven-plugin,
I can create fat, executable jar file.
Then I copy it to the remote server and run. But sometimes,
I change only one line or event one word in my code and I had to do whole build/copy step again. I'm sure that I'm doing it wrong, but I couldn't find another way that more efficient (Like capistrano in Rails).
At this point, I'm planning to clone source code to server, push from local, pull from remote, build and run approach. What is the correct (or elegant) way of doing this deployment?
For automatic build and deployment process (continuous integration), you can use Jenkins. Refer this documentation for more details: https://jenkins.io/doc/
I would say it depends where are you trying to do it.
The best and the most agile way to do it for a controlled environment is surely a CI-CD (Continuous Integration and Continuous Deployment) pipelines, which complies-builds-tests-deploys your code against every commit made to the source code BUT it may be too slow to use CI-CD for a development environment where you had like to have a shorter feedback cycle and faster feedback to see how the code is progressing.
However, if you are talking about development environment, I will hit another chord and ask you why to deploy to the external server AT ALL while developing. When you use Spring Boot, which helps you develop a self-contained application, you get the Tomcat Server embedded with it for free. That gives you the choice to run the code anywhere you develop and test to move forward.
A simple maven goal - mvn spring-boot:run can make the code run anywhere you had like.
There is another magical library available in Spring-Boot, known as Devtools, which is meant to support agile developers. The library once in the app classpath, performs hot-swapping of byte-code to auto reload of code into the running application (running locally with embedded Tomcat) as soon there is a saved change. This is one of the coolest gadget that a developer can have.
Use of Spring-Loaded (or JRebel for non spring-boot apps) libraries can also help a developer do hot-swapping of byte code to load changes in running application as soon saved.
I hope it helps.
I work with multiple XPages Libraries that contain all of our Java code outside Domino Designer. I'm using Eclipse Mars and have setup the Xpages SDK to make this work. Most of the Java code is called from Xpages (or managed bean inside a nsf). But everytime when I make a change in our Java code, the change is not picked up. I need to "restart task http" on my Domino development server everytime.
When I turn on debugging and change Java code, all changes are picked up immediately but it will crash my server when I change a return type or add a new function or move classes between packages.
Is there an easier way to develop in Java without restarting the HTTP task everytime I make change (or prevent those server crashes)?
When debugging from Eclipse, if you use the Stop option, it crashes the server. If you use Continue, it works fine.
In terms of hot-swapping code, there isn't a way currently. JRebel can be used with some servers, but I don't know of anyone who has got it working with Domino.
It's not specific to plugins though. The same is true of any shared Java code, presumably because it's compiled to byte code and cached. See this blog post where I had issues with SCXD http://www.intec.co.uk/single-copy-xpage-design-some-learning-and-why-its-not-for-me/. There are various tell http osgi commands including ones for bundles etc, but I haven't found one that successfully reload plugins. I think Cameron Gregor did some investigations as well, but also couldn't find a way. It's one of the issues I highlighted with OSGi development on Domino on my blog http://www.intec.co.uk/from-xpages-to-web-app-part-seven-osgi-application-development-introduction/.
I'm working on a project for class that involves me developing a plugin for an existing application. However, I struggle with GUI programming and the inability to use a debugger or print statements has made the process very not fun. Is there any way I can debug this thing other than trial and error?
The plugin (as well as the main program) are written in Java, and I'm using NetBeans. I'd prefer to stick with NetBeans but would be willing to move to a different IDE if necessary.
You should be able to use remote debugging as described here http://wiki.netbeans.org/FaqDebuggingRemote
This involves running the original JAR from the command line with the following parameters `"-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n"
This would then allow you to attach the Netbeans debugger to the running process.
I currently have Apache HTTP Server, but I'm guessing I'll need Tomcat (and then have to configure it in a way that makes it not open to the public), a Java JDK (which I already have, but should probably update), and an IDE (I have Eclipse). But what else should I have or know before starting?
Lets see... you'll need:
A JDK. Preferably the Standard Edition, unless you plan on using GlassFish as a J2EE server. If you do use the standard edition, you need to include the jars from your servlet container/J2EE stack to access J2EE libraries.
A Servlet container. Apache Tomcat is a popular one, and Eclipse already has integration support for it. Keep in mind that Tomcat is not a complete J2EE stack... you need something like JBoss Application Server or Apache Geronimo for that.
(Semi-Optional) A web server. Apache Web Server surprisingly works well with Apache Tomcat or Apache Geronimo... it's almost like they were made by the same people! Eclipse has built-in support for Tomcat and doesn't appear to require a web server because of it. I could be wrong, though.
(Optional) An IDE. If you use Eclipse, get the version for Java EE Developers.
(Optional) A Database. MySQL and HSQLDB are popular ones for Java, at least for small to medium applications. Keep in mind that you also need to download the JDBC drivers for your database.
(Optional) A revision control system. Even on a single-developer project, a revision control system can save your hide if you accidentally remove code or a file that you shouldn't. There are several choices here; Subversion is my personal choice, along with an Eclipse plugin for it, such as Subclipse.
I'd recommend having a database server installed as well- you can go pretty far with the various pure Java implementations, but anything significant will probably benefit from having a copy of MySQL around.
I'd also get some sort of version control going- tortoiseSVN works really well for windows. Even if you're just goofing around for yourself, getting in the habit of using it will save time and heartache down the road.
If you're trying to stay pretty simple you have everything you need; a servlet container.
The IDE of course helps.
I would recommend Eclipse's Web tools project as it will allow you to code, and then hit a button that will put that code on tomcat all from the IDE.
http://www.eclipse.org/webtools/
As Bogdan mentioned maven is a dependency management tool but depending on your level of comfort I'm not sure if you want to muddy the water with that yet.
Another project that uses Maven is appfuse (http://appfuse.org/display/APF/Home) and will help you get off the ground quickly for generating a webapp. It will give you a webapp, a database, unit tests, dependency management, and a good skeleton to structure your project off of.
So, if you're just wanting to play around with some .jsps and a servlet or two I would stick with the IDE, but if you're comfortable with web applications, MVC, and build tools I'd recommend appfuse.
That's all you need from the tools.
Then, you need to google some tutorial on using servlets and jsp pages. Even documentation bundled with tomcat is good enough.
You'll probably also want a database like MySQL or HSQLDB. You could replace Tomcat with Jetty which is often easier to get class changes to reload without restarting the server.
You can do everything from within NetBeans if you're willing to switch IDEs (it's a relatively painless switch, but you might be able to create a similar setup in Eclipse). There's a Tomcat plugin for NetBeans that allows you to create, edit, run, and debug servlet and JSP web apps all from within NetBeans. There's a starter tutorial here. When you install the Tomcat plugin, you get lots of good example servlets and JSPs as a bonus.
I would go for maven.
It will give you a quick start in configuring your project (by using archetypes) and it will manage your dependencies.
Install it and run the archetype command to create your project.
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
After that just use the maven eclipse plugin to configure your eclipse environment for that project (http://maven.apache.org/plugins/maven-eclipse-plugin/).
I currently have Apache HTTP Server, but I'm guessing I'll need Tomcat (and then have to configure it in a way that makes it not open to the public)
For simple Java based web applications, you need not have Apache installed unless you are too concerned about performance and want to gain by letting Apache serve static resources.
But what else should I have or know before starting?
A good IDE is most recommended, otherwise the development will become painful. Use a simple database as people have already suggested. I would go with MySQL because its neither too complex for a webapp nor too trivial.
Instead of Tomcat I recommend Jetty, that is also a Servlet-Container. In my experience it's easier to setup and maintain. Good enough to test your application.
Other than that you need a JDK (naturally). A database is optional, but if your web-app wants to save data it's the best option.
Step 1:you need to have J2EE installed in your system if not download it from http://www.oracle.com/technetwork/java/javaee/downloads/index.html here.
Step 2: Should have Apache TomCat server to run your web project on your system locally(local Server).
installation steps https://www.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html go to this website.
Step 3:set Class path for java JRE.