I have a JavaEE application with EJB, deployed in glassfish. If i add the connection pools, jndi resources, jms resources to the glassfish, then the project is working fine. But is there anyway i can do these things without adding these configurations from the glassfish admin console.
The purpose for this is, when i need to send my project to another person, he/she will also have to add these configs to glassfish. I need to prevent it
Best way to achieve this are probably command line scripts (bat, sh). There you can administrate GlassFish using the asadmin command. Here is a list of all asadmin subcommands: http://docs.oracle.com/cd/E18930_01/html/821-2416/gcode.html
Example to add a JNDI resource:
asadmin create-jndi-resource --user admin --passwordfile passwords.txt
--host pigeon --port 4001 --jndilookupname sample_jndi --restype queue
--factoryclass sampleClass --description "this is a sample jndi
resource" sample_jndi_resource
(Example source: http://docs.oracle.com/cd/E19879-01/820-4332/6nfq988q6/index.html)
Related
I am creating a web application in which there will be multiple subdomain. Each client will be having its own subdomain. Each subdomain will have individual database. For example I am having a client abc, then it will have subdomain as abc.mydomain.com and its database name will be abc.
Now this application is created in spring boot. Here I want to configure wildcard subdomain. So how can I configure it in spring boot. For this, I had tried few solution.
I had changed my /etc/hosts and added an domain name entry in it as below
127.0.0.1 www.mydomain.com
But now I want subdomain in this. How can I do it.
I had seen somewhere that I need to configure server.xml of tomcat. In server.xml I had added below line.
<Host name="www.mydomain.com" appBase="webapps" unpackWARs="true"
autoDeploy="true">
<Alias>*.mydomain.com</Alias>
</Host>
Can you please help me with this. Also let me know incase you need more details in this.
After been working for multiple days I came to a solution for this question. As I was working for wildcard subdomain in localhost. Thus for this I need to use an external software called dnsmasq, I had executed following commands to install dnsmasq in my laptop.
brew install dnsmasq
After installing dnsmasq in my laptop I need to to configure it. For this I have to update the dnsmasq. For my case it is located at
/usr/local/etc/dnsmasq.conf
In this file I have to add few lines to configure wildcard subdomain. Lines are as below.
# Route all *.mydomain.com addresses to localhost
address=/mydomain.com/127.0.0.1
# Don't read /etc/resolv.conf or any other configuration files.
no-resolv
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
Next I need to restart my dnsmasq service. Command for it is as below.
sudo brew services start dnsmasq
Finally you need to create a file mydomain.com at /etc/resolver (Create folder resolver if not exists). Add below line in mydomain.com file.
nameserver 127.0.0.1
This is the complete configuration for setting up swildcard subdomain in your mac os.
For reference you can follow this link
I install JBoss 3.0.1 and it functions well both Apache on port 80 & Tomcat8 on port 8080. I deploy a sample war file from Tomcat and can view it at http://localhost:8080/sample/.
So is it possible to map it on Apache, then we can access it at http://localhost/sample/? If yes, can you please help me how to do that? Any suggestion would be appreciated.
Update: For POC purpose, the OS is Windows 7
You can do it by means of AJP. You don't specify what OS are you using, but I will assume it is GNU/Linux, although instructions for MS Windows will be similar.
The procedure is the following:
Install Apache module for AJP, usually it is called something like libapache2-mod-jk. (In debian/ubuntu you can run sudo apt-get install libapache2-mod-jk).
Then you will have a new module calledjk or similar. You have to enable it (In debian/ubuntu you can run sudo a2enmod jk).
Default configuration will serve mostly, open it a see where does JkWorkersFile point. This file is needed to configure the workers that manage communication with tomcat apps.
Create workers file (if it does not exists). A workers file is more or less as following.
Sample workers file:
ps=/
worker.list=worker1,worker2,...
# worker1 definition
worker.worker1.port=8009
worker.worker1.host=192.168.1.23
worker.worker1.type=ajp13
# worker2 definition
....
Every worker can point to different tomcat server. Port must be the same that configured into $CATALINA_HOME/conf/server.xml. In this file there is a connector for AJP protocol:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Every worker has to point to this port.
Finally, you can configure virtual host, locations, etc. into Apache with JkMount workerName to indicate Apache that this url has to be forwarded to the proper worker.
There are plenty of samples an documentation. Here you are with Tomcat official docs: https://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
Hope it helps!
Edit
If you are using MS Windows, you can download mod_jk from this url https://tomcat.apache.org/download-connectors.cgi
Install it and configure as suggested. Due to you want to map this url http://localhost/sample to tomcat app in http://localhost:8080/sample Your configuration must be the following:
workers file (Review port with server.xml tomcat conf file):
worker.list=worker1
# worker1 definition
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
Apache Location directive (Review order, deny and allow to suit your needs):
<Location /sample/>
JkMount worker1
Order deny,allow
Deny from all
Allow from localhost
</Location>
I have an issue setting up an rmi port on Apache Tomcat server
(set JAVA_OPTS=%JAVA_OPTS% -DlocalRmiRegistryPort=9401)
Here are the steps i have done and getting the error respectively.
Issue with MoSKito tool while configuring RMI port on Tomcat
I am also tried to configure MoSkito inspect on my java web application. as part of it, i have been trying to make RMI port using "set JAVA_OPTS=%JAVA_OPTS% -DlocalRmiRegistryPort=9401" on catalina.bat. there is no error as such but 9401 is not getting connected.
Steps followed:
1) My OS is Windows 7
2) I have installed Apache Tomcat v7
3) I have downloaded Moskito inspect .war file from http://www.moskito.org/download.html and
4) Installed Moskito inspect on my tomcat server, the MoSKito inspect web UI is loading good.
5) I have created a sample java web application and deployed on same tomcat server. and web application also working good.
6) Now i have taken step to configure RMI port 9041 using below command on \bin\catalina.bat file(since i am on Windows OS).
I have put the below command on top of the file in \bin\catalina.bat
set JAVA_OPTS=%JAVA_OPTS% -DlocalRmiRegistryPort=9401
7) and started tomcat server, and then opened Moskito application on browser and gone to Quick Connect option on and given localhost and rmi port 9401 to call remote invocation.
Its failed.... its always giving error as MoSKito encountered an error:
Cannot connect to localhost#localhost:9401, due: Can not resolve manually set reference. Server at localhost, port: 9401 is down or not properly configured
[net.anotheria.moskito.webui.util.APILookupUtility.findRemote(APILookupUtility.java:168), net.anotheria.moskito.webui.util.APILookupUtility.findRemote(APILookupUtility.java:142), net.anotheria.moskito.webui.util.APILookupUtility.getAdditionalFunctionalityAPI(APILookupUtility.java:113),
Q1: How to set -DlocalRmiRegistryPort=9401 on tomcat on Windows OS.
Q2: Once we set port, how to ensure port is set properly and its up and ready state for connection.
Q3: Once port is set properly, then how to set / configure specified java web application needs to be configured for MoSKito, since we could have more than one java web application on same tomcat server.
Please guide me, thank you :)
in order to be able to connect to a MoSKito monitored application you have to enable an agent that binds itself to port 9401 and answers your replies. To do so, you have to add a dependency to your pom (if you are using maven):
<!-- Enabling MoSKito Inspect Embedded -->
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-inspect-remote</artifactId>
<version>${moskito.version}</version>
</dependency>
Please keep in mind that the current MoSKito version is 2.5.4
If you are using a servlet 3.0 compatible container (tomcat 7, jboss wildfly) you are done. If you are using an older container you may need to add following to your web.xml:
<listener>
<listener-class>net.anotheria.moskito.webui.embedded.StartMoSKitoInspectBackendForRemoteListener</listener-class>
</listener>
If you are using no container at all, you can start it manually:
net.anotheria.moskito.webui.embedded.StartMoSKitoInspectBackendForRemote.startMoSKitoInspectBackend()
Now for you questions:
Q1: via catalina.bat. You were doing it correctly.
Q2: if the agent is configured everything will work correctly.
Q3: You may want to check out step by step guide here:
http://blog.anotheria.net/msk/the-complete-moskito-integration-guide-step-1/
Regards
Leon
I am new to glassfish and java ee programming. I am using Netbeans. When I try to deploy my web application to glassfish server, my project output shows
The module has not been deployed.
And in the glassfish server log:
WARNING: There is no cluster named localhost in this domain.
SEVERE: There is no instance named localhost in this domain.
Any comment would be helpful. thanks guys.
In glassfish/domains folder is there a domain called domain1 (default name). if not you need to create a new domain. if there is one then make sure under glassfish/domains/domain1 a file domain.xml points to all instances of localhost
Hi
We started to create our applications with J2EE. We now created a Webservice and deployed it to the Glassfish Server. We have written an apache proxy rule to access it via https://our.server.com/webservice-war (only https port is open to that server):
ProxyRequests Off
ProxyPass /webservice-war http://our.server.com:8080/webservice-war
ProxyPassReverse /webservice-war http://our.server.com:8080/webservice-war
Now everything works fine, but when we go to the to the ServiceEndpoint page (which is automatically generated) there is a link to the WSDL page:
http://our.server.com:8080/webservice-war/HostaliasSearchImplService?wsdl
which is obously wrong (Glassfish listens to port 8080). and also https is changed to http
Anyone an idea how I can fix it, that the automatically generated link is:
https://our.server.com/webservice-war/HostaliasSearchImplService?wsdl
BR, Rene
I discovered what I consider to be a very simple and elegant way to deal with the issue: use mod_substitute. Since those of us with this problem are already using Apache, and it's built in and simple, I liked this approach best.
I put a block similar to the below in one of my Apache conf files and found joy:
<Location />
AddOutputFilterByType SUBSTITUTE text/xml
Substitute "s|http://internal:8080/foo|https://external/foo|ni"
</Location>
Found the solution!
Anonym gave me a good hint about mod_jk. So here the complete configuration (for RHEL5).
First of all Download the mod_jk module for apache: http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/x86_64/
Put in in the modules directory /etc/httpd/modules and make it executeable:
chmod +x mod_jk-1.2.31-httpd-2.2.x.so
After that create /etc/httpd/conf/workers.properties:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
The Port 8009 is the where the Glassfish jk connector listens (we come to that later).
No we have to configure mod_jk, therefore create the file: /etc/httpd/conf.d/mod_jk.conf with the following content:
LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.x.so
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /atsi-war to worker named worker1 (ajp13)
JkMount /yourapp-war/* worker1
(This means everything from your http://apache.webserver.com/yourapp-war/ will bi redirected to Glassfish yourapp-war application context)
Important, if you are using virtual hosts on apache, you have to set the option:
JkMountCopy On
for your virtual servers. Explication:
If this directive is set to "On" in
some virtual server, the mounts from
the global server will be copied to
this virtual server, more precisely
all mounts defined by JkMount or
JkUnMount.
Now we have to create the jk connecter in glassfish:
asadmin create-http-listener --listenerport 8009 --listeneraddress 0.0.0.0 --defaultvs server jk-connector
asadmin set configs.config.server-config.network-config.network-listeners.network-listener.jk-connector.jk-enabled=true
Restart Glassfish, and everything sould work.
As for rewriting the https -> http, I'm not sure that's possible(yet) without using mod_jk, see here
, but see also this little guide
Though, generally, you'll need configure Glassfish and set http.proxyPort (and probably http.proxyHost too). Hopefully that should reflect in the autogenerated WSDL URL.
Here's 3 different ways to do this:
1
Use asadmin (in the Glassfish bin/ directory, run
asadmin create-jvm-options "-Dhttp.proxyPort=80"
asadmin create-jvm-options "-Dhttp.proxyHost=our.server.com"
2
Edit domain.xml and add under the <java-config> element
<jvm-options>-Dhttp.proxyPort=80</jvm-options>
<jvm-options>-Dhttp.proxyHost=our.server.com</jvm-options>
3.
Open the Glassfish admin web page, under Application Server -> VM Settings -> JVM Options and add these options
http.proxyPort=80
http.proxyHost=our.server.com
Setting
server-config.network-config.protocols.protocol.http-listener-1.http.server-name=MyHost:80
on GlassFish Server Open Source Edition 3.1.2.2 (build 5) solved problem to me.