Deploying .sar files used in jBoss to weblogic - jboss

We have ".sar"(Service Archive file) used in jboss. Currently we are planning to migrate the code to Weblogic.
Is there a way to deploy .sar files into weblogic.
If not directly possible, is there a work around where we can deploy the services on web logic.

In order to get the custom mbeans that are in the .sar you will need to repackage the contents as an .ear as a .sar is not standard Java EE deployment mechanism - that is a JBoss proprietary archive.
Here are some instructions on how to create, package and deploy your own service MBeans (JMX Beans) along with an example of how to use it.
https://blogs.oracle.com/WebLogicServer/entry/developing_custom_mbeans_to_ma

One thing you could do is to "substitute" or "emulate" the SAR Deployer, by creating, configuring and registering MBeans. That, AFAIK, could be done in two ways:
1) Using Standard Java EE components: that means on web tier you can use the init() method of a servlet (make sure that it is preloaded on startup) or, better, a ServletContextListener
2) Using WebLogic specific components. I'm talking about Startup classes. Simply register a startup class that creates, configures and registers your MBeans.
If you are using a web module, the first approach has the obvious advantage that you are using pure Java EE components. Although you are not using that, you can add a "dummy" web module only for doing that
Concerning what you have to do in those classes, you can choose a "from scratch" approach, by parsing the xml files that describe services and therefore manually create, configure and register MBeans or, if I remember well, the XMBeans from JBoss is something that can be reused outside JBoss but you need to check because I'm not sure

Related

ZK Project , Need Structural Advice for multiple ZK war applications

I need a advice for design purpose my structure of the application is as follows.
I have three module designed in ZK framework as a separate war application (web application) e.g finance-module , general-ledger and cash-account , all are separate war files can be deploy on tomcat as a separate war files,
Now I want to have a seperate war ZK application that has index or home page and have menu and from that menu I can able to call these three module or war application.
-------------------------- Main module -------------
Menu : general-ledger link , cash-account-link ,finance-module
1) This 4th Main module also has feature to user login and change user preference , means can also have code e.g view module as well as spring service.
Now the question is that how to call other war files zul pages and even if v call how to manage from 4th module and also how to share session across the four war files or applications.
Thanks
Vikas
I have worked in a similar scenario and this worked well for us:
When you create separate war's it means that they are independently running in it's own web context inside tomcat. Usually when you want to share resources like datasources, transactionManagers, or any other kind of jee resource you need to configure them at the tomcat instance level and they will be available in the JNDI directory of the tomcat server and any web application can pull any of them to use it.
https://tomcat.apache.org/tomcat-8.0-doc/config/context.html
https://tomcat.apache.org/tomcat-8.0-doc/jndi-resources-howto.html
There are several jee resources than you can share in the tomcat server but if you need more flexibility and robustness you might need a full stack java enterprise application server like wildfly http://wildfly.org/news/2014/11/20/WildFly82-Final-Released/ or any other commercial like WebSphere, Oracle Weblogic, etc
Now, if you want to share java classes, zul's or any other file, you may want to package them in separate common jars and use them in any war as a dependency and then reference them through the classpath of the web application.To organize and maintenance this modular projects Maven and Gradle are very good tools you can use.
From ZK you can call any other url of the other war's as simple as
<a href="htt://myserver/account/home.zul" label="Account"/>
<a href="htt://myserver/finnance/home.zul" label="Finance"/>
To share the session what you need is to implement a Single Sign On (there are other implementations like oracle opensso), you can configure it directly in tomcat but be aware of this Sharing security context between few web applications .
Spring Securityhas an extraordinary support for this kind of escenario.

EAR generated using ANT doesn't work on Websphere 8.5

The object is to build .ear by using ANT then deploy it on Websphere 8.5 with wsadmin.
Manually, the ear file is generated from a jar file and after deployment, the web application works very well.
But if I use the ear generated by ANT, after deployment (by hand or by wsadmin), I always have this error :
SRVE0255E: A WebGroup/Virtual Host to handle /WebApp$%7Blogout.url%7D has not been defined.
SRVE0255E: A WebGroup/Virtual Host to handle localhost:9080 has not been defined.
Someone knows which might invoke this problem. I met this message before while my colleague deploy on websphere with a war file directly from a Tomcat server.
Thanks in advance.
It looks like you have not defined web application bindings during deployment. There are several ways to do this, but before that I suggest that you read about Application bindings in WAS, especially the paragraph Virtual host bindings for web modules.
Required bindings can be provided either as parameters to install command of AdminApp or by including binding files directly inside WAR. In some cases WAS can generate default binding for you. For example, to install web application with default bindings you need to provide the following command to wsadmin (simplified):
AdminApp.install(path_to_your_war_file, [
'-appname', your_app_name,
'-CtxRootForWebMod', [
['.*', '.*', your_app_context_root]
],
'-usedefaultbindings'])
I also recommend deploying application once in WAS console to understand possible bindings.

