I'm running Weblogic locally, but will run also be run in production on server instances administred from weblogic server
I have set a system property in Weblogic using, "-DRUNTIME_ENVIRONMENT=LOCALHEST" under the menu item in Servers -> Configuration-> Server start -> Arguments:
I my java file, i have System.out.println("ENVR_:" + System.getProperty("RUNTIME_ENVIRONMENT"));
And it prints null, is there some argument i have missed?
Have to add "set JAVA_OPTIONS=%JAVA_OPTIONS% -Druntime.environment=local" to the startWebLogic.cmd file
I believe the settings on that page apply only if Node Manager is used. So you will need to start your application server with Node Manager and not using the command line or other means.
If you are using Linux/Mac OS(I am using WebLogic 12.2 on Mac):
Find the file startWebLogic.sh then edit
Find and this line change this line JAVA_OPTIONS="${SAVE_JAVA_OPTIONS} -Denv=dev"
-Denv=dev is the environment you want
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I am installing Tomcat 7 in my PC it works in Eclipse but when I try to open in bin/ tomcat7.exe it just open and closes, (I am stopping the server in Eclipse). Also, in Eclipse I'am trying to open admin console like URL:(localhost:1234/admin) it shows 404 error. Can anyone who knows this problem explain a solution?
If you are using Windows, you can follow the following to run tomcat7.exe :
Open your Command prompt (cmd)
Set your JAVA_HOME or JRE_HOME. Eg. set JRE_HOME=C:\Program Files\Java\jre7
Go to the directory of your tomcat. Eg. cd C:\Program Files\apache-tomcat-7.0.35\bin
Run startup.bat file. Eg. startup.
This should start your tomcat server without using Eclipse.
First Set JAVA_HOME and CLASSPath path
For Windows Java Path Settings
Right click on Computer and open Properties.
In Windows Vista or Windows 7, go to Advanced System Settings.
Else go to next step. Go to Advanced Tab and click on Environment
Variables button.
Select CLASSPath under the list of System Variables, and press Edit and add If CLASSPath not available there click New button add
C:\Program Files\java\jre 1.x.x_xx\bin
after a semicolon.
Now click on New' button under system variables and enter
JAVA_HOME as variable name and path to jdk home directory (ex.
C:\Program Files\Java\jdk1.x.x_xx
After Completing Java Path Settings
Go to the directory of your Tomcat. Eg. cd C:\Program
Files\apache-tomcat-7.0.35\bin
Run startup.bat file
To start your application server in Windows :
Open command prompt .(Run as Administrator).
Go to the path (..\apache-tomcat-8.0.27\bin) and run startup.bat
A new command prompt opens up and should stay unclosed to tell your server is in running state.
If command prompt opens and closes automatically, then the reason can be as below.
tomcat is already in started state in Eclipse.
Check the connector port configured in server.xml file and check if that port is free in your local machine. [netstat command]
Change the connector port to some unused port, preferably in 80XX series.
Let me know if you are able to invoke localhost:(the http connector port) you have configured in server.xml through you web browser.
You don't start Tomcat by double clicking the exe, use the batch files instead.
startup.bat starts the server, shutdown.bat stops it again.
And ignore the advise to get the service installer. You don't need those unless you want the server to start on system boot and run in the background. Which you don't want unless you're going to configure a production server, which you aren't here.
The batch files are in the same directory on your computer as the exe.
you have to set JAVA_HOME and JRE_HOME in System environment.while setting the JAVA_HOME and JRE_HOME, you should assure that JRE path that you are setting is corresponding to the JDK whose path you have set in JAVA_HOME. some time what happens that there may be more than one JDK in the system so conflict occurs. better to have only one JDK and corresponding JRE.
This is probably due to a bad setup of an environment variable.
For example, if you setup incorrect JAVA_OPTS, tomcat startup will fail.
You can check your configuration by calling : catalina configtest
Here an example of the output for bad setup of JAVA_OPTS :
Error occurred during initialization of VM Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
It works for me after updating the jdk path in JAVA_HOME compatible to your tomcat version in user Variables.
the JAVA_HOME and JRE_HOME environment variables set should not have semicolon or ; at the end...I was facing similar problem...removed semi-colon or ; from the end and tomcat server started from cmd screen after running startup command(of tomcat..bin folder).
I checked environment variables and compiler version everything was fine, deleting junk files from work folder worked for me.
Just download the tomcat 32-bit/64-bit Windows Service Installer (pgp, md5) as in this set up is given which will install tomcat on your PC and you can also start and stop tomcat using the tomcat service.
In my experience tomcat7 might not like it if JAVA_PATH or JDK_PATH contain bracket symbols like in "Program Files (x86)". Make sure you format path in your environmental variables correctly or move your JDK to another folder.
In my case, I had some reference to a jar file in catilana.bat, but the jar I had removed from my system. Tomcat started successfully once I removed that reference from catilana.bat
Check your JRE_HOME location in environment variables. if it didn't work then try
1). Open CMD in administration mode.
2). locate to your tomcat directory.
3). run startup.bat --->> It will show your problem.
Had the same problem with Apache Tomcat 9 version.
Solution is very simple.
Apache Tomcat 9 is supported by Java 8 and later versions. So, I had JRE_HOME with JRE7 path, I binded it to new JRE8 and everything works fine.
Different versions of Apache Tomcat are available for different versions of the Servlet and JSP specifications. The mapping between the specifications and the respective Apache Tomcat versions is:
I am new to JBOSS.I downloaded jboss-as-7.1.1.Final.zipand unzip this zip file.
Then I go to bin folder and double click on standalone.bat but new cmd window open and close within 2 -3 sec.
I tried to start server throught cmd.I open cmd in 2 ways
1.normally mode
Run as Admin (Admin Mode).
In 2 ways I get:
Calling "P:\Software\JBOSS\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
'findstr' is not recognized as an internal or external command,
operable program or batch file.
then it stops.
So the JBoss server does not start.
I added Environment Variables like.
JBOSS_HOME : P:\Software\JBOSS\jboss-as-7.1.1.Final
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21
How can I run JBoss server and deploy projects in it on Window 7?
Add the following value to Right Click My Compuer -> Advanced -> Environment Variables -> System Variables -> Select Path variable -> append the below value.
C:\WINDOWS\system32
It should work with that change.
#All, Finally I got it,why I am getting this problem 'findstr' is not recognized as an internal or external command, operable program or batch file.
Because the following path C:\Windows\System32 was not set in Environment variables. I found through google.I fix it and run my server it's working great.
Thank you guys for your valuable suggestions.
You have to go to your bin folder P:\Software\JBOSS\jboss-as-7.1.1.Final\bin\ and then execute run.bat or standalone.bat
If you still get errors, you should delete your entire JBoss folder and then install it again and try to run it with the default settings. Once you've confirmed that works, change the settings 1 by 1 so that you know which setting caused your server to not start up.
You could better add it in to any IDE(eclipse) and then deploy your application. That should be easy to manage your applications
I am using Tomcat 7.0 and I found a reference of how to change session savings into the database. But I don't get how to change
org.apache.catalina.session.StandardSession.ACTIVITY_CHECK to true
The link that I am referencing is http://www.intelligrape.com/blog/2010/07/21/tomcat-6-session-persistence-through-jdbcstore/
I am using localhost Tomcat 7.X downloaded as zip, MySQL 5.5, STS 3.1(Incuding Eclipse)
Any figuring out?
This is a system property ( http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html ) so to set these you have to specify the -D option. In your case "-Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true".
But where? Well, System Properties are given to the Java process when it starts. In case of Tomcat you can use a environment variable called $JAVA_OPTS which is given to the Java process on startup. So
export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
and then run Tomcat. For this to persist make sure that the user running catalina.sh has this environment variable always set.
add below line in catalina.bat just after where you found other JAVA OPTS already being set.
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
e.g.
rem Register custom URL handlers
rem Do this here so custom URL handles (specifically 'war:...') can be used in the security policy
set "JAVA_OPTS=%JAVA_OPTS% -Djava.protocol.handler.pkgs=org.apache.catalina.webresources"
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
I need to disable IPv6. For that the java documentation indicates setting jvm property java.net.preferIPv4Stack=true.
But I don't understand how to do it from the code itself.
Many forums demonstrated doing it from the command prompt, but I need to do it at runtime.
You can use System.setProperty("java.net.preferIPv4Stack" , "true");
This is equivalent to passing it in the command line via -Djava.net.preferIPv4Stack=true
Another approach, if you're desperate and don't have access to (a) the code or (b) the command line, then you can use environment variables:
http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html.
Specifically for java web start set the environment variable:
JAVAWS_VM_ARGS
and for applets:
_JPI_VM_OPTIONS
e.g.
_JPI_VM_OPTIONS=-Djava.net.preferIPv4Stack=true
Additionally, under Windows global options (for general Java applications) can be set in the Java control plan page under the "Java" tab.
I ran into this very problem trying to send mail with javax.mail from a web application in a web server running Java 7. Internal mail server destinations failed with "network unreachable", despite telnet and ping working from the same host, and while external mail servers worked. I tried
System.setProperty("java.net.preferIPv4Stack" , "true");
in the code, but that failed. So the parameter value was probably cached earlier by the system. Setting the VM argument
-Djava.net.preferIPv4Stack=true
in the web server startup script worked.
One further bit of evidence: in a very small targeted test program, setting the system property in the code did work. So the parameter is probably cached when the first Socket is used, probably not just as the JVM starts.
well,
I used System.setProperty("java.net.preferIPv4Stack" , "true"); and it works from JAVA, but it doesn't work on JBOSS AS7.
Here is my work around solution,
Add the below line to the end of the file ${JBOSS_HOME}/bin/standalone.conf.bat (just after :JAVA_OPTS_SET )
set "JAVA_OPTS=%JAVA_OPTS% -Djava.net.preferIPv4Stack=true"
Note: restart JBoss server
you can set the environment variable JAVA_TOOL_OPTS like as follows, which will be picked by JVM for any application.
set JAVA_TOOL_OPTS=-Djava.net.preferIPv4Stack=true
You can set this from the command prompt or set in system environment variables, based on your need. Note that this will reflect into all the java applications that run in your machine, even if it's a java interpreter that you have in a private setup.
System.setProperty is not working for applets. Because JVM already running before applet start. In this case we use applet parameters like this:
deployJava.runApplet({
id: 'MyApplet',
code: 'com.mkysoft.myapplet.SomeClass',
archive: 'com.mkysoft.myapplet.jar'
}, {
java_version: "1.6*", // Target version
cache_option: "no",
cache_archive: "",
codebase_lookup: true,
java_arguments: "-Djava.net.preferIPv4Stack=true"
},
"1.6" // Minimum version
);
You can find deployJava.js at https://www.java.com/js/deployJava.js
I have Java 1.6 and Tomcat 5.5 installed on my system.
But Tomcat 5.5 accesses Java 1.5 and hence as the outcome I get the error Bad version number in .class file while executing java code with JSP.
How can I change the Tomcat version to Java 1.6?
UPDATE
I tried changing the JVM that the tomcat5w.exe is pointing to the version 1.6 and now I am out of the Bad version in .class file error. But now, I get the following error.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.lang.NullPointerException
myfirst.SearchLink.checkURL(SearchLink.java:20)
org.apache.jsp.Test_jsp._jspService(Test_jsp.java:52)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
What might be the root cause?
When you open catalina.sh / catalina.bat, you can see :
Environment Variable Prequisites
JAVA_HOME Must point at your Java Development Kit installation.
So, set your environment variable JAVA_HOME to point to Java 6. Also make sure JRE_HOME is pointing to the same target, if it is set.
Update: since you are on Windows, see here for how to manage your environment variables
You can change the JDK or JRE location using the following steps:
open the terminal or cmd.
go to the [tomcat-home]\bin directory.
ex: c:\tomcat8\bin
write the following
command: Tomcat8W //ES//Tomcat8
will open dialog, select the java tab(top pane).
change the Java virtual Machine value.
click OK.
note:
in Apache TomEE same steps, but step (3) the command must be: TomEE //ES
If you use the standard scripts to launch Tomcat (i.e. you haven't installed Tomcat as a windows service), you can use the setenv.bat file, to set your JRE_HOME version.
On Windows, create the file %CATALINA_BASE%\bin\setenv.bat, with content:
set "JRE_HOME=%ProgramFiles%\Java\jre1.6.0_20"
exit /b 0
And that should be it.
You can test this using %CATALINA_BASE%\bin\configtest.bat (Disclaimer: I've only checked this with a Tomcat7 installation).
Further Reading:
http://tomcat.apache.org/tomcat-5.5-doc/RUNNING.txt - Section:
'Advanced Configuration - Multiple Tomcat Instances'
http://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt - Section: '(3.4)
Using the "setenv" script (optional, recommended)'
In Eclipse it is very easy to point Tomcat to a new JVM (in this example JRE6). My problem was I couldn't find where to do it. Here is the trick:
On the ECLIPSE top menu FILE pull down tab, select NEW, -->Other
...on the New Server: Select A Wizard window, select: Server-> Server... click NEXT
. on the New Server: Define a New Server window, select Apache> Tomcat 7 Server
..now click the line in blue and underlined entitled: Configure Runtime Environments
on the Server Runtime Environments window,
..select Apache, expand it(click on the arrow to the left), select TOMCAT v7.0, and click EDIT.
you will see a window called EDIT SERVER RUNTIME ENVIRONMENT: TOMCAT SERVER
On this screen there is a pulldown labeled JREs.
You should find your JRE listed like JRE1.6.0.33. If not use the Installed JRE button.
Select the desired JRE. Click the FINISH button.
Gracefully exit, in the Server: Server Runtime Environments window, click OK
in the New Server: Define a new Server window, hit NEXT
in the New Server: Add and Remove Window, select apps and install them on the server.
in the New Server: Add and Remove Window, click Finish
That's all. Interesting, only steps 7-10 seem to matter, and they will change the JRE used on all servers you have previously defined to use TOMCAT v7.0. The rest of the steps are just because I can't find any other way to get to the screen except by defining a new server. Does anyone else know an easier way?
There are several good answers on here but I wanted to add one since it may be helpful for users like me who have Tomcat installed as a service on a Windows machine.
Option 3 here: http://www.codejava.net/servers/tomcat/4-ways-to-change-jre-for-tomcat
Basically, open tomcatw.exe and point Tomcat to the version of the JVM you need to use then restart the service. Ensure your deployed applications still work as well.
On Linux, Tomcat7 has a configuration file located at:
/etc/sysconfig/tomcat7
... which is where server specific configurations should be made. You can set the JAVA_HOME env variable here w/o needing to create a profile.d/ script.
This worked for me.
test
open the termenal or cmd.
go to the [tomcat-home]\bin directory.
ex: c:\tomcat8\bin
write the following command: Tomcat8W //ES//Tomcat8
will open dialog, select the java tap(top tap).
change the Java virtual Machine value.