JPA binding classes are not found when added at runtime

Hi,
I have my jpa binding classes in a jar file, which acts as a plugin for my application. I add this jar at runtime using a custom URL class loader. But I am getting exception that my tables are not mapped, when i try to use them.
Here is the exception :-
java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: data_source_tab is not mapped [select d from data_source_tab d where d.url = ?1]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
... 6 more
Caused by: org.hibernate.hql.ast.QuerySyntaxException: data_source_tab is not mapped [select d from data_source_tab d where d.url = ?1]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:94)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:316)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3228)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3112)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)
If i directly add the jar in my build path, then it is working fine and it is creating the required tables. But the problem is, I get the hold on jar file at runtime.
Please help me with this.
Here is my classloader class :-
public class CustomURLClassLoader extends URLClassLoader
private static CustomURLClassLoader URLCLASSLOADER = null;
public CustomURLClassLoader(ClassLoader parent)
super(new URL[0], parent);
this.addAllJarsToClassPath();
* This method adds all the jars in the specified dirs and sub dirs
* recursively to the classpath. NOTE : Even though we use the term
* 'classpath' technically URLs are added to a list of URLs to search for
* classes and resources.
* @param dirContainingJars
* The directory containing jars
* @throws Exception
public void addJarsToClassPath() throws Exception
super.addURL("URL of jar file");
}

I don't know about hibernate, but EclipseLink allows passing in the classloader to the factory when it gets created as Shaun describes at:
JPA & Class Loaders
Best Regards,
Chris

