I want to basically upgrade my tomcat version(on RHEL).
Always worked in an environment where my war file would be dumped into */webapps, on restart of tomcat, the war file would expand and the rest is history.
Now, the system I'm working on, has completely different folder structure.
Something like this:
[root#bliss ~]# ls /usr/local/blah/blu-app/WEB-INF/
accounts faces-reports.xml logging.properties web-app_2_3.dtd
bin faces-syscfg.xml logging.properties-production web-app_2_4.xsd
buildnum.txt framework2007 perl web.xml
classes host.xsd settings work
deploy-root java.policy tags
events.xsd lib tld
[root#bliss ~]#
I can see some tomcat related jars here:
/usr/local/blah/blu-app/WEB-INF/lib/tomcat-http.jar
/usr/local/blah/blu-app/WEB-INF/lib/tomcat-util.jar
/usr/local/blah/blu-app/WEB-INF/lib/tomcat-coyote.jar
UPDATE
So I did find out that the tomcat is embedded 'cuz I found the following code starting it:
tomcat = new Embedded();
tomcat.setCatalinaHome(targetPath);
Host host = tomcat.createHost("localhost", targetPath);
Context rootCtx = tomcat.createContext("", targetPath);
((StandardContext)rootCtx).setWorkDir("WEB-INF/work");
ServletContext servletContext = rootCtx.getServletContext();
servletContext.setAttribute("version", version);
ApplRealm realm = new ApplRealm(servletContext);
tomcat.setRealm(realm);
rootCtx.setPrivileged(true);
Engine engine = tomcat.createEngine();
engine.setName("tomcat");
engine.setDefaultHost("localhost");
host.addChild(rootCtx);
engine.addChild(host);
tomcat.addEngine(engine);
LOG.debug("starting tomcat");
tomcat.start();
LOG.debug("tomcat started");
// clear out any old sessions: see bug 17882
Session[] sessions = rootCtx.getManager().findSessions();
for (int i = 0; i < sessions.length; i++)
{
sessions[i].expire();
}
ServerSocket socket = null;
socket = new ServerSocket(CmcUtils.getControlPort(), 2, InetAddress.getByName("127.0.0.1"));
socket.accept();
LOG.info("Received shutdown command. Exiting !");
tomcat.stop();
The question then is, how do I upgrade this tomcat to say Tomcat6?
Replace with the latest jars in WEB-INF/lib? Which all jars?
It depends. It could be an embedded tomcat but it could also be a heavily customised tomcat configuration.
Check the startup script to determine which class is being invoked. If its the usual catalina its not embedded its just that they changed the config to point to another folder instead of webapps.
If it is indeed embedded then to upgrade u would need to replace the tomcat jars with new ones.
In tomcat we can create virtual hosts,i.e, making tomcat recognize application's which are deployed in external folders.
A lot more information can be found here.
http://tomcat.apache.org/tomcat-5.5-doc/config/host.html
In your given scenario, try to lookup in server.xml, which is usually found in conf folder of tomcat home.
Related
As title says, I can't contact my EJB from a distant machine. The client trying to contact the EJB-hosting machine works perfectly when used locally.
The remote machine is on Windows XP SP3 (32 bits) with Java JRE 7_71. It's connected to the same network as the machine running the EJB on a Glasshfish server.
The second machine (which is running the Glasshfish server) runs on Win7 x64. Are installed JDK 1.7_75, JDK 1.8_25, jre1.8.0_25 and JRE 7_71.
All firewalls are disabled. No proxies used. Just 2 machines behind a router connected to internet.
I'm programming with NetBeans 8.0.2, with a Glasshfish server 4.1.
Here's what it looks like :
http://imgur.com/zl05ACG
"ABEJB" is my EJB. In Properties > Sources, the "Source / Binary Format is JDK 7. In Properties > Libraries, I added the JDBC driver (works well) and set the Java Platform to "JDK 1.7".
Note : When I'm deploying my EJB on Glassfish, I got these infos :
Infos: Portable JNDI names for EJB AJoyfulBean: [java:global/ABEJB/AJoyfulBean!EJB.NewSessionBeanRemote, java:global/ABEJB/AJoyfulBean]
Infos: Glassfish-specific (Non-portable) JNDI names for EJB AJoyfulBean: [ABS/AJoyfulBean#EJB.NewSessionBeanRemote, ABS/AJoyfulBean]
NewSessionBean.java :
#Stateless(name = "AJoyfulBean")
public class NewSessionBean implements NewSessionBeanRemote
{
#Override
public String testConnexion()
{
String retour = "Connected to : " + System.getenv("COMPUTERNAME");
try
{
retour += " / " + InetAddress.getLocalHost();
}
catch (UnknownHostException ex)
{
retour += "unknown IP ! :(";
}
return retour;
}
}
NewSessionBeanRemote.java
#Remote
public interface NewSessionBeanRemote
{
String testConnexion();
}
sun-ejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>AJoyfulBean</ejb-name>
<jndi-name>ABS/AJoyfulBean</jndi-name>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
"A Better Stock" is my Java application on a remote machine. In Properties > Sources, the "Source / Binary Format is JDK 7. In Properties > Libraries, I added the "Java EE from GlassFish" libraries from NetBeans and the "gf-client.jar" from the Glassfish installation repertory. The Java Platform is set to "JDK 1.7".
The EJB interface is the same as my EJB (I don't get a Marchal exception anyway).
Inside a static method on my main class :
try
{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.164"); // the IP of the machine hosting the glassfish server
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(props);
NewSessionBeanRemote myEJB = (NewSessionBeanRemote) ctx.lookup("java:global/ABEJB/AJoyfulBean!EJB.NewSessionBeanRemote"); // Tried "ABS/AJoyfulBean#EJB.NewSessionBeanRemote" too
jTextAreaInformations.setText(jTextAreaInformations.getText() + "\n" + myEJB.testConnexion());
}
catch (Exception ex)
{
jTextAreaInformations.setText(jTextAreaInformations.getText() + "\n" + ex.toString());
}
MANIFEST.MF :
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.8.0_25-b18 (Oracle Corporation)
Class-Path: lib/javax.annotation-api.jar lib/jaxb-api.jar lib/webservi
ces-api-osgi.jar lib/bean-validator.jar lib/javax.batch-api.jar lib/j
avax.ejb-api.jar lib/javax.el.jar lib/javax.enterprise.concurrent-api
.jar lib/javax.enterprise.concurrent.jar lib/javax.enterprise.deploy-
api.jar lib/javax.faces.jar lib/javax.inject.jar lib/javax.intercepto
r-api.jar lib/javax.jms-api.jar lib/javax.json.jar lib/javax.mail.jar
lib/javax.management.j2ee-api.jar lib/javax.persistence.jar lib/java
x.resource-api.jar lib/javax.security.auth.message-api.jar lib/javax.
security.jacc-api.jar lib/javax.servlet-api.jar lib/javax.servlet.jsp
-api.jar lib/javax.servlet.jsp.jar lib/javax.servlet.jsp.jstl-api.jar
lib/javax.servlet.jsp.jstl.jar lib/javax.transaction-api.jar lib/jav
ax.websocket-api.jar lib/javax.ws.rs-api.jar lib/javax.xml.registry-a
pi.jar lib/javax.xml.rpc-api.jar lib/jaxb-osgi.jar lib/webservices-os
gi.jar lib/weld-osgi-bundle.jar lib/jaxm-api.jar lib/gf-client.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: a.better.stock.UI.Accueil
When I'm running the .jar file of my client (with the /lib folder) on the machine hosting the glassfish server, my EJB is contacted and correctly do the tasks required (updating SQL tables).
But when I copy the .jar file and /lib folder to the distant machine and execute it, it get this exception :
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory
[Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
So basically, why am I getting this exception ? I'm giving the context. And anyway, it works on local but not on remote client. Weird.
how do you start your client? from which directory? the same as on your local directory? perhaps it could be that your class path of your client is not correct? or even incomplete?
i think it could be that some jar files from lib/ folder require other jars in the correct folder structure. you can see that for example in the appserv-rt.jar/META-INF/MANIFEST.MF. there you can find the "Class-Path: ../lib/gf-client.jar" entry. the solution could be that you run your client from within the lib/ folder or from within the bin/ directory as glass fish does..
please check if your container (glassfish) is listening on port 3700.
on windows http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/netstat.mspx?mfr=true
netstat -a -n -o
if it is running, try a telnet to the port
telnet <yourglassfishIP> 3700
If you can type anything and the telnet does not terminate immediately your port is open.
In case of open port, check if you have configured glassfish to accept remote EJB calls.
I'm running Jetty as a service (followed these instructions) on an Ubuntu 14 server. It's been configured to run on port 9000, and it seems to this just fine.
On the same server, I have a solr instance folder (it's located outside of jetty, as part of a website).
What I would like, is to be able to browse to hostname:9000/solr and hostname:9000/solr/admin and then see/manage the data that's in my solr instance folder, but all I ever get from the Jetty service are 404-errors.
The instance itself works perfectly if I start it manually by running 'java -Djetty.port=9000 -jar start.jar' - however, this is not what I want.
What do I need to do?
Edit: Here is the output from service jetty check
root#ubuntu14:/opt/web/mybase/webapps# service jetty check
Checking arguments to Jetty:
START_INI = /opt/web/mybase/start.ini
JETTY_HOME = /opt/jetty/jetty-distribution-9.2.7.v20150116
JETTY_BASE = /opt/web/mybase
JETTY_CONF = /opt/jetty/jetty-distribution-9.2.7.v20150116/etc/jetty.conf
JETTY_PID = /var/run/jetty.pid
JETTY_START = /opt/jetty/jetty-distribution-9.2.7.v20150116/start.jar
JETTY_LOGS = /opt/web/mybase/logs
JETTY_STATE = /opt/web/mybase/jetty.state
CLASSPATH =
JAVA = /usr/bin/java
JAVA_OPTIONS = -Dsolr.solr.home=/var/www/mywebsite/private/my-solr-4.7 -Djetty.logs=/opt/web/mybase/logs -Djetty.home=/opt/jetty/jetty-distribution-9.2.7.v20150116 -Djetty.base=/opt/web/mybase -Djava.io.tmpdir=/opt/jetty/temp
JETTY_ARGS = jetty.state=/opt/web/mybase/jetty.state jetty-logging.xml jetty-started.xml
RUN_CMD = /usr/bin/java -Dsolr.solr.home=/var/www/mywebsite/private/my-solr-4.7 -Djetty.logs=/opt/web/mybase/logs -Djetty.home=/opt/jetty/jetty-distribution-9.2.7.v20150116 -Djetty.base=/opt/web/mybase -Djava.io.tmpdir=/opt/jetty/temp -jar /opt/jetty/jetty-distribution-9.2.7.v20150116/start.jar jetty.state=/opt/web/mybase/jetty.state jetty-logging.xml jetty-started.xml
Jetty running pid=4728
First make sure you have deployed the solr.war file correctly into Jetty as described here. Basically you have 2 options -
Copy the war file into the JETTY_HOME/webapps directory
Add the war file path into $JETTY_HOME/contexts/context.xml file
This will deploy Solr into jetty.
To run Solr, set the Dsolr.solr.home system property to point to your Solr root directory e.g. java -Dsolr.solr.home= -jar start.jar
I have a dedicated root server with CentOS and Apache Tomcat 7.
The Servlet in Tomcat7 works well, but dont get a connection/data from the database.
On my local system with eclipse it worked well. I exported the database from my local system and imported it with phpmyadmin on the server.
Same username, same passwort.
As host ive tried
final String host = "jdbc:mysql://localhost/table"; and
final String host = "jdbc:mysql://localhost:3306/table";
What could be the Problem? I dont know what to do.
This java.lang.ClassNotFoundException: com.mysql.jdbc.Driver is when you dont have the mysql-connector-java.jar in your classpath Download one fron here and put it in the classpath
On machine1, I installed apache tomcat 7 listening on port 9999 and copied a sample.html file in ../webapps/dummy folder of tomcat machine.I was able to access the resource with URL http://localhost:9999/dummy/sample.html
On machine2, Tomcat is already part of some product listening on port 8080 which i thought of utilising it for my sample test. So, I copied a sample.html file in ../webapps/dummy folder of tomcat machine. I was unable to access the resource with URL http://localhost:8080/dummy/sample.html
On machine2, I have existing servlet programming modules running in another folder ../webapps/xyz.
My question:
I am trying to understand, What are the list of things that i need to verify on machine, which let me know, why i have an issue in accessing the URL(above) on machine2? Is this something to do with http access configuration like basic.user/basic.groups file?
It has nothing to do with the port on which tomcat is running.
Did you restart Tomcat after copying file over? It might be that on machine2 it's not configured to run in a dev mode so it doesn't pick up changes at runtime.
or
(if this is linux/unix/mac computer) Tomcat on machine2 is running as tomcat:tomcat user, but file you copied can't be read by this user. Change the permissions of the file.
HTH,
Jan
I am trying to connect to the ejb service in glassfish server through Java Web start.
I am getting the following error while getting the initial context. I have also added the code snippet for getting the initial context.
One interesting is when I run the program as a simple java program outside of java web start in a netbeans IDE, it is working fine.
I added all the relevant jar files from the glassfish modules folder into the java web start.
java.lang.NullPointerException
at com.sun.enterprise.naming.impl.SerialContext.<init>(SerialContext.java:275)
at com.sun.enterprise.naming.impl.SerialContext.<init>(SerialContext.java:334)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.createInitialContext(SerialInitContextFactory.java:358)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:353)
at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:69)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at gov.ca.lc.util.ServiceLocator.getInitialContext(ServiceLocator.java:140)
at gov.ca.lc.util.ServiceLocator.getVotesEJB(ServiceLocator.java:103)
at gov.ca.lc.scenemanagement.AbstractVotingScene.getCommitteeList(AbstractVotingScene.java:143)
at gov.ca.lc.scenemanagement.AbstractVotingScene.<init>(AbstractVotingScene.java:65)
at gov.ca.lc.scenes.MenuScene.<init>(MenuScene.java:56)
at gov.ca.lc.menu.StartVoting.startUp(StartVoting.java:47)
at org.mt4j.MTApplication.setup(MTApplication.java:328)
at processing.core.PApplet.handleDraw(PApplet.java:1580)
at processing.core.PApplet.run(PApplet.java:1502)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Animation Thread" java.lang.NullPointerException
at gov.ca.lc.scenemanagement.AbstractVotingScene.getCommitteeList(AbstractVotingScene.java:143)
at gov.ca.lc.scenemanagement.AbstractVotingScene.<init>(AbstractVotingScene.java:65)
at gov.ca.lc.scenes.MenuScene.<init>(MenuScene.java:56)
at gov.ca.lc.menu.StartVoting.startUp(StartVoting.java:47)
at org.mt4j.MTApplication.setup(MTApplication.java:328)
at processing.core.PApplet.handleDraw(PApplet.java:1580)
at processing.core.PApplet.run(PApplet.java:1502)
at java.lang.Thread.run(Unknown Source)
Following is my code to get the initial context
private static InitialContext getInitialContext()
throws NamingException {
Properties props = null;
try{
// props=new Properties();
// props.load(new FileInputStream(new File("jndi.properties")));
// System.out.println(props.get("java.naming.factory.initial"));
props=new Properties();
props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs ", "com.sun.enterprise.naming");//ur server ip
props.setProperty("java.naming.factory.state ", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");//ur server ip
props.setProperty("org.omg.CORBA.ORBInitialHost", "165.107.33.181");//ur server ip
props.setProperty("org.omg.CORBA.ORBInitialPort","3700"); //default is 3700
}catch(Exception ex){
ex.printStackTrace();
}
return new InitialContext(props);
}
I have the same problem. I use JMS and I need to add other jars. At first I tried using gf-client.jar, but it does not work through Java Web start. So I've added jars listed in
Connecting a remote JMS client to GlassFish 3 . It works outside of Java Web start.
I don't know what the relevant jar files are for you, but just in case we have a different view on that area: I use just appserv-rt.jar and java-ee.jar using the same properties you use for initial context and it works fine. Don't add anything else you don't need and try again.
package-appclient in glassfish/bin creates appclient.jar that include jars for client. Then unpack it on a client and use gf-client.jar as usual.
I would like to add that all these set up will work only if you have the glassfish installed in your machine. If you deploy the java webstart app in a machine which doesn't have the glassfish server then we will end up getting the same exception. The reason is that if you open the appserv-rt.jar it points to the gf-client.jar and if you look into the gf-client.jar it points to a whole bunch of jar files in modules folder. So I suppose, essentially we need the all the jar files pointed by the gf-client.jar.