• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Deploy in remote

 
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have an app in my local, it works with my DB, but it doesnt with the remote one.

Then when I try to deploy it, after change the conection it shows an error, we already disccued that error in this forum. I think it happens because of my firewall.

I need to run it in my remote server. Can I upload it to the server, and once there change the code and deploy there?

Any idea?

Regards,
Isaac
 
Marshal
Posts: 3654
516
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not put the database connection information in a text-based properties file and have the end user can configure it with the deployment-specific details?

Another idea might be to provide the information on command line when the application is started by the end user.
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds good but Im not sure if I got it. I need to deploy a war in local in order to upload it to Tomcat in remote. But I cant run it in my local and generate the .war.
Should I then upload only the folder which contains the app and after that call to it via browser(and the .war will be created in the remote server)?

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you trying to access the remote DB locally? From my experience the chance of doing that is slim because of firewall, different network subnet, or the remote server setting (like part of hosting plan).

The DB connection can remain as "localhost" such that when you deploy your WAR to the remote server, it accesses the remote server's DB (aka local for the server)

You should able to use the app server's admin console to deploy the WAR. Or upload the WAR to the corresponding deploy folder.
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the remote server in one hosting plan and the DB in another, that s why I cant use localhost there. On the other hand I can deploy the war in the remote server, but I cant create the war itself for upload it to the remote server
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Isaac Ferguson wrote:I have the remote server in one hosting plan and the DB in another, that s why I cant use localhost there. On the other hand I can deploy the war in the remote server, but I cant create the war itself for upload it to the remote server



For the DB connection setup, ask the hosting plan people for advice.

For the WAR how are you able to deploy the WAR yet can't create it for upload?

Oh are you somehow hard-coding the JDBC info in your WAR? You ought to be using JNDI and do a lookup in code instead. So that the your WAR won't need to change if the DB connection changes.
 
Ron McLeod
Marshal
Posts: 3654
516
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Isaac Ferguson wrote:I need to deploy a war in local in order to upload it to Tomcat in remote.


Oh - I don't think you mentioned your application was contained in a WAR. You should, as mentioned previously, define a Data Source resource, and then look it up using JNDI. For example:
        Context initCtx = new InitialContext();
        Context envCtx = (Context) initCtx.lookup("java:comp/env");
        DataSource ds = (DataSource) envCtx.lookup("jdbc/MyDataSourceName");
        Connection connection = ds.getConnection();

You can specify the DataSource in the META-INF/context.xml file in your WAR. I also believe that your can configure it outside of the app as part of the server configuration.

Edit: detailed info here: Apache Tomcat 6.0 JNDI Datasource HOW-TO / Apache Tomcat 7.0 JNDI Datasource HOW-TO
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read the article, and I am trying to do it like that.

My code in the context.xml




Any more idea?
 
Ron McLeod
Marshal
Posts: 3654
516
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is java code which belongs in your application - shouldn't be in the context.xml file

Isaac Ferguson wrote:




Here is an example of Data Source resource from a working deployment:
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now my code in the context.xml is like follow:



I can see a red line before this code:



When I try to run in local, I get this error:



I have changed it from </Context> to /> but I get the same issue

Any idea?
 
Ron McLeod
Marshal
Posts: 3654
516
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your problem at this point is that your XML is not well formed. Pay attention to the error message: .. context.xml seems to be broken. Please make sure it is parseable and valid ... If your IDE is highlighting <Resource name="jdbc/IdhAdmin", then take a look at the line previous to it. <Context antiJARLocking="true" path="/IdhAdmin" is missing the closing >.
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It deploy now. I got confused because



is closing



then I have to close it "again" at the end using ?



 
Ron McLeod
Marshal
Posts: 3654
516
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't end the Context tag with a >, then whatever follows will be understood to be attributes of the Context element, not a child element as you want.
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, it deploy perfectly and I have upload it to my server.

I local it works fine, but in remote it is like it could not retrieve any data and it throws an error:



It get null from the DB, I think that maybe the problem is with the IP.

When I use this in the context.xml it works fine



When I use this in the context.xml it doesnt works



I got my ip adrees using this site:

http://www.iplocation.net/find-ip-address

I think it is my external IP? and not the rigth one.

In both cases I run it in local for the above examples

Any idea?

 
Ron McLeod
Marshal
Posts: 3654
516
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can explain network-wise what you have?
     - Where is the application server running, where is the database, if not same platform, what interconnects them, etc?
     - Where are the clients?
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The application server in running in a remote server of the company jvmhost.com/.
The DB is in my local.
Im using Windows, and the server is running on Linux

Where are the clients?



Do you mean the users? I cant connect from my local browser when running the app in the remote server.

In the remote platform Im using an option when I put the IP of my office, and I allowed access from that platform to my IP host.

The company has told me this:


When xx.x.xxx.xxx is my office┬┤s ip and xxx.xxx.xxx.xxx is the ip of remote server

Any idea?
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally the host company fixed it. It was related to give grants, in one platform to connect the other one.
 
reply
    Bookmark Topic Watch Topic
  • New Topic