Deploying *.ear file onto Liferay (JBoss) - portlets not exposed - java

I'm trying to deploy .EAR on Liferay (running on JBoss), I put .EAR to JBoss deployments folder. My structure is:
lib (some libraries/modules)
META-INF
WAR (it contains all Liferay specific libraries from auto deploy)
JAR
According to console, deploy is correct. JAR is running (I have some methods with Timers and they are working properly). But I don't see any portlets from WAR that I can add, but according to console WAR is deployed. They are simply not exposed to Liferay. I know that the .EAR is like a closed structure.
I am wondering how to make portlets available to Liferay?
I would appreciate any ideas, thank you.

Currently there is no standard way to deploy portlets (WAR) inside EAR. Liferay won't detect them. Your WAR with portlets must be deployed separately.

Related

Packaging WAR in another WAR (Maven)

I currently trying to migrate an application to Maven. Since the previously, the application was mix of web projects (with JSPs and JSs) and other "normal" projects. I am having a hard time packing all those modules into one. For the web projects, I chose the packaging as WAR and others I chose JAR. Now I am trying to make a master WAR file, that I can eventually deploy to Tomcat. But from I read, packaging a WAR in another WAR is not possible. And also I read that making the packaging as a JAR is doable. I just wanted to know is the first option totally out of the question? If JAR and a WAR is the only option, where do I put all the web stuff (JSP, JS, images etc.). Currently the WAR+JAR combo creates a final WAR file that is only 3KB big, which hardly looks realistic. I know I am missing something, but not sure where to look. The application is about 14 years old, so doesn't really conform to any framework that I can think of. EAR is not an option either, as the application has to be deployed on Tomcat. I wish TomEE was an option! :(
All your "JSP, JS, images etc" should go in a WAR file.I have an application packed in a WAR file that is running with all this in a hosted Tomcat. You can package the entire application as Java EE except there are Desktop applications.
Just take your 20 wars and deploy them on the Tomcat. There is no need to bundle them into another artifact.

Why jar can not be deployed on Apache tomcat or any other application server?

Questions was asked in interview that can we deploy jar on tomcat?
My answer was no, so counter was why like so.
Kindly help
Thanks in advance
To deploy it succesfully, you have to create a war file instead of a jar. See the differences:
jar (Java archive) contains libraries, resources a accessories files.
war (Web archive) contains the web application deployable on any servlet/server
ear (Enterprise archive) is all above can be packaged deployed on any server/servlet as well
I don't know the background of your development. In case you use Maven, just change the packaging.
<project>
<groupId>com.example</groupId>
<artifactId>exampleProject</artifactId>
<packaging>war</packaging>
<version>1</version>
....
</project>
In the interview you'd simply answer that the purpose of jar is not to be deployed on Tomcat. There is war for it. Moreover war contains the web-content like HTML, CSS, JavaScript, JSP, images etc..
you can not deploy jar in a stand alone Tomcat container, but it is possible to deploy web application as executable jar in embedded Tomcat (example - using Spring boot with embedded tomcat as container)

How to Deploy Java EE Project which reference external JAR files in weblogic

I have a web application which consist of JSP pages, Servlet and Consumes Web Services.
It also references apache axis and excel libraries.
Now I want to deploy my application directly in Weblogic server
How do i do that.Whcih archive shud i make WAR or JAR??
ALso how to ensures that it covers all the referenced libraries.
I have made my application in Jdeveloper, but I dont want to deploy it using Jdevelper..
I would package my solution as a .war file, containing all dependent .jar files.
That way your solution is self-contained. You can deploy to an app server containing other apps with their own versions of your libraries (dependent or developed). If you put the dependent jars directly into the app server (as you can do), then you're forcing those versions on all applications deployed, and that could well cause you grief.
The downside is that your developed .war file can become sizable. It's not normally a major problem, and I wouldn't worry about it until it's identified as an issue.
A JAR-file cannot contain a JAR-file, so that option is out. Since you mention JSPs and servlets a WAR would seem the appropriate option, although an EAR with a WAR and several JARs could also be a way forward...
Cheers,
Consider a WAR with your JAR files in WEB-INF/lib. Or, create an EAR with APP-INF/lib folder.

WAR vs EAR for web application with no EJB?

I have a Java EE web application that does not make use of EJBs. I am targeting Jetty/Tomcat for deployment some of the time and thus need a WAR packaging. However, I am also target JBoss and Websphere some of the time.
My understanding is that full-blown Java EE application servers can take either EAR or WAR formats. When would I use one over the other and why? I understand they are both standard compressed file formats and I have read 10 different snippets that try to explain them (including this one), but am no closer to understanding the pros and cons of each.
If you have only web modules - use WAR file.
If you have different Java EE modules - use EAR. Though you can deliver only web modules in EAR - there is no point in doing this (and you will need to do more complex deployment configuration)
The crucial point is if you need anything provided in an EAR file (which may contain said WAR file). If so, then it makes sense to deploy as an EAR.
It can also wire up some of the configuration you need to do manually in Tomcat etc. A typical example is the URL bound to the web application, where you need to override the default heuristic with a container specific configuration file for a WAR, but you can put it directly in the EAR configuration file.
Also, during development WARs can frequently be hotdeployed directly in exploded form, where EARs must be unpacked and deployed. For Glassfish from Eclipse the difference is quite noticeable.
In J2EE application, modules are packaged as EAR, JAR and WAR based on their functionality
If You are using only Servlet, JSP, GIF and HTML files. Then use .WAR
WAR:(Web ARchive) Web modules which contain Servlet class files, JSP
Files, supporting files, GIF and HTML files are packaged as JAR file
with .war (web archive) extension.
If you are using different different JAVA EE modules like (EJB + Servlet, JSP, GIF and HTML files + Other technology). Then use .EAR
EAR: (Enterprise ARchive) All above files (.jar and .war) are packaged
as JAR file with .ear (enterprise archive) extension and deployed into
Application Server.

where to copy servlet files in apache tomcat server to work fine with web?

Can anyone guide me how to get Servlets working in Apache Tomcat server? I can run the Servlets from Netbeans without problems, but I don't know where to put the class files in Tomcat.
In tomcat:
class files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/classes
jar files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/lib
(and if course you'll need web.xml in WEB-INF)
They go in Tomcat/webapps folder. There are several ways to deploy a JSP/Servlet webapplication on Tomcat. They are all described in Tomcat Web Application Deployment HOW-TO.
If you already have developed the webapplication in Netbeans, then Netbeans should already have build a WAR file of it in the /dist folder. You just need to drop the WAR file in Tomcat/webapps folder and Tomcat will automatically deploy it during startup (or even while running, this is called hotdeploy).
If you want to develop without an IDE and/or don't want to create a WAR, then you just need to put a folder representing the context name in Tomcat/webapps, e.g. Tomcat/webapps/contextname. It will become the public web content. You can drop all JSP files and other static files in there. Then, for classes you need to create a Tomcat/webapps/contextname/WEB-INF/classes folder. There should go the package structure.

Categories