Similar Messages

  • Parent key 1393696 not found when adding child 1393727.

    By posting, I received this :
    An error in the system has occurred. Please contact the system administrator if the problem persists.
    type: java.lang.IllegalArgumentException
    java.lang.IllegalArgumentException: Parent key 1393696 not found when adding child 1393726.
    at com.jivesoftware.util.LongTree.addChild(LongTree.java:99)
    at com.jivesoftware.forum.database.DbTreeWalker.addChild(DbTreeWalker.java:233)
    at com.jivesoftware.forum.database.DbForumThread.addMessage(DbForumThread.java:617)
    at com.jivesoftware.forum.proxy.ForumThreadProxy.addMessage(ForumThreadProxy.java:145)
    at com.jivesoftware.forum.action.PostAction.createMessage(PostAction.java:1083)
    at com.jivesoftware.forum.action.PostAction.execute(PostAction.java:946)
    at com.jivesoftware.forum.action.PostAction.doPost(PostAction.java:666)
    at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:300)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:166)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.jivesoftware.forum.action.JiveExceptionInterceptor.intercept(JiveExceptionInterceptor.java:63)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.jivesoftware.base.action.JiveObjectLoaderInterceptor.intercept(JiveObjectLoaderInterceptor.java:56)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at oracle.wocapps.forum.action.OracleLocaleInterceptor.intercept(OracleLocaleInterceptor.java:74)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.webwork.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:71)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
    at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
    at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:272)
    at com.jivesoftware.base.util.JiveWebWorkServlet.service(JiveWebWorkServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    at com.jivesoftware.util.SetResponseCharacterEncodingFilter.doFilter(SetResponseCharacterEncodingFilter.java:53)
    at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
    at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
    at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
    at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)
    at com.jivesoftware.util.SetRequestCharacterEncodingFilter.doFilter(SetRequestCharacterEncodingFilter.java:48)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:627)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
    at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    at java.lang.Thread.run(Thread.java:595)

    Check the adapter that is attached to the child table , compile it again and try adding .
    BTW which connector you are using and paste the error trace from log files
    Thanks
    Suren

  • I can find many purchases in my purchase history, but they are not found when I "Check Available Downloads." How else can I download my purchases?

    I can find many purchases in my purchase history, but they are not found when I "Check Available Downloads." How else can I download my purchases?

    what happened to the initially downloaded files ? did you make a backup ? do you use time machine ?

  • Javax.servlet.jsp.SkipPageException  classes are not  found

    i'm using Sun java system application server plot form edition 8.2 to deploy
    some filename.war..which is developed by Eclipse 3.2 then i have the following error Report in sjsas admin console:
    Application Server > Applications > Web Applications
    ErrorAn error has occurred.
    Deploying application in domain failed; Some verifier tests failed for the given application. Aborting deployment. Please verify your application using the verifier separately for more details ; requested operation cannot be completed Some verifier tests failed for the given application. Aborting deployment. Please verify your application using the verifier separately for more details
    in windows temp folder where log file shows the following error Report:
         FAILED TESTS :
         Test Name : tests.web.WebArchiveClassesLoadable
         Test Assertion : All classes in this Web Archive are loadable. Please refer to J2EE 1.4 Specification Section #8.1.2 for further information.
         Test Description : For [ hh.war ]
    classes [ javax.servlet.jsp.SkipPageException ] referenced by [ org.apache.jsp.VotingResponse_jsp] are not found
    classes [ javax.servlet.jsp.SkipPageException ] referenced by [ org.apache.jsp.index_jsp] are not found
    Please either bundle the above mentioned classes in the application or use optional packaging support for them.
    END OF STATIC VERIFICATION RESULTS
    How can i overcome from this exception.

    Perhaps your version of the sun server is too old. SkipPageException exists since JSP 2.0 according to the javadocs.

  • New movies are not found when connecting to my camera

    Hi,
    I Use a Sony HDR XR550VE. After soem time of happy use of iMovie, it now no longer discovers new clips at import.
    Hooking it up to iMovie and importing new clips has working fine in the beginning untill the point at which I deleted the camera's harddrive content (using the camera's commands), and started making a really long movie (over 6 hrs). THat did not import very well: half of it wasn't discovered via the iMovie import dialogue. Since then, new movies I've shot are not discovered anymore and can't be imported. Accessing the drive directly via the "Import films" option allows me to drill all the way down to the AVCHD-mts source file, but are displayed grayed out and can't be selected to be imported.
    Please help.
    Thanks,
    Jeronias

    Hi Jeronias,
    Sorry to hear that things have gone a bit pear-shaped for you again.
    You may have already tried this, but deleting iMovie's preference file sometimes helps when iMovie is not working as it should. The file can become corrupted in some circumstances, such as when iMovie quits unexpectedly or is "Force Quit".
    Close iMovie then, in Finder, navigate to the file named "com.apple.iMovieApp.plist" in your User (Home)>Library>Preferences folder. Drag the .plist file to the Trash. When next opened iMovie will create a fresh file with the default settings, which you can change if desired in iMovie's menu item iMovie>Preferences.
    Hopefully, that may get things back to normal.
    I'm interested in the procedure you are using (or attempting to use) to import your video into iMovie. I have a similar camcorder, the Sony HDR-SR7, which records AVCHD video to a 60 Gb hard drive. Your model, of course, has a 240 GB hard drive and also records to Memory Stick and SD/SDHC cards.
    When I connect my camera via USB and turn it on, a dialogue appears on the LCD touch screen. I then have to touch the hard drive icon in order for the camera to be recognized by my MacBook Pro. With iMovie open, it takes a couple of minutes (maybe less) before the import screen appears. Is this the way you normally go about importing your footage? Of course, you will have 2 import sources - the hard drive and/or a memory card.
    Have you tried importing from a memory card using a card reader, rather than connecting the camera? If this works, then the import problem is isolated to the camera itself. I'm assuming that iMovie is not recognizing the hard drive nor the card when the camera is connected via USB.
    So, in summary:
    What process are you using to import from the camera?
    Have you tried using a card reader?
    Have you tried deleting the preference file?
    John

  • File not found when adding a link to another site collection on the navigation page

    When I am adding a link to another site collection in the navigation page, I got the following error. Is there any limitation for the navigation setting? why can't we add a link to another site collection in the navigation page?
    This is SharePoint 2007

    Hi
    the URL provided is working?  (check it in separate browser window )
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Tags are not found when typing a keyword into the location bar

    Previously when I typed a tag into the address bar - tagged bookmarks would show up. Now very rarely does this happen and instead search engine search terms show up.
    To search for tags/keywords I now have to open the bookmarks and do a search in there. Very inconvenient... it suks big time. WTF happened?
    Thanks Joe

    I think I am on the way to an answer. I turned off ALL add-ons and tags are now showing up in adress bar searches.
    Thanks! :-)

  • I just bought and downloaded an album.  the album/tracks are NOT found in my music listing alongside every other track i have purchased! however, they are found and playable in the recently added playlist. plz help

    i just bought and downloaded an album.  the album/tracks are NOT found in my music library alongside every other track i have purchased! however, they are found and playable in the recently added playlist.  in addition, when using the search queue in the upper right corner, the artist and album is listed when searched for, but when clicked on, nothung happens.  i have downloaded hundreds of tracks with no issue (not a noob), but have no idea what has occurred...plz help

    Have you checked whether the songs are in your iTunes library? If they are, then just drag them to your purchased playlist. If they aren't, try checking for available downloads.
    If none of the previous work, then get in contact directly with iTunes store support to tell them about your problem.

  • Binary class definition not found: Hello  --- When access the sample

    Hi,
    I followed the the document of
    Oracle9iAS Release 2 Containers for J2ee
    dated 12/01/01
    to deploy the stateless pure java web service, Hello.
    When I hit
    http://server:port/hellows/helloService?wsdl
    I got the generated WSDL
    Also, I can get the proxy class source and jar from
    http://server:port/hellows/helloService?proxy_jar
    http://server:port/hellows/helloService?proxy_source
    However, after I compiled HelloClient and HelloProxy, I got the following error when I tried to access the web service, Hello
    Any advice is appreciated.
    Qiming
    [SOAPException: faultCode=SOAP-ENV:Protocol; msg=Unsupported response content type "text/html", must be: "text/xml". Response was:
    <HTML><HEAD><TITLE>500 Internal Server Error</TITLE></HEAD><BODY><H1>500 Internal Server Error</H1><PRE>oracle.j2ee.xanadu.JasperGenerationError: no source generated during code generation!: 1 in getFile name: \Hello.class
    <br>1 in getFile name: \Hello.java
    <br>error: error message &apos;class.format&apos; not found<br>binary class definition not found: Hello
    <br>
    <br>     at oracle.j2ee.ws.JavaWrapperGenerator.generate(JavaWrapperGenerator.java:267)
    <br>     at oracle.j2ee.ws.RpcWebService.generateWrapperClass(RpcWebService.java:668)
    <br>     a[i]Long postings are being truncated to ~1 kB at this time.

    You may want to try the latest and greatest OC4J 9.0.3 which is on OTN at:
    OC4J 9.0.3: http://otn.oracle.com/software/htdocs/devlic.html?/software/products/ias/htdocs/utilsoft.html
    The updated Web service writeups are in:
    <oc4j_home>\webservices\demo\demo.zip (unzip and look in the <demo_unzip>\basic\java_services\README.txt)
    One thing that might cause your problem is making sure your class path is updated to point to all the right class files as described in the writeup, including the jar file containing the downloaded class files.
    Mike.

  • When going from a Mac-based Ai to a PC based Ai, the documents "Font" are not found on the PC version?  (mostly Helvetica) where and how do I get those Fonts?  And/or, can I use the Mac version of these Fonts?

    When going from a Mac-based Ai to a PC based Ai, the documents "Font" are not found on the PC version?  (mostly Helvetica) where and how do I get those Fonts?  And/or, can I use the Mac version of these Fonts?
    Thanks, Rich

    In order to be cross platform you must be using the Open Type version of all fonts to cause the least disruption. Macs can read and process the Windows .ttf  type format but PCs can't process Mac formatted type. Most recent versions also cannot use the older PS Type 1 fonts.

  • Stored procedure not found when creating a new recordset binding in Dreamweaver CS6 with ColdFusion Server 11

    Stored procedure not found when creating a new recordset binding in Dreamweaver CS6 with ColdFusion Server 11.  I can see the tables and views in the database tab, but no stored procedures.  If I connect to a data source created in ColdFusion Server 6 I am able to see the stored procedures.

    Ben thanks for the reply!
    Yes that is the process I am following:
    In Dreamweaver, open the page that will run the stored procedure.
    In the Bindings panel (Window > Bindings), click the Plus button, and then select Stored Procedure.
    In the Data Source pop‑up menu, select a connection to the database containing the stored procedure
    Enter the ColdFusion Data Source user name and password.
    At this point in the procedure drop down I would get a message that said No Stored Procedure Found.
    Right now it appears to be working, I had to create a new site that pointed to the older CF 6 server's data source and create a page following the process above, then when I went back to the CF 11 site the stored procedures were now populated.  I need to make sure it is pulling from the correct server but right now it appears to be working.
    Thanks
    Dwight

  • When i want to install itunes 10.5 there is an error (some keys are not found). Can someone help me, please???

    When i want to install itunes 10.5 there is an error (some keys are not found). Can someone help me, please???

    I have solved the Problem

  • "Class Circle not found in TryBouncingBalls" error message. Help !

    Dear People,
    I have an error message :
    "TryBouncingBalls.java": Error : class Circle not found in class stan_bluej_ch5_p135.TryBouncingBalls at line 67, "
    Circle circle = new Circle(xPos + 130, 30);
    below are the classes TryBouncingBalls, BouncingBall, BallDemo, Canvas
    Thank you in advance
    Stan
    package stan_bluej_ch5_p135;
    import java.awt.*;
    import java.awt.geom.*;
    public class TryBouncingBalls
    public static void main(String[] args)
    Canvas myCanvas = new Canvas("Creativity at its best");
    myCanvas.setVisible(true);
    BouncingBall ball = new BouncingBall(50,50,16, Color.red, 500, myCanvas);
    BouncingBall ball2 = new BouncingBall(70,80,20, Color.green, 500, myCanvas);
    BouncingBall ball3 = new BouncingBall(90,100,16, Color.red, 500, myCanvas);
    BouncingBall ball4 = new BouncingBall(30,30,20, Color.green, 500, myCanvas);
    ball.draw();
    ball2.draw();
    ball.draw();
    ball2.draw();
    // make them bounce
    boolean finished = false;
    while(!finished) {
    myCanvas.wait(50); // small delay
    ball.move();
    ball2.move();
    ball3.move();
    ball4.move();
    // stop once ball has travelled a certain distance on x axis
    if(ball.getXPosition() >= 550 && ball2.getXPosition() >= 550)
    finished = true;
    myCanvas.setFont(new Font("helvetica", Font.BOLD, 14));
    myCanvas.setForegroundColor(Color.red);
    myCanvas.drawString("We are having fun, ...\n\n", 20, 30);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.black);
    myCanvas.drawString("...drawing lines...", 60, 60);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawLine(200, 20, 300, 50);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.blue);
    myCanvas.drawLine(220, 100, 370, 40);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.green);
    myCanvas.drawLine(290, 10, 320, 120);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawString("...and shapes!", 110, 90);
    myCanvas.setForegroundColor(Color.red);
    myCanvas.drawString("to bring to focus creative ideas !", 310, 290);
    // the shape to draw and move
    int xPos = 10;
    Rectangle rect = new Rectangle(xPos + 40, 150, 30, 20);
    Rectangle rect2 = new Rectangle(xPos + 80, 120, 50, 25);
    Rectangle rect3 = new Rectangle(xPos+ 1200, 180, 30, 30);
    Rectangle rect4 = new Rectangle(xPos + 150, 220, 40, 15);
    myCanvas.fill(rect);
    myCanvas.fill(rect2);
    myCanvas.fill(rect3);
    myCanvas.fill(rect4);
    Circle circle = new Circle(xPos + 130, 30);
    // Circle circle2 = new Circle(xPos + 150, 50);
    // Circle circle3 = new Circle(xPos + 170, 30);
    // Circle circle4 = new Circle(xPos + 200, 40);
    // myCanvas.fill(circle);
    // myCanvas.fill(circle2);
    // myCanvas.fill(circle3);
    // myCanvas.fill(circle4);
    // move the rectangle and circles across the screen
    for(int i = 0; i < 200; i ++) {
    myCanvas.fill(rect);
    myCanvas.fill(rect2);
    myCanvas.fill(rect3);
    myCanvas.fill(rect4);
    myCanvas.wait(10);
    myCanvas.erase(rect);
    myCanvas.erase(rect2);
    myCanvas.erase(rect3);
    myCanvas.erase(rect4);
    xPos++;
    rect.setLocation(xPos, 150);
    rect2.setLocation(xPos, 120);
    rect3.setLocation(xPos, 180);
    rect4.setLocation(xPos, 220);
    // at the end of the move, draw once more so that it remains visible
    myCanvas.fill(rect);
    myCanvas.fill(rect2);
    myCanvas.fill(rect3);
    myCanvas.fill(rect4);
    package stan_bluej_ch5_p135;
    import java.awt.*;
    import java.awt.geom.*;
    * Class BouncingBall - a graphical ball that observes the effect of gravity. The ball
    * has the ability to move. Details of movement are determined by the ball itself. It
    * will fall downwards, accelerating with time due to the effect of gravity, and bounce
    * upward again when hitting the ground.
    * This movement can be initiated by repeated calls to the "move" method.
    * @author Bruce Quig
    * @author Michael Kolling (mik)
    * @author David J. Barnes
    * @version 1.1 (23-Jan-2002)
    public class BouncingBall
    private static final int gravity = 3; // effect of gravity
    private int ballDegradation = 2;
    private Ellipse2D.Double circle;
    private Color color;
    private int diameter;
    private int xPosition;
    private int yPosition;
    private final int groundPosition; // y position of ground
    private Canvas canvas;
    private int ySpeed = 1; // initial downward speed
    * Constructor for objects of class BouncingBall
    * @param xPos the horizontal coordinate of the ball
    * @param yPos the vertical coordinate of the ball
    * @param ballDiameter the diameter (in pixels) of the ball
    * @param ballColor the color of the ball
    * @param groundPos the position of the ground (where the wall will bounce)
    * @param drawingCanvas the canvas to draw this ball on
    public BouncingBall(int xPos, int yPos, int ballDiameter, Color ballColor,
    int groundPos, Canvas drawingCanvas)
    xPosition = xPos;
    yPosition = yPos;
    color = ballColor;
    diameter = ballDiameter;
    groundPosition = groundPos;
    canvas = drawingCanvas;
    * Draw this ball at its current position onto the canvas.
    public void draw()
    canvas.setForegroundColor(color);
    canvas.fillCircle(xPosition, yPosition, diameter);
    * Erase this ball at its current position.
    public void erase()
    canvas.eraseCircle(xPosition, yPosition, diameter);
    * Move this ball according to its position and speed and redraw.
    public void move()
    // remove from canvas at the current position
    erase();
    // compute new position
    ySpeed += gravity;
    yPosition += ySpeed;
    xPosition +=2;
    // check if it has hit the ground
    if(yPosition >= (groundPosition - diameter) && ySpeed > 0) {
    yPosition = (int)(groundPosition - diameter);
    ySpeed = -ySpeed + ballDegradation;
    // draw again at new position
    draw();
    * return the horizontal position of this ball
    public int getXPosition()
    return xPosition;
    * return the vertical position of this ball
    public int getYPosition()
    return yPosition;
    package stan_bluej_ch5_p135;
    import java.awt.*;
    import java.awt.geom.*;
    * Class BallDemo - provides two short demonstrations showing how to use the
    * Canvas class.
    * @author Michael Kolling and David J. Barnes
    * @version 1.0 (23-Jan-2002)
    public class BallDemo
    private Canvas myCanvas;
    * Create a BallDemo object. Creates a fresh canvas and makes it visible.
    public BallDemo()
    myCanvas = new Canvas("Ball Demo", 600, 500);
    myCanvas.setVisible(true);
    * This method demonstrates some of the drawing operations that are
    * available on a Canvas object.
    public void drawDemo()
    myCanvas.setFont(new Font("helvetica", Font.BOLD, 14));
    myCanvas.setForegroundColor(Color.red);
    myCanvas.drawString("We can draw text, ...", 20, 30);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.black);
    myCanvas.drawString("...draw lines...", 60, 60);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawLine(200, 20, 300, 50);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.blue);
    myCanvas.drawLine(220, 100, 370, 40);
    myCanvas.wait(500);
    myCanvas.setForegroundColor(Color.green);
    myCanvas.drawLine(290, 10, 320, 120);
    myCanvas.wait(1000);
    myCanvas.setForegroundColor(Color.gray);
    myCanvas.drawString("...and shapes!", 110, 90);
    myCanvas.setForegroundColor(Color.red);
    // the shape to draw and move
    int xPos = 10;
    Rectangle rect = new Rectangle(xPos, 150, 30, 20);
    // move the rectangle across the screen
    for(int i = 0; i < 200; i ++) {
    myCanvas.fill(rect);
    myCanvas.wait(10);
    myCanvas.erase(rect);
    xPos++;
    rect.setLocation(xPos, 150);
    // at the end of the move, draw once more so that it remains visible
    myCanvas.fill(rect);
    * Simulates two bouncing balls
    public void bounce()
    int ground = 400; // position of the ground line
    myCanvas.setVisible(true);
    // draw the ground
    myCanvas.drawLine(50, ground, 550, ground);
    // crate and show the balls
    BouncingBall ball = new BouncingBall(50, 50, 16, Color.blue, ground, myCanvas);
    ball.draw();
    BouncingBall ball2 = new BouncingBall(70, 80, 20, Color.red, ground, myCanvas);
    ball2.draw();
    // make them bounce
    boolean finished = false;
    while(!finished) {
    myCanvas.wait(50); // small delay
    ball.move();
    ball2.move();
    // stop once ball has travelled a certain distance on x axis
    if(ball.getXPosition() >= 550 && ball2.getXPosition() >= 550)
    finished = true;
    ball.erase();
    ball2.erase();
    package stan_bluej_ch5_p135;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    * Class Canvas - a class to allow for simple graphical
    * drawing on a canvas.
    * @author Michael Kolling (mik)
    * @author Bruce Quig
    * @version 1.8 (23.01.2002)
    public class Canvas
    private JFrame frame;
    private CanvasPane canvas;
    private Graphics2D graphic;
    private Color backgroundColor;
    private Image canvasImage;
    * Create a Canvas with default height, width and background color
    * (300, 300, white).
    * @param title title to appear in Canvas Frame
    public Canvas(String title)
    this(title, 600, 600, Color.white);
    * Create a Canvas with default background color (white).
    * @param title title to appear in Canvas Frame
    * @param width the desired width for the canvas
    * @param height the desired height for the canvas
    public Canvas(String title, int width, int height)
    this(title, width, height, Color.white);
    * Create a Canvas.
    * @param title title to appear in Canvas Frame
    * @param width the desired width for the canvas
    * @param height the desired height for the canvas
    * @param bgClour the desired background color of the canvas
    public Canvas(String title, int width, int height, Color bgColor)
    frame = new JFrame();
    canvas = new CanvasPane();
    frame.setContentPane(canvas);
    frame.setTitle(title);
    canvas.setPreferredSize(new Dimension(width, height));
    backgroundColor = bgColor;
    frame.pack();
    * Set the canvas visibility and brings canvas to the front of screen
    * when made visible. This method can also be used to bring an already
    * visible canvas to the front of other windows.
    * @param visible boolean value representing the desired visibility of
    * the canvas (true or false)
    public void setVisible(boolean visible)
    if(graphic == null) {
    // first time: instantiate the offscreen image and fill it with
    // the background color
    Dimension size = canvas.getSize();
    canvasImage = canvas.createImage(size.width, size.height);
    graphic = (Graphics2D)canvasImage.getGraphics();
    graphic.setColor(backgroundColor);
    graphic.fillRect(0, 0, size.width, size.height);
    graphic.setColor(Color.black);
    frame.show();
    * Provide information on visibility of the Canvas.
    * @return true if canvas is visible, false otherwise
    public boolean isVisible()
    return frame.isVisible();
    * Draw the outline of a given shape onto the canvas.
    * @param shape the shape object to be drawn on the canvas
    public void draw(Shape shape)
    graphic.draw(shape);
    canvas.repaint();
    * Fill the internal dimensions of a given shape with the current
    * foreground color of the canvas.
    * @param shape the shape object to be filled
    public void fill(Shape shape)
    graphic.fill(shape);
    canvas.repaint();
    * Fill the internal dimensions of the given circle with the current
    * foreground color of the canvas.
    public void fillCircle(int xPos, int yPos, int diameter)
    Ellipse2D.Double circle = new Ellipse2D.Double(xPos, yPos, diameter, diameter);
    fill(circle);
    * Fill the internal dimensions of the given rectangle with the current
    * foreground color of the canvas. This is a convenience method. A similar
    * effect can be achieved with the "fill" method.
    public void fillRectangle(int xPos, int yPos, int width, int height)
    fill(new Rectangle(xPos, yPos, width, height));
    * Erase the whole canvas.
    public void erase()
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    Dimension size = canvas.getSize();
    graphic.fill(new Rectangle(0, 0, size.width, size.height));
    graphic.setColor(original);
    canvas.repaint();
    * Erase the internal dimensions of the given circle. This is a
    * convenience method. A similar effect can be achieved with
    * the "erase" method.
    public void eraseCircle(int xPos, int yPos, int diameter)
    Ellipse2D.Double circle = new Ellipse2D.Double(xPos, yPos, diameter, diameter);
    erase(circle);
    * Erase the internal dimensions of the given rectangle. This is a
    * convenience method. A similar effect can be achieved with
    * the "erase" method.
    public void eraseRectangle(int xPos, int yPos, int width, int height)
    erase(new Rectangle(xPos, yPos, width, height));
    * Erase a given shape's interior on the screen.
    * @param shape the shape object to be erased
    public void erase(Shape shape)
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    graphic.fill(shape); // erase by filling background color
    graphic.setColor(original);
    canvas.repaint();
    * Erases a given shape's outline on the screen.
    * @param shape the shape object to be erased
    public void eraseOutline(Shape shape)
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    graphic.draw(shape); // erase by drawing background color
    graphic.setColor(original);
    canvas.repaint();
    * Draws an image onto the canvas.
    * @param image the Image object to be displayed
    * @param x x co-ordinate for Image placement
    * @param y y co-ordinate for Image placement
    * @return returns boolean value representing whether the image was
    * completely loaded
    public boolean drawImage(Image image, int x, int y)
    boolean result = graphic.drawImage(image, x, y, null);
    canvas.repaint();
    return result;
    * Draws a String on the Canvas.
    * @param text the String to be displayed
    * @param x x co-ordinate for text placement
    * @param y y co-ordinate for text placement
    public void drawString(String text, int x, int y)
    graphic.drawString(text, x, y);
    canvas.repaint();
    * Erases a String on the Canvas.
    * @param text the String to be displayed
    * @param x x co-ordinate for text placement
    * @param y y co-ordinate for text placement
    public void eraseString(String text, int x, int y)
    Color original = graphic.getColor();
    graphic.setColor(backgroundColor);
    graphic.drawString(text, x, y);
    graphic.setColor(original);
    canvas.repaint();
    * Draws a line on the Canvas.
    * @param x1 x co-ordinate of start of line
    * @param y1 y co-ordinate of start of line
    * @param x2 x co-ordinate of end of line
    * @param y2 y co-ordinate of end of line
    public void drawLine(int x1, int y1, int x2, int y2)
    graphic.drawLine(x1, y1, x2, y2);
    canvas.repaint();
    * Sets the foreground color of the Canvas.
    * @param newColor the new color for the foreground of the Canvas
    public void setForegroundColor(Color blue)
    graphic.setColor(Color.blue);
    * Returns the current color of the foreground.
    * @return the color of the foreground of the Canvas
    public Color getForegroundColor()
    return graphic.getColor();
    * Sets the background color of the Canvas.
    * @param newColor the new color for the background of the Canvas
    public void setBackgroundColor(Color newColor)
    backgroundColor = newColor;
    graphic.setBackground(newColor);
    * Returns the current color of the background
    * @return the color of the background of the Canvas
    public Color getBackgroundColor()
    return backgroundColor;
    * changes the current Font used on the Canvas
    * @param newFont new font to be used for String output
    public void setFont(Font newFont)
    graphic.setFont(newFont);
    * Returns the current font of the canvas.
    * @return the font currently in use
    public Font getFont()
    return graphic.getFont();
    * Sets the size of the canvas.
    * @param width new width
    * @param height new height
    public void setSize(int width, int height)
    canvas.setPreferredSize(new Dimension(width, height));
    Image oldImage = canvasImage;
    canvasImage = canvas.createImage(width, height);
    graphic = (Graphics2D)canvasImage.getGraphics();
    graphic.drawImage(oldImage, 0, 0, null);
    frame.pack();
    * Returns the size of the canvas.
    * @return The current dimension of the canvas
    public Dimension getSize()
    return canvas.getSize();
    * Waits for a specified number of milliseconds before finishing.
    * This provides an easy way to specify a small delay which can be
    * used when producing animations.
    * @param milliseconds the number
    public void wait(int milliseconds)
    try
    Thread.sleep(milliseconds);
    catch (InterruptedException e)
    // ignoring exception at the moment
    * Nested class CanvasPane - the actual canvas component contained in the
    * Canvas frame. This is essentially a JPanel with added capability to
    * refresh the image drawn on it.
    private class CanvasPane extends JPanel
    public void paint(Graphics g)
    g.drawImage(canvasImage, 0, 0, null);

    Dear Miciuli,
    I found the definition for the circle in the canvas class and used it to creates circles ! Thank you for jaring my brain into thinking !
    Stan
    Ellipse2D.Double circle = new Ellipse2D.Double(xPos, 70, 30 , 30);

  • Error in File name or class name not found during Automation operation: 'CreateObj​ect'

    Hello Team,
    When I am trying to execute the below code i am getting the following error. Any help would be greatly appreciated.
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    If Not oFSO.FolderExists(SavePath) Then
    Set f = oFSO.CreateFolder(SavePath)
    Else
    End If
    53 4/11/2014 12:27:22 PM Error:
    Error in <NoName(4).VBS> (Line: 9, Column: 1):
    File name or class name not found during Automation operation: 'CreateObject'
    I have googled through the error and tried to re-register the scrrun.dll using regsvr32 eventhogh it is successfully registered, i am getting the following error. My PC is windows 7 32bit OS.
    any help is greatly appreciated.

    The following script class will write a log file entry. See if it will run for you.
    The script is using a class object that you might not have seen before. A little intro:  The top section is just for testing the class. Normally I just comment this out after the class is working well.  It should run right way. I would save the vbs file in the editor, That way when you are using autoactpath or currentscriptpath variables they will be able resolve the paths.
    Paul
    Attachments:
    LoggingCode_V2.VBS ‏5 KB

  • Error oracle.sql.* and oracle.jdbc.driver.* not found when using oracle as a database

    I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
    Please Advice!
    Thanks in advance
    AnuPama

    Hi Anupama,
    First of all I would be surprised if you would not like to use the connection pooling feature of weblogic (in which case you might not be needing the import the classes directly), and would like to open direct connections to your database. Anyways for doing that I would recommend you to check out the readme doc that ships
    along with the jdbc oracle (classes12.zip etc). I am giving an excerpt over here:
    These are a few simple things that you should do in your JDBC program:
    1. Import the necessary JDBC classes in your programs that use JDBC.
    For example:
    import java.sql.*;
    import java.math.*;
    2. Register the Oracle driver before before calling other JDBC APIs.
    (This is not needed if you are using the JDBC Server-side Internal
    Driver because registration is done automatically in the server.)
    To register the Oracle driver, make sure the following statement
    is executed at least once in your Java session:
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    3. Open a connection to the database with the getConnection call.
    Different connection URLs should be used for different JDBC
    drivers. The following examples demonstrate the different URLs.
    For the JDBC OCI8 Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:oci8:@<database>",
    "scott", "tiger");
    where <database> is either an entry in tnsnames.ora or a SQL*net
    name-value pair.
    For the JDBC Thin Driver, or Server-side Thin Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@<database>",
    "scott", "tiger");
    where <database> is either a string of the form
    <host>:<port>:<sid> or a SQL*net name-value pair.
    For the JDBC Server-side Internal Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:kprb:");
    Note that the trailing ':' character is necessary. When you use
    the Server-side Internal Driver, you always connect to the
    database you are executing in. You can also do this:
    Connection conn
    = new oracle.jdbc.driver.OracleDriver().defaultConnection();
    Hope this helps,
    Thanks,
    Anupama wrote:
    I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
    Please Advice!
    Thanks in advance
    AnuPama--
    Apurb Kumar

Maybe you are looking for

  • Share buttons on Blogspot are not showing up.

    This is my blog address: http://realityhideseek.blogspot.com/ I have www.addtoany.com share buttons under each post that show up in Chrome, but not in Firefox. I've read several help articles, but none seem to do any good. This is only since the upgr

  • Sending Sales Order via Outlook

    Apologies if this is not the correct forum to post this question. We are trying to use outlook as the default email system to send Sales Order, PO's, Invoices, etc. We have tried the Outlook Integration to get a not so complete solution. We are now t

  • Maximum number of cookies that can be stored

    hi, i would like to know what is the maximum number of cookies that can be stored in a browser or in a client machine? moreover i would like to know the disadavantage of using cookies? can anybody please help me in this. thank u in advance. Fazlina

  • After update iTunes still says I need to update

    when I try to access iTunes it tells me I need to update my device. It gives me step by step. It then says it is up to date. But i still can't access itunes. It gives me the same message "Need tp update device". Don't know what else to do other than

  • Could not start the Oracle BI server service on local computer - error 1067

    Hi Guys, i've successfully installed the BI.however when i try to start the BI service, i get the above message.any ideas to fix this ? Thanks Jag