folks,
i am trying to deploy a ear with a ejb in the ear root. the ejb has a persistence.xml file where the tag has to be a jar file in the Glassfish's domain lib. (this i have put it there because the jar is used across ears)
so what exactly should be the content of the <jar-file>*****/myjar.jar</jar-file> tag, for the jar in the glassfish's domain lib directory.
thanks fr yure time,
rajan.
The path should be either an absolute path to a JAR (not recommended) or the simple file name for a JAR inside the EAR deployment file. So, assuming you have an EAR with the jars "ejbs.jar", "jpa.jar" and "myjar.jar", the <jar-file> tag in jpa.jar for myjar.jar should be:
<jar-file>myjar.jar</jar-file>
Related
I found several similar topics, like reading from inner structure etc, however it still does not solve my problem.
Project structure:
whole project -> war, which has:
several jar's connected as dependency
in pom.xml;
context.xml in META-INF folder, which I need to read from one of jars.
part of it -> jar, which is dependency in war's pom.xml
I've tried a few solutions like:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream input = classLoader.getResourceAsStream("META-INF/context.xml");
However I did not expect that to work as I think my jar searches for this resource in its structure, not in war.
I need jar project to read context.xml from war project. So, jar is like inner structure and war is outer. Is that possible to do?
With getResourceAsStream() you have access to all resources in the classpath.
The classpath of a webapplication consists of every jar under WEB-INF/lib and every file under WEB-INF/classes
META-INF is not in the classpath.
Please read the question: How to get resource from the context.xml file in tomcat webapp?
I have a simple project in eclipse that only contains a WebContent folder with dynamic html pages (javascript, jquery, css etc).
How can I deploy such a project (that does not have a war file) to a Tomcat?
A WAR file is just a .zip with a different extension. You just need to make sure there is no top level folder within the .zip. Your files need to be in the root of the archive.
To deploy your static files you can either create a directory (the name of the directory will become the context path - use ROOT for the default web application) and copy your files to that directory. Alternatively, zip everything up, change the extension to .war and copy that to the webapps directory. The name of the WAR file (minus the .war extension) becomes the context path.
There are numerous edge cases and details associated with the above. For the full details, see the Tomcat docs:
http://tomcat.apache.org/tomcat-8.0-doc/config/host.html#Automatic_Application_Deployment including the links on naming and expected behaviour.
I need to read a properties file located inside an ear. In jboss 5.1 I put the file in the root of the ear and it works, but in wildfly it doesn´t.
In wildfly, I managed to read the property file outside the ear according to this
http://blog.jyore.com/?p=58
But I haven´t found the way to do the same but with the file inside the ear. I´ve tried without success putting the file in the METAINF folder, also tried with the "Class-Path: ." in the manifest...
Please any ideas?? Do I have to put the file in any specific location??
I found the solution:
In WildFly 8, to get those properties available in the classpath, package them within your application. For example, if you are deploying a .war then package those properties in WAR WEB-INF/classes/ folder. If you want those properties accessible to all components in a .ear, then package them at the root of some .jar and place that jar in EAR lib/ folder.
https://docs.jboss.org/author/display/WFLY8/How+do+I+migrate+my+application+from+AS5+or+AS6+to+WildFly
Thanks for your help
I have an API for my database model and JPA controllers and I add the jar of that AProject to my BProject. When I declare my API in BProject.
And the error is No Persistence provider for EntityManager named "MyPersistenceUnitName" in my "BProject".
Is it possible or should I create what i'm calling in my AProject?
Yes you can reuse the code you had in AProject.jar. According to persistence chapter of Java EE 6 Tutorial:
The JAR file or directory whose META-INF directory contains
persistence.xml is called the root of the persistence unit. The scope
of the persistence unit is determined by the persistence unit’s root.
Each persistence unit must be identified with a name that is unique to
the persistence unit’s scope.
Persistent units can be packaged as part of a WAR or EJB JAR file or
can be packaged as a JAR file that can then be included in an WAR or
EAR file.
If you package the persistent unit as a set of classes in an EJB JAR
file, persistence.xml should be put in the EJB JAR’s META-INF
directory.
If you package the persistence unit as a set of classes in a WAR file,
persistence.xml should be located in the WAR file’s
WEB-INF/classes/META-INF directory.
If you package the persistence unit in a JAR file that will be
included in a WAR or EAR file, the JAR file should be located in
either
The WEB-INF/lib directory of a WAR
The EAR file’s library directory
i have any problems with weblogic 12c.
I have a java web application, it run with TomCat.
No i must trasfer this application on weblogic 12c server. I have chage any file and deploy the application. Found, but i can't read a file.jsp. (This file found correctly on TOMCAT).
I have this strcture:
Folder:
WebContent
- WEB-INF
-- jsp
--- errorIdent.jsp
But when i use this cose
InputStream in =
this.getClass().getClassLoader().getResourceAsStream("../jsp/errorIdent.jsp");
the inputStream object is null.
For this i try some test case and i find this file only if i put it into WEB-INF/classes
WEB-INF is not on the classpath.
WEB-INF/classes is the root of the classpath.
Libraries in WEB-INF/lib are also put on the classpath.
Why would you want/need to read a JSP file from Java anyway?