Hi
Please can you confirm whether JNDI is preferred over JDBC when publishing projects? If so, can you please advise us of the benefits of using JNDI?
Thanks
Please can you confirm whether JNDI is preferred over JDBC when publishing projects? If so, can you please advise us of the benefits of using JNDI?
Thanks
RE: JNDI vs JDBC
The main considerations are security and environment independence.
The following documentation link should be useful: External Calls - JNDI Options
RE: JNDI vs JDBC
I'm not sure that I would say using JNDI is preferred as such, but it does provide some benefits over the direct JDBC approach.
When using JNDI, the actual details for the database connection are configured on the server rather than in the app which has a number of benefit, for example:
The main downside of using the JNDI approach is that it takes a bit more effort to setup. You need to configure the connection details on your server accordingly to make the JNDI resource available, add the relevant resource-ref to the web.xml file for your application, and then change the WebMaker setting.
You can find more details on how to set this up for both JDBC database connections and Remote Service URLs in the documentation at http://www.hyfinity.net/mvcdocumentation_v7/Morphyc/XDE%20User%20Guide/External%20Calls%20-%20JNDI%20Options.html
I hope this helps.
Please let me know if you have any further questions.
Regards,
Gerard
RE: JNDI vs JDBC
RE: JNDI vs JDBC
So if we set up JNDI in the projects web.xml, can we just do it for new projects and leave existing ones using JDBC?
Thanks
[hr][/hr]
Thanks Gerard :-)
RE: JNDI vs JDBC
Hi kidder,
For BizFlow WebMaker you need to setup the resource reference details in the web.xml on the BizFlow server.
These details are then available to be used by any project/application, but are only used if the project is configured to use them (changing from the default JDBC details).
So, you won't need to change the older projects until you want too.
Steve.
RE: JNDI vs JDBC
I'm thinking of having a go at setting this up, by following the directions you've provided.
I assume that I need entries in the projects web.xml like these below:
<resource-ref>
<description>Bizflow</description>
<res-ref-name>BizflowContainer</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<env-entry>
<env-entry-name>HWActivityService_Proxy-HWActivity</env-entry-name>
<env-entry-value>http://devserver/bizflow/webservice/HWActivity.hws</env-entry-value>
<env-entry-type>Java.lang.String</env-entry-type>
</env-entry>
together with entries in the context.xml like this:
<Resource name="jdbc/BizflowContainer" auth="Container"
jndi-name="jdbc/Bizflow"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="userid" password="userpassword"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc :s qlserver://devsqlserver;databaseName=bizflow;"
defaultAutoCommit="false"/>
<Environment name="HWActivityService_Proxy-HWActivity" value="http://devserver/bizflow/webservice/HWActivity.hws" type="Java.lang.String" override="false" />
Is this correct?
Thanks for your help on this.
RE: JNDI vs JDBC
I think that looks about right.
I believe the res-ref-name value in the web.xml resource-ref section must match the name of the Resource in the context.xml though, so I think this should still have the 'jdbc/' prefix.
You would then use 'jdbc/BizflowContainer' as the Resource Name for the database in the Publication Settings within WebMaker.
For the service URL, given these entries you would need to set a Resource Name of 'HWActivityService_Proxy-HWActivity' for the appropriate Service Agent in the Publication Settings.
I hope this helps. It can still sometimes need a bit of trial and error to get this working properly though so please let me know if you have any further questions.
Regards,
Gerard
RE: JNDI vs JDBC
I'm having a few issues with this
I'm getting errors when i try to load the page. I've ensured that the env-entry nodes are in the web.xml file on the devserver here:
\\devserver\Program Files (x86)\Apache Software Foundation\..\bizflowwebmaker\WEB-INF
and look like this
<env-entry>
<env-entry-name>HWActivity</env-entry-name>
<env-entry-value>http://devserver/bizflow/webservice/HWActivity.hws</env-entry-value>
<env-entry-type>Java.lang.String</env-entry-type>
</env-entry>
In my publication settings i am referencing HWActivity (please see attachment).
The WM logs show this error:
javax.naming.NameNotFoundException: Name [HWActivity] is not bound in this Context. Unable to find [HWActivity].
When i check the Tomcat logs I see this error:
17-Jul-2015 15:14:14 org.apache.catalina.core.NamingContextListener addEnvironment
SEVERE: Environment entry HWProcessService_Proxy-HWProcess has an invalid type
Any ideas what I am doing incorrectly?
Thanks for your help
RE: JNDI vs JDBC
I have a couple of initial thoughts:
Firstly, the fact that the Tomcat log mentions the environment entry 'HWProcessService_Proxy-HWProcess' does not seem correct. Given you are referencing HWActivity in WebMaker and the web.xml, I think you need to make sure that the context.xml entry uses the same name.
Secondly, the invalid type message suggests a problem with the type attribute on the Environment tag, and looking again at your version in post 7 it looks like there might be a capital J. Is this the case? If so, I would try changing this, and hopefully it will resolve this error.
I hope this helps.
Regards,
Gerard
RE: JNDI vs JDBC
I think I put the incorrect part of the log into my post - sorry, it should have been the HWActivity bit I posted...it was 4pm on a Friday!!
Following your suggestion, I amended the capital J to lower case j - all seems to have worked now. I had copied it from the page linked to above - may I suggest that it might be worth looking at updating that at some point?
Thanks for your help with this.
RE: JNDI vs JDBC
Hi Kidder,
Thanks for feedback, we will update.
Steve.
RE: JNDI vs JDBC
Hi guys,
sorry to go back to this - just wondered if you could offer a little clarification to me please wrt the context.xml file. On the help page it mentions updating the context.xml in the conf directory of the Tomcat installation; on the Apache Tomcat pages it mentions updating the context.xml in the per-web-application META-INF folder.
Should I be using both? Or just one? Or are the DB connections in the conf/context.xml and the other resources in the META-INF/context.xml?
Thanks
RE: JNDI vs JDBC
I'm not really an expert on all of this, but this is my understanding:
Each web application running on tomcat has a Context.
This is determined by looking at the default information (eg from conf/context.xml), and then overriding this with any specific settings for an individual application (eg in a META-INF/context.xml file in the app)
So while you could define the resource settings in both places, I think it may not really make sense as the application specific ones (in META-INF/context.xml) would always override the defaults.
I think one of the big gains from using JNDI for these settings in the first place is to not have to include the connection details etc in the app, so I personally don't think putting them in a META-INF/context.xml file makes sense. If you did this you would need to change the WAR file contents to install on different environments.
This is why we suggest using the conf/context.xml file in the help.
This will mean that the settings will apply to all apps installed on that Tomcat instance however. If you don't want this, then I think you can define an application specific context file, without needing to place it in the WAR, by creating a file at /conf/[enginename]/[hostname]/[contextname].xml (eg /conf/Catalina/localhost/myapp.xml).
For more info on this have a look at the Tomcat documentation: https://tomcat.apache.org/tomcat-7.0-doc/config/context.html
I hope this helps.
Regards,
Gerard
RE: JNDI vs JDBC