Glassfish 3.1.2 lib/jar referral from ejb.jar issue - java

I have been working on migrating our code base onto Glassfish 3.1.2 using Java 7. I have been struck with this issue, where the deployment of EAR fails. I have an EAR, having modules, ejb.jar, couple of war files, along with lib directory having jar files to be shared across other modules within the EAR.
The issue is that ejb.jar refers to some spring bean definitions in lib/abc.jar file and is unable to find the spring file. The structure is like this:
EAR
ejb.jar (some spring files in here refer to lib spring file like, xyz.xml importing spring/abc.context.xml)
couple of war projects.
lib/lot of jar files (one of the jar here contains the spring file being referred from ejb.jar, note the file is inside directory inside the jar, like spring/abc-context.xml)
But the ejb jar cant load the bean definitions from lib/.jar
I have tried using the Manifest.MF inside the ejb.jar to refer to lib/abc.jar, but with no luck....
Not sure if there is some sort of problem with new GF 3.1.2, why its not able to respect the Manifest file. Any help will be much appreciated!

It looks like the JVM doesnt like the manually edited Manifest file and my guess is that windows is adding something like a carriage return etc. I managed to get it working by using the ant to generate the manifest file instead.
Thanks and hope that helps someone.

Related

How to create war file if project doesn't have entry point?

There is a project in github:
https://github.com/chexagon/redis-session-manager
I downloaded and created jar file via maven. But I must use war file for deploying it to Tomcat and use it in our own application. Because of this project doesn't have web.xml file or any entry point (at least I couldn't find it) I couldn't create war file properly. Can anyone help me to solve this issue.
Thanks in advance
The software you downloaded is not a web application. It is a component that can be used as part of a web application.
Correction - Actually it is an add-on component / plugin for Tomcat itself ... that allows the session state of web applications to be persisted in Redis.
Turning it into a WAR file won't help.
Even putting it into your application's WAR file won't help.
The JAR file needs to be copied to the tomcat/lib directory. Then you add a a <Manager> element to the conf/server.xml file. The README.md file describes the attributes of <Manager>.

Update xml file in JAR with weblogic deployment plan

I have a java application(not a EJB, not a MDB, it has a class implements ApplicationLifecycleListener). I build this java application into a jar file then create an EAR file include this jar, deploy the EAR file on a weblogic server, it works perfectly fine.
Now I want to use weblogic deployment plan to update some of the values in a configuration file which located inside the jar file. I generated the deployment plan, but it does not recognize my configuration XML file. I tried manually add it to the deployment plan, and use the deployment plan to redeploy this application. But nothing is updated.
I have read some examples of updating ejbs, but did not find anything about update a JAR's configuration inside an EAR, can anyone please give me example or send leave a link on how to properly use weblogic deployment plan to update a configuration file inside a JAR which is packed within an EAR file. Thanks.
You probably have to place the XML file in a jar file with same name under the same path as the original and use this jar in AppFileOverrides.

Glassfish 3.1.2 weird class loading

I have a simple web application deployed in glassfish as a war file, and there is a class file included in a jar file under WEB-INF/lib folder
also I have a custom .class file developed and I put in under
WEB-INF/classes/...same classpath as in jar file/TheClass.class
However when I deploy the application, looks like that class file I customized does not take effect at all. But if I replace the one in the jar file, then everything is fine.
I have use the same feature on Websphere, Jboss and tomcat, all take the .class file in precedence on top of jar file.
is there any configuration I have missed in the context that cause the weird behavior?

Classpath in java and spring

I am majorly confused about where the classpath is. I understand when we create a spring mvc, resources folder, or inside web-inf is considered classpath. And we can use "classpath:" inside xml files to declare the folder. However, where is this classpath exactly? How is it set ? I have been reading about it for a long time, i still couldnt manage to get a real clear image in my head how the classpath is initially determined etc.
For example when we create a war file, and deploy it on a tomcat server, all the resource files can still be read via given paths with "classpath:" in the xml files. How does this work?
Thanks.
Ok, if it's web application, the classpath begins in WEB-INF/classes. Also, jar files in WEB-INF/lib are also on the classpath.
The Classpath is where the JVM will look for class files and other resources. Since you are using Spring MVC, I assume you are deploying a Web application (ie WAR file). This means that the classpath is set by the container which is following the Servlet spec.
The classpath for a WAR file includes the WEB-INF/classes and WEB-INF/lib folders. The Java EE/Servlet container where the WAR file is deployed will also include other common folders in the classpath.
Here is how Tomcat works.
You might also want to try this StackOverflow article/answer

ant: Need help packaging an EJB and its dependencies into an EAR

My goal is pretty simple: to use ant to build an EAR which contains 1 EJB and 1 jar containing all of the dependencies. This jar, called common.jar for the sake of example has vendor jar files in it as well as other xml files that the EJB depends on and will need to be able to see during runtime....
So far I have everything packaged correctly as an EAR like this:
EARFILE.ear
-EJBFILE.jar
/META-INF
-MANIFEST.MF
-common.jar
/META-INF
-MANIFEST.MF
/lib
-(all vendor jars inside here)
-(All the xml config files are inside the root of the common.jar)
Inside the MANIFEST.MF for the EJBFILE.jar is...
Class-path: ../../common.jar
Inside the MANIFEST.MF for the common.jar is...
Class-path: ../lib/some_common.jar
When I deploy this the appserver (websphere) cannot find the JAR file when I try to start the server. I am getting the ClassDefNotFoundError because the classes inside the EJB cant find the vendor JAR files when I try to start the instance. However I know that common.jar is setup correctly though, else the EJB wouldn't have compiled since it needed to have those vendor jars on the classpath for javac.
So what I want to know is this:
How can I get the runtime to correctly see the Vendor jar files.
Will the EJB be able to see the xml files at run-time? I am concerned about this because these xml files are located outside of the EJB inside of a jar that is just in the EAR, it isn't even a module its just a jar inside the EAR.
Does it even matter when using websphere? From what I gather some containers don't even care what is in the Class-path of MANIFEST.MF.
There are several improvements I can suggest, based on running into similar problems.
First and most importantly, use the appxml attribute of the Ant ear task to specify your deployment descriptor (usually named application.xml); also include references to the vendor JAR files bundled as defined below
I would recommend you not put your vendor JAR files into another JAR - instead, just copy them into the EAR at the same level as EJBFILE.jar
The configuration XML files can go in a sub-directory of the EJBFILE.jar (such as config), and then you can reference them as /config/filename.xml.
The application.xml file will tell WebSphere where to find your JAR files. Classpath traversal in an application server is not the same as that of a compiler, which JBoss has taught me the hard way.
I am using all of the above patterns, and my in-container code (deployed in the EAR) can see all my XML files, as well as find all my dependencies.

Categories

Resources