Search Results

Search found 12222 results on 489 pages for 'initial context'.

Page 40/489 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Configuring jdbc-pool (tomcat 7)

    - by john
    i'm having some problems with tomcat 7 for configuring jdbc-pool : i`ve tried to follow this example: http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency so i have: conf/server.xml <GlobalNamingResources> <Resource type="javax.sql.DataSource" name="jdbc/DB" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/mydb" username="user" password="password" /> </GlobalNamingResources> conf/context.xml <Context> <ResourceLink type="javax.sql.DataSource" name="jdbc/LocalDB" global="jdbc/DB" /> <Context> and when i try to do this: Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource datasource = (DataSource)envContext.lookup("jdbc/LocalDB"); Connection con = datasource.getConnection(); i keep getting this error: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:803) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) pls help tnx

    Read the article

  • Creating a UIImage from a rotated UIImageView...

    - by Magic Bullet Dave
    I have a UIImageView with an image in it. I have rotated the image prior to display by setting the transform property of the UIImageView to CGAffineTransformMakeRotation(angle) where angle is the angle in radians. I want to be able to create another UIImage that corresponds to the rotated version that I can see in my view. I am almost there, by rotating the image context I get a rotated image: - (UIImage *) rotatedImageFromImageView: (UIImageView *) imageView { UIImage *rotatedImage; // Get image width, height of the bonuding rectangle CGRect boundingRect = [self getBoundingRectAfterRotation: imageView.bounds byAngle:angle]; // Create a graphics context the size of the boundinf rectangle UIGraphicsBeginImageContext(boundingRect.size); CGContextRef context = UIGraphicsGetCurrentContext(); // Rotate and translate the context CGAffineTransform ourTransform = CGAffineTransformIdentity; ourTransform = CGAffineTransformConcat(ourTransform, CGAffineTransformMakeRotation(angle)); CGContextConcatCTM(context, ourTransform); // Draw the image into the context CGContextDrawImage(context, CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height), imageView.image.CGImage); // Get an image from the context rotatedImage = [UIImage imageWithCGImage: CGBitmapContextCreateImage(context)]; // Clean up UIGraphicsEndImageContext(); return rotatedImage; } However the image is not rotated about its centre. I have tried all kinds of transforms concatenated with my rotate to get it to rotate around the centre but to no avail. Am I missing a trick? Is this even possible since I am rotating the context not the image? Getting desperate to make this work now, so any help would be appreciated. Dave

    Read the article

  • Initial text and paperclipped-URL for action in UIActivityViewController & UIActivityItemSource?

    - by Benjamin Kreeger
    Finally been making it through Apple's (rather dismal) documentation on the new UIActivityViewController class and the UIActivityItemSource protocol, and I'm trying to send different data sets to different actions called from the activity view. To simplify things, I'm looking at two things. A Facebook posting action, which should say "Check this out!" and also attach a URL to the post (with that cute little paperclip). A Twitter posting action, which should say "Check this out, with #hashtag!" and also attach that same URL (with the same paperclip). Here's the code I've got implemented right now. - (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType { if ([activityType isEqualToString:UIActivityTypePostToFacebook]) { return @"Check this out!"; } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) { return @"Check this out, with #hashtag!"; } return @""; } - (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController { return @""; } And then when I set up this activity view controller (it's in the same class), this is what I do. UIActivityViewController *activityView = [[UIActivityViewController alloc] initWithActivityItems:@[self] applicationActivities:nil]; [self presentViewController:activityView animated:YES completion:nil]; My dilemma is how to attach that NSURL object. It's relatively easy when calling the iOS 6 SL-class posting modals; you just call the individual methods to attach a URL or an image. How would I go about doing this here? I'll note that instead of returning NSString objects from -activityViewController:itemForActivityType, if I return just NSURL objects, they show up with that paperclip, with no body text in the post. If I return an array of those two items, nothing shows up at all.

    Read the article

  • InstallExecuteSequence cache interferes with custom action operation

    - by Dima G
    I need to upgrade a product that could be installed in per-user context to a new version that is always in per-machine context. The requirements are: Whether the old version was installed in a Per-User (no matter who) or Per-Machine context should be completely seamless to an administrator user that performs the upgrade. The MSI upgrade should succeed without the need to know the password of the user that originally installed the previous version of the product in a Per-User context. The installation should be performed from a single .msi file (no setup.exe is allowed). The installation should be able to run in a silent (non-UI) mode. No reboots are allowed during installation. My strategy is to find in the beginning of the installation whether the product is already installed in per-user context, and if so, to transform the registry keys manually to Per-Machine context (I checked: no additional changes such as file system changes etc. are needed except this transform). I figured out how to move all appropriate keys in the registry from the user settings to the machine settings (pre-loaded appropriate user hive in case it didn't appear in HKEY_USERS) and created custom action that does it - and it does work when I run it as a stand-alone executable before running the MSI. The problem, however, is that when Windows Installer runs InstallExecuteSequence it first creates a 'cached product context' for all products. So when my custom action runs in the course of InstallExecuteSequence, this cache has already been created. Thus FindRelatedProducts action that determines if older product with same upgrade code exists looks on that cache and ignores the changes that my custom action applied. If before running the MSI the previous product was in per-user context, FindRelatedProducts will look at the cache and not apply the upgrade and remove the previous version, because the new product is in per-machine context, even though the previous product version is already configured to per-machine context in the registry by that time by my custom action. What can be done to solve this problem without violating the requirements stated above?

    Read the article

  • Should i enforce realloc check if the new block size is smaller than the initial ?

    - by nomemory
    Can realloc fail in this case ? int *a = NULL; a = calloc(100, sizeof(*a)); printf("1.ptr: %d \n", a); a = realloc(a, 50 * sizeof(*a)); printf("2.ptr: %d \n", a); if(a == NULL){ printf("Is it possible?"); } return (0); } The output in my case is: 1.ptr: 4072560 2.ptr: 4072560 So 'a' points to the same adress. So should i enforce realloc check ? Later edit: Using MinGW compiler under Windows XP. Is the behaviour similar with gcc on Linux ? Later edit 2: Is it OK to check this way ? int *a = NULL, *b = NULL; a = calloc(100, sizeof(*a)); b = realloc(a, 50 * sizeof(*a)); if(b == NULL){ return a; } a = b; return a;

    Read the article

  • Session state provider and global.asax not interacting properly?

    - by yodaj007
    I'm experimenting with creating a crude, proof-of-concept session state store provider in ASP.Net. But I've got a problem and I'm not sure what to do about it. The website works properly when using the InProc provider. The Session_Start in global.asax is called on session creation as it should. But not if I implement my own provider. The Session_Start method from global.asax isn't being called at all if a new session is being created (that is, I delete the session state file). Am I missing something important here? public class TestSessionProvider : SessionStateStoreProviderBase { private const string ROOT = "c:\\projects\\sessions\\"; private const int TIMEOUT_MINUTES = 30; public string ApplicationName { get { return HostingEnvironment.ApplicationVirtualPath; } } private string GetFilename(string id) { string filename = String.Format("{0}_{1}.session", ApplicationName, id); char[] invalids = Path.GetInvalidPathChars(); for (int i = 0; i < invalids.Length; i++) { filename = filename.Replace(invalids[i], '_'); } return Path.Combine(ROOT, Path.GetFileName(filename)); } public override void Initialize(string name, NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (String.IsNullOrEmpty(name)) name = "Sporkalicious"; base.Initialize(name, config); } public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout) { SessionStateItemCollection items = new SessionStateItemCollection(); HttpStaticObjectsCollection objects = SessionStateUtility.GetSessionStaticObjects(context); return new SessionStateStoreData(items, objects, TIMEOUT_MINUTES); } /// <summary> /// The CreateUninitializedItem method is used with cookieless sessions when the regenerateExpiredSessionId /// attribute is set to true, which causes SessionStateModule to generate a new SessionID value when an /// expired session ID is encountered. /// </summary> /// <param name="context"></param> /// <param name="id"></param> /// <param name="timeout"></param> public override void CreateUninitializedItem(HttpContext context, string id, int timeout) { FileStream fs = File.Open(GetFilename(id), FileMode.CreateNew, FileAccess.Write, FileShare.None); BinaryWriter writer = new BinaryWriter(fs); SessionStateItemCollection coll = new SessionStateItemCollection(); coll.Serialize(writer); fs.Flush(); fs.Close(); } public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions) { return GetItemExclusive(context, id, out locked, out lockAge, out lockId, out actions); } public override SessionStateStoreData GetItemExclusive(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions) { locked = false; lockAge = TimeSpan.FromDays(1); lockId = 0; actions = SessionStateActions.None; if (!File.Exists(GetFilename(id))) { return null; } FileStream fs = File.Open(GetFilename(id), FileMode.Open, FileAccess.ReadWrite, FileShare.Read); BinaryReader reader = new BinaryReader(fs); SessionStateItemCollection coll = SessionStateItemCollection.Deserialize(reader); fs.Close(); return new SessionStateStoreData(coll, new HttpStaticObjectsCollection(), TIMEOUT_MINUTES); } public override void ReleaseItemExclusive(HttpContext context, string id, object lockId) { } public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item) { File.Delete(GetFilename(id)); } public override void ResetItemTimeout(HttpContext context, string id) { } public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem) { if (!File.Exists(GetFilename(id))) { CreateUninitializedItem(context, id, 10); } FileStream fs = File.Open(GetFilename(id), FileMode.Truncate, FileAccess.Write, FileShare.None); BinaryWriter writer = new BinaryWriter(fs); SessionStateItemCollection coll = (SessionStateItemCollection)item.Items; coll.Serialize(writer); fs.Flush(); fs.Close(); } public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback) { return false; } public override void InitializeRequest(HttpContext context){} public override void EndRequest(HttpContext context){} public override void Dispose(){} }

    Read the article

  • How can I check a type's dependents order to drop them and replace/modify the initial type?

    - by pctroll
    I tried to modify a type using the following code and it gave me the error code: 'ORA-02303'. I don't know much about Oracle or PL/SQL but I need to solve this; so I'd appreciate any further help with this. Thanks in advance. The code is just an example. But then again, I need to check its dependents first. create or replace type A as object ( x_ number, y_ varchar2(10), member procedure to_upper ); /

    Read the article

  • How to pass content in response from Exception filter in Asp.net WebAPI?

    - by jaffa
    Consider following code: My problem is: 1) I can't seem to cast the errors to HttpContent 2) I can't use the CreateContent extension method as this doesn't exist on the context.Response.Content.CreateContent public class ServiceLayerExceptionFilter : ExceptionFilterAttribute { public override void OnException(HttpActionExecutedContext context) { if (context.Response == null) { var exception = context.Exception as ModelValidationException; if ( exception != null ) { var modelState = new ModelStateDictionary(); modelState.AddModelError(exception.Key, exception.Description); var errors = modelState.SelectMany(x => x.Value.Errors).Select(x => x.ErrorMessage); // Cannot cast errors to HttpContent?? // var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) {Content = errors}; // throw new HttpResponseException(resp); // Cannot create response from extension method?? //context.Response.Content.CreateContent } else { context.Response = new HttpResponseMessage(context.Exception.ConvertToHttpStatus()); } } base.OnException(context); } }

    Read the article

  • JSF, writeAttribute("value", str, null) fails with strings obtained through ValueExpression.getValue

    - by Roma
    Hello, I'm having a somewhat weird problem with custom JSF component. Here's my renderer code: public class Test extends Renderer { public void encodeBegin(final FacesContext context, final UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.startElement("textarea", component); String clientId = component.getClientId(context); if (clientId != null) writer.writeAttribute("name", clientId, null); ValueExpression exp = component.getValueExpression("value"); if (exp != null && exp.getValue(context.getELContext()) != null) { String val = (String) exp.getValue(context.getELContext()); System.out.println("Value: " + val); writer.writeAttribute("value", val, null); } writer.endElement("textarea"); writer.flush(); } } The code generates: <textarea name="j_id2:j_id12:j_id19" value=""></textarea> Property binding contains "test" and as it should be, "Value: test" is successfully printed to console. Now, if I change the code to: public void encodeBegin(final FacesContext context, final UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.startElement("textarea", component); String clientId = component.getClientId(context); if (clientId != null) writer.writeAttribute("name", clientId, null); ValueExpression exp = component.getValueExpression("value"); if (exp != null && exp.getValue(context.getELContext()) != null) { String val = (String) exp.getValue(context.getELContext()); String str = "new string"; System.out.println("Value1: " + val + ", Value2: " + str); writer.writeAttribute("value", str, null); } writer.endElement("textarea"); writer.flush(); } generated html is: <textarea name="j_id2:j_id12:j_id19" value="new string"></textarea> and console output is "Value1: test, Value2: new string" What's going on here? This doesn't make sense. Why would writeAttribute differentiate between the two strings? Additional info: The component extends UIComponentBase I am using it with facelets

    Read the article

  • Can't use method return value in write context--how to fix for include_once?

    - by Bill Paetzke
    I'm getting this error in CodeIgniter when trying to load the email library: Can't use method return value in write context It's happening on line 827 of Loader.php in [codeigniter root]/system/libraries/Loader.php include_once($filepath); where $filepath equals "/var/www/system/libraries/Email.php" I called it like this in another php file: $this->load->library('email'); where $this is the CodeIgniter instance. According to the CodeIgniter email doc page, I'm doing it right. But it's not working...

    Read the article

  • What is Test Driven Development? Does it require to have initial designs?

    - by Nirajan Singh
    Hello Everybody, I am very new to TDD, not yet started using it. But i know that we have to write test first and then actual code to pass the test and refactor it till good design. My concern over TDD is that where does it fit in our SDLC. Suppose i get a requirement of making order processing system. Now, without having any model & design of this system, how can i start writing test. Shouldn't we require to define the entities & its attribute to proceed. If not, is it possible to develop big system without any design. I am really very confused over it. Can anyone help me to start TDD. Thanks in advance.

    Read the article

  • How do I get only two form fields to show instead of all 5 on initial page load? CSS

    - by marcamillion
    Here is the implementation: http://jsfiddle.net/AdQfB/2/ If you notice, when you click 'Login' or 'Register' before entering anything, you should see a few fields disappear and re-appear respectively. I would like for this page to display the view of just the two fields on the first load (rather than the current 5 it shows on first load), then when the user clicks the 'register' link, it shows the other 3 - for a total of 5. How do I do that? Thanks

    Read the article

  • How do i set Savepoints for Linq to SQL and use "NO" ExecuteCommand ?

    - by nik
    TransactionScope TransactionABC = new TransactionScope(); try { context.Connection.Open(); { context.ExecuteCommand("insert into test (test) values (1)") context.SubmitChanges(); context.ExecuteCommand("savepoint test"); context.ExecuteCommand("insert into test (test) values (2)") context.SubmitChanges(); context.ExecuteCommand("rollback to test"); } TransactionABC.Complete(); TransactionABC.Dispose(); } catch (Exception ec) { MessageBox.Show(" ", ec.Message); } finally { context.Connection.Close(); } It works, but only with ExecuteCommand. I want to use a function, because i can't see what happens in the savepoint !

    Read the article

  • How to build a control programatically?

    - by W_K
    I have custom control written in Java. For the sake of simplicity lets assume that it looks like this: public class HelloworldControl extends UIComponentBase { @Override public void decode(FacesContext context) { String cid = this.getClientId(context); ... super.decode(context); } @Override public void encodeBegin(FacesContext context) throws IOException { ResponseWriter writer = context.getResponseWriter(); writer.writeText("Hello world!", this); // I want a view!! } @Override public void encodeEnd(FacesContext context) throws IOException { ResponseWriter writer = context.getResponseWriter(); ... } public void restoreState(FacesContext context, Object state) { Object values[] = (Object[]) state; ... super.restoreState(context, values[0]); } public Object saveState(FacesContext context) { Object values[] = ... } } I would like to add programatically child control to it. For example I would like a child view control to render a view just under the Hellow world text. How can i do this? What is the standard procedure to build dynamically a control? To put it simply - I want programatically build a hierarchy of standard components and I want to attach it to my control.

    Read the article

  • What should I ask a prospective client during initial meeting?

    - by Anna Lear
    I'm about to branch out into taking on some contracts on the side. What would be some good questions to ask of a potential client during a first meeting? I've thought of a few things that seem pretty obvious: * What is the project? * What are the deadlines? * What's the budget? * What/how do they want me to deliver the completed work? Is that it, or are there any tricky things to watch out for?

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >