Setting up a local OC4J instance in Intellij - java

When I am developing I run my application locally on an OC4J instance on my PC and I can start the server from eclipse, deploy the application to OC4J with maven, view it in the browser and debug it in eclipse. I am trying get the same set up in IntelliJ.
The steps to set it up the server in eclipse are:
Preferences > Servers > Runtime Environments -> Add (Oracle > Oracle
OC4j Standalone 10.1.3n)
Open the server configuration/overview window from the servers view
Server Properties > set username, password, port etc
Click "Open Launch Configuration"
Arguments tab > set VM arguments
Classpath tab > User entries shows oc4j.jar ~ C:\oc4j\j2ee\home
Source tab > shows my project directory and a 'Default' directory
JRE tab displays the jdk I am using
When all this is set I can run the server from eclipse and debug my application.
I've done the following in IntelliJ (but it's not working...)
Run > Edit configurations
Add new configuration
Select JSR45 Compatible Server (I've read this is the one to choose for OC4J)
Give it a name, mainly use default values, add OC4J_JVM_ARGS to 'VM Options Variable' box
add -start to VM Options (I've also tried adding all the vm args from eclipse in here)
Startup/connection tab: add C:\oc4j\bin\oc4j.cmd to Startup script box (I can't add the oc4j.jar from C:\oc4j\j2ee\home)
Now when I try to run the server from intellij I get the following output:
C:\oc4j\bin\oc4j.cmd
Usage: oc4j.cmd [Options]
Options:
-start : start OC4J
-shutdown -port -password : stop OC4J
-version : display the version
-help : display this message
Disconnected from server
This seems to be normal and is what happens when you run C:\oc4j\bin\oc4j.cmd, but I don't know what start up script I should be setting in intellij
Can anyone advise? Where should I specify -user and -password in Intellij? Thanks a lot

It seems that the 'Startup script' and'Shutdown script' boxes on the Startup/Connection tab in IntelliJ are not just file inputs, you can also type commands in there. So OC4J can be started by changing my intellij steps as follows:
Run > Edit configurations
Add new configuration
Select JSR45 Compatible Server
give it a name
mainly use default values
add any VM Options you have
add OC4J_JVM_ARGS to 'VM Options Variable' box
Startup/connection tab:
add "C:\oc4j\bin\oc4j.cmd -start" to Startup script box
add "C:\oc4j\bin\oc4j.cmd -shutdown -port=(your port number) -password=(your password)" to Shutdown script box
OC4J can now be started from intellij

Related

How can I increase the -XXMaxPermGen jvm settings in Jboss under MyEclipse?

When I start Jboss on My Eclipse, server is started with following vm arguments
INFO [ServerInfo] VM arguments: -Djboss.home=C:\JBoss -Djava.library.path=C:\Program Files (x86)\Java\jdk1.6.0_30\bin -Djava.endorsed.dirs=C:\JBoss\lib\endorsed -Xms128m -Xmx512m -XX:MaxPermSize=256m
When I insert a big persistence object, I am getting out of memory exceptions. Jboss should be started -Xms512M -Xmx1024M .I have checked myeclipse ini file, I have change run.bat, run.conf.bat. I could not find where Myeclipse is reading this value.
Can you please show me the way to change jboss vm setting in MyEclipse 2014?
When I select Manage Launch Configuration, this ui is shown
This is jboss definition in Run Configuration Panel
Go to Server window
Double click on ths JBoss server
Under General Information, there is a link - Open Launch Configuration, click on it.
Window will open click on Arguments subtab.
Change VM arguments and Apply.
Restart Server.
Please follow the below steps :
Option 1 :
1) Open the server (double click on server)
2) Open launch Configuration
3) Go to argument tab
4) VM Arguments
and set your flag.
5) Restart Eclipse
For Graphical view
Option - 2:
1) Go to below path :
Window::Preferences::Java::Installed JREs::Edit::Default Vm Arguments:
2) Select variables button.
3) give any name suppose - vmargs
4) Edit variables
5) Select new button.
6) Add name name suppose vm (add the value size as per your requirement)
value : -Xmx1024M -Xms1024M -XX:PermSize=2048m -XX:MaxPermSize=2048m
7) Select ok
8) Restart your eclipse.
To change the memory settings for the JBoss server :
Go to Window > Preferences > MyEclipse > Servers > JBoss > expand JBoss x.x > JDK > Optional Java VM Arguments.

Debugging applet in war file using eclipse on win8. java 7 15

I'm unable to debug applet when it is in the WAR file. I use Eclipse IDE and Win8. My java version is 7 15.
I'm going to list my steps and maybe there is something that I do wrong:
1) First of all, I go to "Control panel->Programs->Java", then on "Java" tab I select "View". New window opens.
2) Then I enter the following line into "Runtime parameters": (without quotes) "-Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=1888,suspend=n", then I click "OK", "OK".
3) In Eclipse IDE I build war file.
4) Then I navigate to "Servers" tab, right click on my tomcat server and select "Debug". Now I can reach my project on my browser using this address: "localhost:8080/myProjectName".
5) On Eclipse IDE I go to "Run->Debug Configurations...->", then I select "Remote JAVA application" tab. Let's say there are no elements on that tab, so I right click on "Remote JAVA application" and select "New".
6) I set connection type to "Standart (Socket Attach)" and then I set "port" to 1888 and host to "localhost", then I click apply.
7) After clicking apply I do not close that window and I click "Debug". Window closes and IDE spits out error window "Problem occured. 'Launching myProjectName(1)' has encountered a problem. Failed to connect to remote VM. Connection refused."
--- Additional info ---
I use java server pages on this project too and then I set
JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
in catalina.bat file and run server from command line by typing
catalina.bat jpda start
I'm able to debug java beans, but not the applets.
This is because beans are running on the server side and the applet runs on the user side.
My whole application or applet was not signed, so my system failed to attach runtime parameters for debugging from Java Control Panel.

