Websphere Server Profile for different node and cell name - java

I'm relatively new to Websphere. I have created a WAS ( Websphere Application Server 8.5) profile configuration on local, manually from scratch which contains multiple data sources, queues, connection factories and activation specifications. ( Windows 7 PC). I backed this up using backupConfig.bat. I wish to replicate this profile configuration on another system where the Websphere Application Server (installation cannot be altered) has a different Node and Cell name. Is there a way where I can replicate it , without having to manually create the resources again,one-by-one , in the local WAS profile on the new system? When I googled this, it threw up the manageprofiles command, though I am not sure if it's backup option will work in my case. Thanks in advance.

If these are simple queues, datasource etc you can use Property based configuration - see Using properties files to manage system configuration.
You export configuration from one cell and import to the other.
If you have few elements you can use WebSphere Configuration Migration Tool (Eclipse plugin), which will allow you to select graphically which resources to move - it generates jython script that you can execute on target environment.

Related

Websphere AS conflicts between Two eclipse workspaces

I am new to Websphere. Right now, I am setting up workspace for two projects in separate eclipse workspaces in MyEclipseBlue 2016 using Websphere 8.5 Application Server. Profiles are configured separately for those projects.
Need to work with both applications at the same time since one application depends on the other. When I deploy the applications separately by opening any one workspace, server starts without any errors. But when both workspaces are open, starting/stopping a server in one workspace, makes the server in other workspace to does the same and exception occurs when server starts.
I don't know how this occurs, How both the servers in separate eclipse workspaces are integrated?
Websphere variables under Environment in Admin console are different for both projects since they are configured with different profiles. But When deploying both the applications at the same time, Websphere variables specific to any one of the profiles gets applied for both the projects.
Unable to find the way to deploy these two projects with different websphere profiles at the same time.
Please advise.
To be clear, you have an installation of WAS 8.5, with two profiles, say AppSvr01 and AppSvr02, and two eclipse workspaces, say ws1 and ws2, and you are using the WebSphere Application Server Developer Tools for Eclipse to manage the servers? And ws1 workspace is configured in WDT to use WAS profile AppSvr01 and ws2 workspace is configured to use WAS profile AppSvr02? If the interaction you describe is happening, some possibilities are 1) WDT is using the same WAS profile in both ws1 and ws2 workspaces, 2) the WAS profiles AppSvr01 and AppSvr02 have conflicting port assignments, or 3) WDT is not configured to use unique ports to communicate with the server. #1 is easy to check in the WDT Server editor settings. #2 shouldn't be the case as you stated the port assignments are unique to the profiles. #3 is also easily checked in the WDT Server editor. Examine the "Server connection types and admin ports" section for both profiles and verify they're unique to each workspace, if not, override them. If they are unique, run each workspace by itself, have WDT start the server and examine the logs to see what profile the workspace is actually starting and on what ports.
The WebSphere connectors in MyEclipse are somewhat intelligent in that they can detect if the server is running or not. When you start WebSphere in one workspace, the other will detect that it is started and show "running" status. Similarly if the server is stopped. Although you have separate profiles, are they using the same ports? If so, change the port numbers. You can see the port numbers quickly by double clicking the connector in the Servers view (which brings up a configuration editor) though you'll have to change them through the WebClipse profile manager.
Alternatively, use a single workspace for both projects, since one depends on the other, and use a single profile. You haven't said why you need to use separate profiles and workspaces (not sure how the dependency works in that case).

Loading data source for #DataSourceDefinition from application in Liberty

For usage with #DataSourceDefinition I'd like to have the DataSource class loaded from the application that uses this #DataSourceDefinition annotation (or equivalent data-source element in a deployment descriptor).
This works for basically every server as per the test I added in the Java EE 7 samples project.
For example, considering this data source definition in web.xml:
<data-source>
<name>java:app/MyApp/MyDS</name>
<class-name>org.h2.jdbcx.JdbcDataSource</class-name>
<url>jdbc:h2:mem:test</url>
</data-source>
The jar containing org.h2.jdbcx.JdbcDataSource would reside in WEB-INF/lib.
This is very convenient in CI testing when testing against a server that's automatically downloaded, and where the name of the deployed .war is unknown in advance (since controlled by say Arquillian).
While nearly every server supports this, Liberty 16.0.2 throws the following exception for either java:app/MyApp/MyDS or java:global/MyDS:
CWNEN0011E: The injection engine failed to process bindings for the
metadata due to the following error:
java.sql.SQLNonTransientException: J2CA8022E: Application xyz23-zvf does
not have any shared libraries that provide org.h2.jdbcx.JdbcDataSource
for dataSource java:global/MyDS.
The IBM instructions refer to setting up a shared library that lives on the local file system, but for several classes of data sources (e.g. those that only have internal meaning to the application), as well as for the mentioned CI testing this is not practical.
Is there any way to let Liberty load the data source from the application like most other Java EE servers do?

Coherence config default override path

