I don't mess with WebSphere often enough to know if this will work. I would like my J2EE or plain Java apps to know on which box it is running, i.e PRODUCTION, DEVELOPMENT or TEST, and use PROD, DEVL or TEST resources accordingly. Since this info is common to all apps, I don't want to store it within any particular app. Is it possible to store an (environment?) variable on the Linux box or within WebSphere (outside of all apps) that is accessible to all J2EE (Struts2) apps and plain Java apps? I would appreciate any pointers in this regard. Thanks.
Yes. I'm not a WebSphere user, but a quick search provides this: Setting environment entries in WebSphere Application Server.
WebSphere Application Server 7.0, 8.0, 8.5 and 8.5.5
Open the administrative console.
Select Servers > (Expand Server Types) > WebSphere application servers > server_name > (Expand Java™ and Process Management) > Process Definition > Environment Entries > New.
Add entries to the Name/Value pairs.
Click OK.
Save changes to the master configuration and restart the Application Server.
WebSphere Application Server 6.1
Open the administrative console.
Select Servers > Application Servers > server_name > (Expand Java™ and Process Management) > Process Definition > Environment Entries > New.
Add entries to the Name/Value pairs.
Click OK.
Save changes to the master configuration and restart the Application Server.
I do nearly the same thing in JBoss/Wildfly. You are simply setting up an entry the JVM's Environment.
Edit in response to 1st comment:
I think it's a safe guess that your Java app doesn't run in the same JVM as your J2EE app on WebSphere. Separate JVMs = separate environments. We use Java Web Start to distribute and kick off local Java apps from different environments - each server environment writes a JNLP containing the appropriate app setup. If you just need apps on the same machine to know where they are you can set up an shell variable, as you said, that could be read by both WebSphere and Java apps.
Edit #2, regarding WebSphere - after further investigation:
I also found this, which is a partial duplicate of this question: Place for setting environment variables for WebSphere JVM process. The answer there notes that using the WebSphere GUI to enter the env variables is also preferable for clustering.
You might want to use use the WebSphere specific method in combination with the shell variables.
Related
I am about to start working on a JSF application and I am trying to decide on how to set up my production environment.
I enjoy working off my VPS for production instead of my local host. Is there a way to launch a JSF app to my server and then build on it from there? Or is that not going to work because I have to have a compiler to compile the java each time I update?
If that is the case would it make sense to just install a compiler to the server?
This is my first JSF and real java application so if there is some good info on this please lead me there.
I have someone working with me and I was assuming if we both work of the server it would be easiest.
How would this work in a professional environment, or in other words how would a team working for a company set their environment up?
How it generally works is that each team member has a local installation, and deployments up the chain to servers are handled by the systems admin guys on requests, them being provided with an installation package containing the compiled application (a WAR or EAR file), any other files needed, and quite likely a script with database changes, an installation manual, and things like that.
You should never develop directly on a production server. Only deploy stuff there once it's complete, tested, and verified to be in working order, and secured against attacks.
I'm currently having 2 Weblogic admin servers in 2 different domains created on the same machine.
I want to convert one of the admin server to a managed server and then use them together to deploy a Java application. Is this feasible? If yes, how?
I'm currently using Weblogic Server 10.3.
PS: I'm quite new to Weblogic domain creation and administration. Please revert for any more details needed.
The simple answer is no, however, adding a managed server to a domain is extremely simple. See the documentation here. When deploying your application you'll need to target both servers or create a cluster (also very easy), add both machines to it and give the cluster name as the target.
Note, it is generally not concidered best practice to target applications to the Admin server (although it's fine when you're developing on your local machine). If you have the resources available on your environment, you could create two managed servers and put them in a cluster. Depending on the configuration of your Admin server, you may be able to reduce it's size if memory is tight.
Can we deploy a java project on windows azure without uploading JDK and Tomcat on storage in windows azure? If yes, please provide me steps how to do it.
I made a project as provided in windows azure create a sample application in Java.
But at time i have to create a cloud service, I am supposed to deploy JDK and tomcat which totals around 100-130 MB. Isn't there any solution so that we should deploy cloud service and not JDK and tomcat.
Azure VM images do not include the JDK or any of the Java web servers (Tomcat, Jetty, etc.). You need to get them, from somewhere.
So... when building a Java app via Eclipse and related Cloud Service template, there's a startup script that bootstraps your worker role instances. This involves grabbing the SDK and web server (Tomcat, Jetty, etc.) from somewhere and placing it on your instance's disk. Since you're using Cloud Services (worker role in this case), the OS disks are stateless: Each time a new VM instance spins up, it starts fresh, and you're responsible for setting things up (via startup script).
So: You need to set up your SDK and web server. You can either bundle these with your deployment package or download them from somewhere. The former increases the deployment package size by quite a bit (maybe 100MB?). The latter requires you to download the bits from somewhere. You can either download from somewhere like Oracle (which requires you to go through a license agreement each time), or from your own storage account (which is very fast, as long as it's in the same region as your code deployment). Further: being in the same data center, there are no bandwidth charges when downloading stuff to your worker role instances.
The current Eclipse plugin has a setting for your worker role, where you specify blob storage for your JDK and web server. By doing this, it's basically a one-time setup (except when it's time to upgrade the JDK or Tomcat/Jetty version, and then you'll need to re-upload to blob storage). Once these bits are in blob storage, you only need to include your Java classes in your deployment package.
Can anyone point me to the steps/resources that describe:
How to deploy a Java EE app on amazon-EC2
Maintain changes to the meta-data of the app server (deploy new applications) after an instance reboot (probably using amazon-ebs)
First check this out if you haven't already ran through it:
http://docs.aws.amazon.com/gettingstarted/latest/awsgsg-intro/intro.html
it'll give you an idea of how it all works.
With regard to running a Java EE app on EC2, you have a couple of choices - but they generally come down to the following recipe:
Start an instance
Install a Java EE application server (tomcat/glassfish/websphere/...)
Install your application (war/ear) into the application server
Now you can bundle the above into an ebs ami, or you can write a script (bash/sh/tcl) which applies those changes when your instance starts (which i prefer). The scripts allow you to modify what gets installed/started/moved around without having to rebundle your instance.
There's some great resources here: http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=100
Hope that helps.
How to deploy a Java EE app on amazon-EC2
You still deploy to an application server so it isn't really different. If you have more specific questions, please clarify. But have a look at Running JEE applications on Amazon EC2 and How to deploy a java web application on an ec2 instance.
Maintain changes to the meta-data of the app server (deploy new applications) after an instance reboot (probably using amazon-ebs)
If you use Amazon EBS, then you don't need to worry, Amazon EBS volumes are off-instance storage that persists independently from the life of an instance.
The Amazon AWS's newly Launched Elastic BeanStalk is here to resolve you concerns.
You can deploy Java EE apps on Amazon Ec2 instances via Bean Stalk. All you need to do is create a new applications and create a environment in it and add you WAR file for deploying, AWS has its own version of Tomcat 6/7 with open JDK which can be customized to Sun JDK if required.
Therefore Amazon offers complete Deployment tool to start using your app by just deploying in BeanStalk. BeanStalk offer Auto Scaling & Elastic Load balancing and a lots more to customize your application Environment.
If you start an ebs-booted instance, you do not need to care about persistency after a reboot (see http://aws.amazon.com/about-aws/whats-new/2009/12/03/amazon-ec2-instances-now-can-boot-from-amazon-ebs/)
Concerning the deployment of Java EE, I don't see any difference to deploying it on a non-virtual OS.
Boxfuse supports deploying Java EE applications using either Tomcat, TomEE Web Profile or TomEE Plus to AWS with a single command
boxfuse run mytomeeapp-1.0.war -env=prod
This will create an image, provision all necessary AWS infrastructure and launch the instances. It supports blue/green zero downtime updates with Elastic IPs and ELBs.
You can find a tutorial here: https://boxfuse.com/blog/javaee-aws.html
You don't have to worry about maintaining changes to the meta-data as all instances are immutable and contain all necessary app server info.
Disclaimer: I am the founder and CEO of Boxfuse
I am trying to get visualvm and websphere 7 to work together on my local windows desktop. I try to connect through JMX but no luck. Has anybody managed to get visialvm and websphere 7 to work and ow did you do it?
Regards
FF
I got it to work with the help of the VisualVM team in Praha (Thanks Tomas!):
1) On the admin console (Click on Servers -> Server types -> WebSphere application servers -> server1 -> Java and Process Management -> Process definition -> Java Virtual Machine), add the following line into the field of
Generic JVM Argument (note that the first system property is equal to
nothing and no equal sign for the second system property):
-Djavax.management.builder.initial= -Dcom.sun.management.jmxremote
2) Add or uncomment the following three lines in file /opt/IBM/
WebSphere/AppServer/java/jre/lib/management/management.properties
(or / lib/management/management.properties):
com.sun.management.jmxremote.port=3333
com.sun.management.jmxremote.authenticate=false
com.sun.management.jmxremote.ssl=false
com.sun.management.jmxremote.local.only=false
3) Connect VisualVM!
It is possible to set these parameters port, authenticate and ssl as JVM Arguments like -Dcom.sun.management.jmxremote.port=1300
I have another issue: by using the mbean visualvm plugin I can not see any relevant Websphere mbean.
It depends on what you want to achieve and the constraints you have. What you need to know is that there are two MBean servers in WebSphere: in addition to the platform MBean server created automatically by the JRE, WebSphere also creates its own MBean server. Here are the two options you have:
Configure your WebSphere server as described in the answer given by user271858. This will allow you to connect to the platform MBean server. You will get access to the standard platform MBeans that provide process information (RAM, CPU, threads, etc.). On the other hand, you won't be able to access WebSphere's MBeans (implementing certain administrative actions, providing application metrics, etc.). You also need to be aware that by changing the configuration of the WebSphere server, you bypass WebSphere's security.
Connect to WebSphere's MBean server. WebSphere supports several protocols to do that (mainly SOAP and RMI), but none of them is completely standard. This means that you will need to add some of the WebSphere libraries (namely the admin thin client) to VisualVM. It is probably possible to do that (It works with JConsole, so in principle it should be possible with VisualVM as well), but it's tricky, especially it you need to connect to a WebSphere server that has security enabled.
A simpler option is to install the VisualWAS plugin into VisualVM. It relies on an Open Source implementation of one of the proprietary WebSphere protocols and therefore doesn't require any additional WebSphere library.
This will give you access to MBeans registered in WebSphere's MBean server, but not to the standard platform MBeans, i.e. the relevant parts (related to memory, CPU and threads) in VisualVM will be disabled. You can however cross-register the platform MBeans in WebSphere's MBean server, and the VisualWAS project provides a solution for this as well (in the form of a plugin to be installed into WebSphere). You will then have access to all features in VisualVM, and you don't need to bypass WebSphere's security.