How can you develop bottom-up JAX-WS web services referencing classes contained in separate jar files?

I am developing a Java EE 6 bottom-up JAX-WS to expose an EJB3.1 stateless session bean. The web service in a WAR is failing to install on deployment because it references an external jar (or shared library) which one can assume is not loaded yet.
The common suggestion is to include the jars in the /lib folder, which does fix the issue, however the jars need to remain in this external shared library location and NOT in the ear file, because they amount to 30MB.
What are some techniques to get around this issue in a Websphere (WAS v.8) environment or any server environment.
Some suggestions I have found include:
1. define classpath in META-INF file.
2. define the resources in deployment.xml
3. alter class loading order
4. (from ibm) In the case where the jars are part of a Shared Library configured on WebSphere Application Server, then a User Library must be used to configure the project for development before generating the WebService.
However, I have been unsuccessful to find any help online in these areas. Is there another technique or does anyone know anything about accomplishing this? Thanks in advance.
EDIT: If I specify the libraries in the META-INF using class-path, they are loaded before extensions, shared libraries..etc, but they are still loaded after the WAR which is not good. Again, this isn't a runtime issue because the web services are created at deployment on the fly.
I submitted a ticket to IBM. The libraries referenced by the web service are needed during deployment and must be bundled into the Ear in some fashion. I threw them in the web-inf/lib folder. However, if the referenced libraries then depend on additional libraries, these can be placed in the Shared Libraries. Seems odd to me too, but let's all just admit "shared libraries" are a hack anyways.
If you still have issues, just make sure your class loading is set to parent_last.

Shared libraries between web services on Glassfish

I need to deploy multiple web services on a jax-ws application server, glassfish 3. These web services need to have shared libraries, meaning shared instances of the same class.
I know I could do this by dropping a jar in the "~/glassfish3/glassfish/domains/domain1/lib" directory. But I wonder whether this is possible in a more elegant way: I want to place the shared library jar inside a web service war which I deploy and then access that library from another war I deploy on the same application server.
How can I do this?
I found a solution for Glassfish myself: Basically I just deploy a class (SharedClassLoader) which inherits from URLClassLoader as a shared library jar in the above mentioned directory. Then I use this classloader as a bootstrap: On calling the web service, the classloader hierarchy is extended as follows: A SharedClassLoader for an URL is instantiated if it does not exist yet and it is added as a delegate to the DelegatingClassLoader in the classloader tree. By doing this for every web service with the same SharedClassLoader instance, it acts as a bootstrap to pull in more class loading. The jar that SharedClassLoader refers to can also be deployed with one of the web services, because Glassfish unpacks the containers to $AS_HOME/domains/domain1/applications/APPLICATION_NAME/LIBRARY_NAME.jar.
I hope this helps anyone having the same problem. I solved this problem for my Bachelor Thesis. If anyone needs more information, just ask, I can send you my thesis.

Deploying multiple versions of same EJBs and classes to same JBoss server

I have a few separate application projects (EARs) with multiple EJBs that I want to deploy to the same JBoss server. Now, some of the projects may have the same EJBs, but different versions. In similar circumstances, some projects may use different versions of the same "ordinary" classes (i.e. classes loaded within VM, without JNDI lookup).
With OC4J, this seems not to have been a problem, but now with JBoss, I get the impression that everything resides in the same "name space" (or class loader perhaps). Am I correct in this assumption?
Basically, what I want to do (or ensure) are two things:
From a client that does a JNDI-lookup of an EJB, I want to be able to indicate which application it resides in, so that the correct version of the EJB is returned.
From within an EJB, when instantiating a class, I want to ensure that the class is the one deployed with the same application (EAR) as the EJB was.
I think I read that you could configure some "isolation" properties for EJBs, am I guessing correctly in that might would solve my second point?
JBoss's default behaviour is to use a flat classloader. This reduces the footprint, but as you've found, it makes deploying multiple applications troublesome.
Thankfully, the fix is easy. In the ear-deployer.xml file in the deploy directory, make sure the following parameter is set:
<attribute name="Isolated">true</attribute>
This will give each deployed EAR its own classloader space. It will still be able to access stuff from the JBoss lib directory, but the deployed EARs will be invisible to each other.
You're correct that classes from different EAR's reside in the same "space". JBoss uses by default a flat classloader hierarchy, meaning that all classes (except for WAR packaged ones) are loaded by the same classloader. With the introduction of JBoss 5 there's a new standard profile that strictly follows the Java EE rules and thus supports isolated classloading. Older JBoss versions also support this behavior through the callByValue and isolate properties in the deployer configuraion.