I have a multi module maven project containing a common model project and two web projects( 1 for the site uses jsf, and another is set of axis based web services used to collect data from the user)
When I deploy to tomcat I deploy it as 2 war files, the model project is compiled as jar and is included in both war files.
Lately I have been getting a lot of permgen error. I am wondering if it is because I have these 2 war files each of which contains required libraries like HIbernate, Model project, and a bunch of other libraries needed for the individual projects.
My question is am I doing it right(I don't think I am)? and what is the best way to deploy a multiple web projects which depend on a common model project?
I have no experience of Maven, but I recently worked a lot with Java EE and in particular tomcat. I never got tomcat to work together with Eclipse (I have worked in Eclipse for Java projects since I started learning Java four years ago). I did a series of assignments and projects for a class at my school KTH. We had to use OpenEJB together with tomcat for the assignments but it was really messy to get it to work in Eclipse. So during the first assignments I just wrote code in a text editor and compiled from the terminal (OS X) and it was really ineffective.
However I got tip from a class mate that Netbeans had good support for Java EE. So I switched to Netbeans and used Glassfish and JSF. Switching to Netbeans proved to be a good choice. A really nice feature with Netbeans is that it can generate entity classes automatically based on your tables in your database. And then based on those entity classes Netbeans can generate JSF pages (controllers) for you. This makes it really fast and nice to develop Java EE projects. I followed this excellent guide:
http://netbeans.org/kb/docs/web/jsf20-crud.html
I hope this can help you! Sorry I couldn't give you a more precise solution.
Good luck!
I guess the answer is to package it as EAR file instead of WAR as you can package the jar files used commonly by the two web projects. only thing is I won't be able to use tomcat, time to look at Application servers will also try TomEE per David Blevins's suggestion.
Related
Hi I'm totally new to development. I'm trying deploy a web application on a local server like glassfish/tomcat. Backend of the app is written in Java and ui is created using HTML/css/js . I'm using maven as well. I'm not able to find a way to get this running on intellij CE .
Apparently this functionality is not supported in CE. Can someone suggest a turnaround or a different IDE as good as intellij idea. I've tried eclipse but I didn't find it completely useful
Thanks
There is no IDE as good as IntelliJ. JetBrains makes the best IDEs on the market.
No, I don't work for them. I have no affiliation at all. I'm just a satisfied customer for the past 13 years who is happy to buy a license with my own money every year.
The comparison matrix for community and ultimate editions makes it clear: You cannot deploy in IntelliJ without a licensed copy.
You can create a WAR file and deploy it manually to Tomcat or Glassfish if you wish. Why not just do that?
I will compliment you on how you are approaching the problem. IntelliJ, Maven, and your other choices are very good.
If you feel up to the challenge, you can look into Spring Boot. You can run an executable JAR and leave Java EE app servers behind. IntelliJ community can easily run a Spring Boot app.
Choosing Spring Boot does mean leaving EJBs behind. Everything you can do with Java EE is available in Spring Boot. You'll be using POJOs.
I am working in a University project which involves developing a Java-based JSF WebApp. For the development I will be using IntelliJ IDEA and Maven or Gradle (at this point I don't care which one, any of them will fit).
I will also be using JavaScript in the project and I would like to manage its dependencies with Bower.
I could easily throw a js folder inside the webapp directory. I have seen many examples of this, but I do not like it as an approach.
What I want to do is separate the server side implementation from the UI implementation. So, I guess that means having two modules in IntelliJ IDEA, one containing all the Java-based server implementation and another one containing the static web files.
How can I accomplish this using IntelliJ IDEA and/or WebStorm if necessary? Actually, can it be done? Any suggestions welcome/appreciated.
I'm at the point in my application where I would like to have an HTTP Server embedded into my project that updates the page in real-time using AJAJ(Similar to AJAX). However, I have no idea where to begin and the amount of tutorials on this subject are fairly limited, so I decided to go with a name that I've heard quite a few times before, Jetty
So, I downloaded Jetty and read through some documentation, and I'm staring at their beginner tutorial asking myself, "Which one of these f*kin jars do I use?" There's like 9,001 of them. Not to mention that there's like 1200 folders that all contain 1500 more jar files each.
Okay, I'm over exaggerating, but take a look.
It's fairly, uhm... confusing. This is much different than most libraries that are a single jar file, this is just... insane.
Anyway, I'm trying to figure out what all I need to be able to use JQuery, AJAX(AJAJ), and basic HTML features.
I'd suggest you to start with this simple tutorial and jetty-all jar
Embedding Jetty Webinar recording
Embedding Jetty docs
jetty-all different versions downlad
To followup on Gas's answer.
jetty-all doesn't have 100% of Jetty.
It used to, hence the name.
However, today its impossible to have 100% of jetty, as many components can conflict with each other.
If you use maven, or gradle, or ant+ivy, then you'll likely want to depend on:
org.eclipse.jetty:jetty-webapp
org.eclipse.jetty.websocket:javax-websocket-server-impl
let the transitive nature of those build tools pull in the rest.
This would get you "started" easily enough.
There are also plenty of example projects that use embedded jetty.
See:
Embedded Jetty: with JSP enabled
Embedded Jetty: with various WebSocket configurations
Embedded Jetty: using Servlet 3.0 features
Embedded Jetty: using Servlet 3.1 features
Embedded Jetty: various Logging configurations
Some use 100% embedded jetty (without a war file, or WEB-INF, or web.xml), some use a war file built elsewhere.
Jetty uses maven so it can participate in the global central artifact repository, and that we have 2 developers on Jetty that are also developers on Maven.
If you want to manage the dependencies yourself, then you will need to know intimately the purpose and role/purpose/relationship/requirements of every jar file that you are going to add into your project. (and answering that is way out of scope for stackoverflow)
You have many build tool options to make managing the dependencies easier:
Apache Maven
Gradle/Grails
Apache Buildr
Apache Ivy (an add-on for Apache ant)
Groovy Grape
Scala SBT (for working with Scala on top of Java)
Leiningen (for working with Clojure on top of Java)
Maven isn't required, you could use any of the above tools.
Tip: Maven and Gradle are the best integrated in various IDEs (like Eclipse IDE and IntelliJ)
I am writing a java web application using spring, hibernate and mysql. The applications is getting larger so I want to break it into smaller parts e.g. smaller projects, components or which ever way possible. For example I have login and image uploading functionality, I don't want both of these to be in a single code base or project. I want to be able to use these separately almost like separate services independent of each other. Is there a way of doing this e.g. convert the image uploading functionality into a jar and then reference this jar in the actual project? How are the Enterprise projects split?
Hope it make makes sense and please advice if I am going the right direction as it is my first project? It would be nice if someone can point me to a mini example or recommend reading.
thanks in advance
Try with OSGi. If you are using Spring, then declarative services and possibly blueprint container in OSGi specs are what you need to leverage what you have done until now.
Try reading OSGi in Action by Richard S. Hall, Karl Pauls, Stuart McCulloch, and David Savage to get an insight in this technology.
OSGi is a modularazied approach for java software development that enforces loosely coupled services creation. Quoting from the OSGi alliance website:
OSGi technology is a set of specifications that defines a dynamic component system for Java. These specifications reduce software complexity by providing a modular architecture for large-scale distributed systems as well as small, embedded applications.
Hibernate supports OSGi as it can be seen here. As for the OSGi implementation, I would recommend Equinox, but many other valid OSGi implementations exist. Since your project is a web application, you could check also Virgo
Virgo from EclipseRT is a completely module-based Java application server that is designed to run enterprise Java applications and Spring-powered applications with a high degree of flexibility and reliability
and in particular,
supports vanilla WAR files, with all their dependencies in WEB-INF/lib, and Web Application Bundles, that import their dependencies via OSGi manifest metadata, via the reference implementation of the OSGi Web Container specification, based on embedded Apache Tomcat and configured using the standard Tomcat server.xml
I ended up using maven modules and maven dependency management capability. I created a separate maven project and kept adding maven modules as needed e.g. created a module for image uploading, one module for common libraries and so on.
Each of these modules are then packaged to jar files. I then import each one of these jar files using maven dependency to my main web project.
It seems to have worked great so far. Hope this is helpful for someone else, too.
I'm using Eclipse with Tomcat 7.0 and everything is working well. I have 3 webapps I'm developing and all 3 apps use the same set of source code from the same package (e.g. com.mycompany). So far I have 3 copies of the package, one for each web app, in each respective project folder. Each web app is intended to be standalone if needed.
What is the best way of configuring Eclipse Helios to have each dynamic web project use a shared library, which is also under constant development as well?
I think this can be an answer?
Link additional source
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-WorkingWithExistingLayout4.htm
Well...it's a simple enough answer...just keep the library in a single folder and import that into your project using an absolute path...however, note that this will be a problem when you are deploying the application in a different environment...