Not able to run psservice.exe and plink.exe from servlet deployed in Tomcat 6.0 using runtime exec and processbuilder

I am trying to run psservice.exe and plink.exe from servlet using runtime exec. It will be used for starting or stopping services on remote computer running windows and unix aix.
I have set system variables so that i am able to run them from command prompt. These commands are running perfectly from command prompt and java program
I am using below code in Servlets for remote windows machine
Runtime.getRuntime().exec(serverPropLoader.getServerProperties("psservice \\\\172.xx.xx.xx -u username -p password stop MySQL"));
I am using below code in Servlets for remote unix aix 5.3 machine
Runtime.getRuntime().exec(serverPropLoader.getServerProperties("PLINK.exe -ssh -pw "password" username#172.xx.xx.xx /home/mysql/stopservice.sh"));
Below are my observations :
If i run above statement from Eclipse (ver 3.4.2) using Tomcat6 it runs perfectly fine, but if export my web app as WAR and deploy it in Tomcat6 mannually it dosen't run. ( i have tried deploying it in mine and other system)
I have tried puting these command in Batch file and calling it from servlet but no success. From Batch file "net" and "sc" command are working but i am not able to run pservice and plink command. also "sc" command is working for local processes only.
After execution of servlet i am able to see psservice.exe and plink.exe in windows task manager but required services on local and remote system is not starting / stopping
The problem here is, you need to add admin previladges for the tomcat user.
Because this Apache Tomcat Monitor program requires permission to interact with system services, it cannot be executed as a standard user.
Do following tasks, you will be fine
Locate the tomcat7w.exe program in Windows Explorer (the default directory is C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin).
Right-click the name of this file and select the Properties context menu item.
The tomcat7w Properties dialog displays.
Select the Compatibility tab and click either the "Show settings for all users" button or the "Change settings for all users" button at the bottom of the dialog.
A new tomcat7w.exe Properties dialog displays with a single tab entitled Compatibility for all users.
At the bottom of this dialog, in the Privilege Level group box, select the Run this program as an administrator.
The Apache Tomcat Monitor executable will now execute with the required privileges when run from a standard user account.
for more information pls refer
https://supportcontent.ca.com/cadocs/0/CA%20Automation%20Point%20Base%2011%204-ENU/Bookshelf_Files/HTML/AP--RelNotes/index.htm?toc.htm?2009998.html

debugging java application deployed in tomcat

I have an application that I deployed in tomcat. Later I configured the code as a project in Eclipse. I want to connect to the tomcat via eclipse and debug the application.
Trying to setup a remote debug connection is throwing up errors. Is there any entry that I need to add somewhere in tomcat?
First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the start command, and change it to jpda start. This will cause Tomcat to start in debugging mode listening on port 8000.
Next, to connect to this process via Eclipse, select the Run menu and choose Debug Configurations.... In the pane on the left, choose Remote Java Application and click the New launch configuration button above the list. The important settings to note are the Host and Port fields. The host value must match the hostname of the Tomcat process, and the port should be 8000. You also might need to add entries on the Source tab to ensure that all of the source code is available to step through.
Create a new tomcat server
Create a new dynamic web project
Export war to tomcat server
Tomcat debug configuration(important), first double click tomcat server, then select "Use Tomcat installation (takes control of Tomcat installation)"
Add breakpoints
Run tomcat in debug mode
Test war in web browser
Edit source path
Debug source code in Tomcat
The war file is available here.
yes, you need to configure tomcat to accept remote debugging connections. There is a FAQ on how to do it with various IDEs.
http://wiki.apache.org/tomcat/FAQ/Developing#Q2
Simply change the line in startup.bat (if you are using Windows)
from:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to:
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Right Click on the project you want to debug and go to Debug As Menu and in the list click on Debug Configurations.
Then Double click on the Remote Java Application from left menu list. browse for the project u wanna add in then click apply.
Also change the listening port to 7999, then after you started the web app from your localhost click the debug button on the same window. Then any break point's will be hit after that.
Steps to setup the tomcat Debugger with eclipse
Install the following things:
java 1.8+
eclipse EE version
download tomcat 8+
open eclipse and go to servers tab and add a new server(window-> show View-> Others -> Search Servers)
Mark your project as Dynamic web Project(Rightclick on Project-> project facets -> select Dynamic web module)
Export war (File-> Export-> search war -> select module and choose the path)
Run as -> Run on Server
Start the tomcat Server in Debug or Run Mode
check on localhost:8080
Debug worked for me. I was using tomcat 8, configured on centos 7. Debug port opened for me after changing 2 settings.
Open tomcat/conf/bin/startup.sh and added below lines
export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
In the same file startup.sh, added jpda before start command.
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$#"
Restart the tomcat.
In eclipse go to Run>Debug configuration>Remote java application>Add host ip and port(8000) where tomcat is running.
In my case i required to open 8000 through firewall too.
firewall-cmd --zone=public --permanent --add-port=8000/tcp
firewall-cmd --reload
Beside remote debugging, you can debug your app locally within eclipse if you added tomcat in eclipse.
just start server and wright click your app and from debug menu hit debug on server.
If you have multi module maven project, debug on server just shown up for module with war packaging.
If you want debug a class that runs at startup by self, like methods that annotated with #PostConstruct, remember that you should increase server timeout.
To do that, go to server view and double click on tomcat and in server preview tab, increase the timeout value.

How to change Java version used by TOMCAT?

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.

Categories