I've already spent more than 2 days trying to make this work without any result. The server is WebLogic 12c with embedded Coherence server. It is important to mention that I do not run Coherence in standalone mode, instead it starts automatically alongside the application server that has access to Coherence via JNDI context. I am trying to implement POF serialization approach using PortableObject interface to serialize certain objects I save in Coherence. I've also created the corresponding pof-config.xml registering the objects I'm planning to serialize. The only problem is: How do I add the override to the coherence class path?
According to http://docs.oracle.com/cd/E24290_01/coh.371/e22837/gs_config.htm#COHDG5014 I can use the following system property:
java -Dtangosol.pof.config=MyPOF.xml -cp COHERENCE_HOME;COHERENCE_HOME\lib\coherence.jar com.tangosol.net.DefaultCacheServer
The only problem here is that I have no idea which sh/cmd file to edit, since all edits I made to the files in Oracle_Home\coherence\bin\ had no effect.
Also the same article says that there is a way to confirm the pof-config override:
The output for a Coherence node indicates the location and name of the POF configuration deployment descriptors that are loaded at startup. The configuration messages are among the messages that display after the Coherence copyright text is emitted and are associated with the cache service that is configured to use POF. The output is especially helpful when developing and testing Coherence applications and solutions.
Loading POF configuration from resource "file:/D:/coherence/my-pof-config.xml"
But I couldn't find any of the mentioned lines in the logs produced by the server instance.
Any ideas?
Instead of editing files inside of your Oracle_Home, try the following inside of the weblogic admin console:
Login to admin console
Servers link -> Server Name
Click the Server Start tab
Edit the Arguments: text box and add in -Dtangosol.pof.config=MyPOF.xml
You can also change the classpath, Class Path: box, here if you need to
Every time your server starts it should have that property. If you are not using the nodemanager to start your server, you should do the following instead. Keep in mind this will change the properties for every server in your weblogic domain:
Navigate to your <domain home>/bin directory
Edit startWebLogic.sh/cmd
Edit the JAVA_OPTIONS= line and add in -Dtangosol.pof.config=MyPOF.xml
You can also change the classpath CLASSPATH= here if you need to

Avoid project's directory - Java EE app

I am writing and small app using Java EE. I am using Apache Tomcat v 7 and Eclipse as IDE. When I Run the project (Run on server) I get :
http://127.0.0.1:8080/java-web/lis
(That's fine)
But I don't know If there is some way to rewrite the [java-web] dir just to get :
http://my-local-app.dev/list
I suppose there is some way like in Apache Server using confing files and enabling
the mod_rewrite.
I'll apreciate your help. Thanks
In short: All of the pieces you want to change are components of your deployment environment. Unless you have a specific need to override them, it's usually easiest during development to use the URLs that are a little less pretty.
If you do want to alter them, you need to familiarize yourself with what the various parts of an HTTP URL mean. What you have in your test environment is this:
http:// 127.0.0.1:8080/java-web/list
protocol host port path
You could insert an entry into your hosts file listing my-local-app.dev at 127.0.0.1, but that would not change the port or the path.
The port is determined when Tomcat starts up and is 8080 by default. The general port for HTTP is 80, but specific permission is required to bind to ports below 1024. On Linux, the authbind package makes this pretty easy; on Windows, the necessary steps will depend on your version and configuration (e.g., if you have a Group Policy).
In Tomcat, Web applications are prefixed with their names in the path; it looks like your (hypothetical?) application is named java-web.war. You can install an application as the "root application", but this requires a little bit more configuration and is generally skipped in development.
All of this can indeed also be done using something like mod_rewrite, but that seems like overkill to have slightly prettier URLs for your dev machine.
If you want your application to respond to the my-local-app.dev, you need to purchase the "my-local-app.dev" domain and get a Java web hotel running on it.
If your web application is named "java-web" and you do not want the URL to reflect that, you need to tell Tomcat that you want your application deployed at the ROOT location where the name of the web application is not present in the URL. This is typically done in the deployment stage but unfortunately there is no standard location to say this for WAR files so this is vendor dependent. For example does Glassfish use an extra XML file in your deployment.
I believe Tomcat supports this for ROOT.war files. If not, you probably needs to set the META-INF/context.xml file. See https://tomcat.apache.org/tomcat-7.0-doc/config/context.html for details on what to put in this file - especially the context path.

Best way to configure a Java enterprise application

I have a set of EJBs and other Java classes which need to be configured differently based on the system environment in which they are deployed: production, test, or lab. The configuration information includes stuff like URLs and database connection information.
We'd like to deploy the same exact product (EAR file) in each environment, and have the code then figure out where it is and what its configuration should be, without having to reach out to each deployment server in each environment to make changes.
What is the best way to configure all these components in a centralized, reliable, easy-to-maintain fashion?
Thanks for your thoughts.
The best, IMHO, is to use JNDI entries.
You may have to recode some parts of your application in order to use theses entries instead of plain vars, but with this setup:
Configuration is server-independant: each vendor provides its own implementation, but spec is a standard.
In a clustered environment, config can be persisted in a cluster-wide JNDI tree (see JBoss)
Configuration can be changed thru webadmin without restarting server.
How database connection pool information is stored / configured depends on the app server vendor. Put other variable stuff in property files on the classpath.
If you are deploying the exact same EAR to three different instances of a certain container than you will have to edit the deployment settings as there is no way that the deployment process could have any idea about which one of your three versions you would like to use at a particular deployment.
Deployment settings should go into JNDI entries as Piere-Yves said above.
If I were you, I would have my deployment-script (Ant?) properly populate the JNDI entries depending upon which environment you are deploying to.

Categories

Resources