JRebel compatibility with latest weblogic

In our organization we have been using JRebel 6.3.1. It was working perfectly. Now we have upgraded weblogic to 12.2.1.3. Post this upgrade, the java changes are not being picked up. The JSP changes however are being picked up.
Is there any setting that needs to be done?

Loading a huge amount of data using OJB 1.4

I have a Set<String> catNames which contains a huge list of cats names (~35K) and I need to load from the database (Sybase) all of those Cat objects and put them into a Map<String, Cat> cats : each line contain the cat name and the corresponding cat object.

Knowing that I’m using OJB 1.4 (it load the object Cat and all of its dependencies like Food, Clothes…), which is the better way to load such enormous list of cats ?

Solution 1 : one access to the database per catName

cat = getCatByName(catName); then cats.put(catName, cat);
and return cats;

Solution 2 : one access to the database for all those cat names

cats = getCatsByNames(catNames); then

for (Iterator iterator = cats.iterator(); iterator.hasNext();) {
cat = (Cat)iterator.next();
cats.put(cat.getName(), cat);
}

and return cats;

PS : getCatsByNames uses criteria.addIn("catName", catNames);

I am using JDBC ODBC connection for reading Excel 2016 (32 bit) and JDK 1.7.0_80 (64 bit) but getting error

  1. My code is:
    Connection connection = DriverManager.getConnection(“jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};Extensions=xlsx;DBQ=”+ fileName + “;DriverID=22;READONLY=false”);

  2. The error is:
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6964)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7121)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3080)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:233)

java final object DateFormat set timezone

I have a database elsewhere that i have to get my data from that is in an other timezone.

To get the latest updated elements i need to convert the Date to the timezone of the database so i can only get the lines changed after a specific time.

For communication with the database i created a java class with all kind of static final elements. I would like to add a static final DateFormat with a SimpleDateFormat and a TimeZone so i can always use this FINAL DateFormat to change the date to the datetime of the database everywhere in the application.

So i have a class:

public class Data_DB {

static final DateFormat FORMATTER= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

}

I can use the DateFormat everywhere in my application, quite nice.
But i want to change the TimeZone of formatter too.

public class Data_DB {

static final DateFormat FORMATTERSD = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
static final DateFormat FORMATTERDB = FORMATTERSD.setTimeZone(TimeZone.getTimeZone("XXXX/xxxx"));

}

But the return value of FORMATTERSD.setTimeZone(TimeZone.getTimeZone(“XXXX/xxxx”)) is void.

I do not want to instantiate Data_DB to add the TimeZone tot it.

In what way can i solve this to get a static final element FORMATTERDB that i can use everywhere in the application ?

org.apache.ws.security.WSSecurityException: The signature verification failed (The provided certificate is invalid) apache axis

Getting the below mentioned error when customer application trying to submit a request to a webservice. Error says Certificate is invalid but the customer claims their certificate is valid. Is this something that needs to be looked at service end. Please help. Thanks.

Service Provider Apache Axis Version: 1.2
Java version : 1.8

    2017-10-03 12:31:34,622 WARN  [com.company.app.common.WSSignatureReader] 
      [Request: 1507048294573] Error processing security
    org.apache.ws.security.WSSecurityException: The signature verification failed (The provided certificate is invalid)
    at org.apache.ws.security.WSSecurityEngine.verifyXMLSignature(WSSecurityEngine.java:544)
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:324)
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:239)
    at com.company.app.common.WSSignatureReader.process(WSSignatureReader.java:124)
    at com.company.app.common.WSSignatureReader.isValid(WSSignatureReader.java:59)
    at com.company.app.common.SignatureCriteria.isValid(SignatureCriteria.java:47)
    at com.company.app.midtier.validation.handlers.RequestToCompanyValidator.invoke(RequestToCompanyValidator.java:51)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:455)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Thread.java:745)
   2017-10-03 12:31:34,629 WARN  [com.company.app.common.WSSignatureReader] 
   [Request: 1507048294573] Exception verifying signature
   com.company.app.common.ValidationException: WSDoAllReceiver: security processing failed
    at com.company.app.common.WSSignatureReader.process(WSSignatureReader.java:134)
    at com.company.app.common.WSSignatureReader.isValid(WSSignatureReader.java:59)
    at com.company.app.common.SignatureCriteria.isValid(SignatureCriteria.java:47)
    at com.company.app.midtier.validation.handlers.RequestToCompanyValidator.invoke(RequestToCompanyValidator.java:51)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:455)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Thread.java:745)
  Caused by: org.apache.ws.security.WSSecurityException: The signature 
  verification failed (The provided certificate is invalid)
    at org.apache.ws.security.WSSecurityEngine.verifyXMLSignature(WSSecurityEngine.java:544)
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:324)
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:239)
    at com.company.app.common.WSSignatureReader.process(WSSignatureReader.java:124)
    ... 30 more
2017-10-03 12:31:34,632 WARN  [com.company.app.midtier.validation.handlers.RequestToCompanyValidator] [Request: 1507048294573] Unexpected Exception
   AxisFault
      faultCode: {http://www.w3.org/2003/05/soap-envelope}Server.generalException
 faultSubcode:
   faultString: Request is not properly signed or has been tampered with :
    faultActor:
  faultNode:
  faultDetail:
 {http://xml.apache.org/axis/}exceptionName:com.company.app.common.GVIAxisFault
    {http://xml.apache.org/axis/}hostname:s1qvap991

  Request is not properly signed or has been tampered with :
     at com.company.app.common.GVIHandlerA.reportError(GVIHandlerA.java:41)
     at com.company.app.midtier.validation.handlers.RequestToCompanyValidator.invoke(RequestToCompanyValidator.java:53)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:455)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:301)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Thread.java:745)

Spring Boot – Mapping similar requests for Deletion

How would one implement a simple deletion Rest request in the Controller suchh that I can delete both by id and by name?

I have attempted to emmulate the This StackOverflow question but with no luck so far. Please see code below.

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void removeStudent(@PathVariable("id") int id){
   studentService.removeStudent(id);
}

@RequestMapping(method = RequestMethod.DELETE)
public void removeStudent(@RequestParam(value="name") String name){
   studentService.removeStudent(name);
}

Deleting by id works perfectly, however when attempting to delete by name – nothing works.

I attempted to GET just the specific record for a name with the following as per the previous question mentioned:

http://localhost:8080/students?name=FOUR

But it brings EVERYTHING back…

Insert a document JSON from URL in mongodb with java

I’m new in MongoDb and I have to upload a file in MongoDB with a java program.
I tried to write something but I do not know if it’s the right way.
Can someone help me?
My difficulty is that the json file I have to upload is in a link address.
can mongodb read and upload the document to a database through java language?
I load the code below.
Thank you.

import java.io.IOException;
import java.util.Iterator;
import org.bson.Document;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.util.JSON;


public class mongodb {

public static void main (String args []) throws IOException {

    MongoClient mongo = null;
    MongoDatabase db = null;

    try {
        /**** Connect to MongoDB ****/
        mongo = new MongoClient("localhost", 27017);

        /**** Get database ****/
        db = mongo.getDatabase("db_plant");

        System.out.println("Successfully connected to database");           
    } catch (Exception e) {
        System.err.println( e.getClass().getName() + ": " + e.getMessage() );
    }

    DBCollection collection = db.getCollection("plants");

    final String URL = "https://www.plants.usda.gov/java/downloadData?fileName=plantlst.txt&static=true";
    String json = getTextFromUrl(URL);

    DBObject dbObject = (DBObject)JSON.parse(json);
    collection.insert(dbObject);

    DBCursor cursorDocJSON = collection.find();
    while (cursorDocJSON).hasNext() {
        System.out.println(cursorDocJSON).next();
    }
    collection.remove(new BasicDBObject();
}

private static String getTextFromUrl(String uRL) {
    // TODO Auto-generated method stub
    return null;
}

}

Grey screen when using Windows, but JFrames are fine

This test code making use of JFrames works as intended (will close after 10 secs).

// **** Imports ****
import java.awt.*;
import javax.swing.JFrame;




public class TestDisplay extends JFrame {

// **** Constructor ****

public static void main(String[] args)
{
    DisplayMode dm = 
            new DisplayMode(800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);

    TestDisplay td = new TestDisplay();
    td.run(dm);
}

// **** Methods ****

public void run(DisplayMode dm)
{
    getContentPane().setBackground(Color.PINK);
    setForeground(Color.WHITE);
    setFont(new Font("Arial", Font.PLAIN, 24));

    Screen s = new Screen();
    try{
        s.setFullScreen(dm, this);
        try{
            Thread.sleep(10000); // Delay before restoring screen (10 secs)
        }catch(Exception ex){}

    }finally{s.restoreScreen();}

}

public void paint(Graphics g) // JFrame calls paint method automatically
{
    super.paint(g);

    if(g instanceof Graphics2D)
    {
        System.out.println("It is Graphics2D");

        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint // Turn on antialiasing for text
    (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }

    g.drawString("This will be really cool", 200, 200);
}

}

However, when using Windows my grey screen problem persists.
In the TestDisplay > paint method, I encountered the same problem if I removed the “super.paint(g);” line.
These are the following blocks that comprise my code that does not render correctly, but it runs correctly. (Press ESC to close the window)

KeyTest class:

// **** Imports ****
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyTest extends Core implements KeyListener{

// **** Variables ****
private String mess = "";


// **** Constructor ****
public static void main(String[] args)
{
    new KeyTest().run();
}

// **** Methods ****

//init also call init from superclass
public void init()
{
    super.init();
    Window w = s.getFullScreenWindow();
    w.setFocusTraversalKeysEnabled(false); //make wierd buttons not wierd
    w.addKeyListener(this);
    mess = "Press escape to exit!";
}

//key pressed
public void keyPressed(KeyEvent e)
{
    int keyCode = e.getKeyCode();
    if(keyCode == KeyEvent.VK_ESCAPE)
    {
        stop();
    }
    else
    {
        mess = "Pressed : " + KeyEvent.getKeyText(keyCode);
        e.consume(); //prevents button combinations (ex. alt + F = get file)
    }
}

//key released
public void keyReleased(KeyEvent e)
{
    int keyCode = e.getKeyCode();
    mess = "Released : " + KeyEvent.getKeyText(keyCode);
    e.consume(); //prevents button combinations (ex. alt + F = get file)
}

//last method from interface
public void keyTyped(KeyEvent e)
{
    e.consume();
}

//draw 
public synchronized void draw(Graphics2D g)
{
    Window w = s.getFullScreenWindow();

    g.setColor(w.getBackground());
    g.fillRect(0, 0, s.getWidth(), s.getHeight());
    g.drawString(mess, 30, 30);

}
}

Core abstract class:

// **** Imports ****
import java.awt.*;
import javax.swing.*;

public abstract class Core {

// **** Variables ****
private static final DisplayMode[] modes1 = 
{
    new DisplayMode(1920, 1080, 64, 0),
    new DisplayMode(1920, 1080, 32, 0),
    new DisplayMode(800, 600, 32, 0),
    new DisplayMode(800, 600, 24, 0),
    new DisplayMode(800, 600, 26, 0),
    new DisplayMode(640, 480, 32, 0),
    new DisplayMode(640, 480, 24, 0),
    new DisplayMode(640, 480, 16, 0),
};

private boolean running;
protected ScreenManager s;

// **** Constructor ****

// **** Methods ****

//Stop method
public void stop()
{
    running = false;
}

//call init and gameloop
public void run()
{
    try{
        init();
        gameLoop();
    }finally{s.restoreScreen();}

}

//set to full screen
public void init(){
    s = new ScreenManager();
    DisplayMode dm = s.findFirstCompatibleMode(modes1);
    s.setFullScreen(dm);
    Window w = s.getFullScreenWindow();
    w.setFont(new Font("Arial", Font.PLAIN, 20));
    w.setForeground(Color.RED);
    w.setForeground(Color.WHITE);
    running = true;
}

//main gameloop
public void gameLoop()
{
    long startTime = System.currentTimeMillis();
    long cTime = startTime;

    while(running)
    {
        long timePassed = System.currentTimeMillis();
        cTime = cTime + timePassed;

        update(timePassed);

        Graphics2D g = s.getGraphics();
        draw(g);
        g.dispose();
        s.update();

        try{
            Thread.sleep(20);
        }catch(Exception ex){}
    }
}

//update animation
public void update(long timePassed){}

//draws to the screen
public abstract void draw(Graphics2D g);
}

ScreenManager class:

// **** Imports ****
import java.awt.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JFrame;


public class ScreenManager {

// **** Variables ****

private GraphicsDevice vc;

// **** Constructor ****

public ScreenManager()
{
    //give vc access to monitor screen
    GraphicsEnvironment e = 
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    vc = e.getDefaultScreenDevice();
}

// **** Methods ****

// ____ Handle Display Modes ____

//get all compatible display modes
public DisplayMode[] getCompatibleDiplayModes(){
    return vc.getDisplayModes();
}

//compares display modes passed into vc and checks for a match
public DisplayMode findFirstCompatibleMode(DisplayMode modes[])
{
    DisplayMode goodModes[] = vc.getDisplayModes();
    for(int x=0; x<modes.length;x++)
    {
        for(int y=0;y<goodModes.length;y++)
        {
            if(displayModesMatch(modes[x], goodModes[y]))
            {
                return modes[x];
            }
        }
    }
    return null;
}

//get current display mode
public DisplayMode getCurrentDisplayMode()
{
    return vc.getDisplayMode();
}

//check if two modes match
public boolean displayModesMatch(DisplayMode m1, DisplayMode m2)
{
    //test if resolution match (if not match, false)
    if(m1.getWidth() != m2.getWidth() || m1.getHeight() != m2.getHeight())
    {
        return false;
    }
    //test if bit depth match ((if not match, false)
    if(m1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI 
            && m2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI
            && m1.getBitDepth() != m2.getBitDepth())
    {
        return false;
    }
    //test if refresh rate match (if not match, false)
    if(m1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
            && m2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN
            && m1.getRefreshRate() != m2.getRefreshRate())
    {
        return false;
    }

    return true;
}

// ____ Handle Graphics ____

//make jframe full screen
public void setFullScreen(DisplayMode dm)
{
    //Frame f = new Frame();
    JFrame f = new JFrame();

    f.setUndecorated(true);
    f.setIgnoreRepaint(true);
    f.setResizable(false);
    vc.setFullScreenWindow(f);

    if(dm != null && vc.isDisplayChangeSupported())
    {
        try{
            vc.setDisplayMode(dm);
        }catch(Exception ex){}
    }
    f.createBufferStrategy(2);
}

// ??? important magic ???
public Graphics2D getGraphics(){
    Window w = vc.getFullScreenWindow();
    if ( w != null)
    {
        BufferStrategy s = w.getBufferStrategy();
        return (Graphics2D)s.getDrawGraphics();
    }
    else
    {
        return null;
    }
}

//updates display
public void update()
{
    Window w = vc.getFullScreenWindow();
    if(w != null)
    {
        BufferStrategy s = w.getBufferStrategy();

        //only display new frame when it is ready
        if(!s.contentsLost())
        {
            s.show();
        }
    }
}

//returns full screen window
public Window getFullScreenWindow()
{
    return vc.getFullScreenWindow();
}

//get Width of window
public int getWidth()
{
    Window w = vc.getFullScreenWindow();
    if(w != null)
    {
        return w.getWidth();
    }
    else
    {
        return 0;
    }
}

//get Height of window
public int getHeight()
{
    Window w = vc.getFullScreenWindow();
    if(w != null)
    {
        return w.getHeight();
    }
    else
    {
        return 0;
    }
}

//get out of fullscreen
public void restoreScreen()
{
    Window w = vc.getFullScreenWindow();
    if (w != null)
    {
        w.dispose();
    }
    vc.setFullScreenWindow(null);
}

//create image compatible with monitor (width, height, transparency)
public BufferedImage createCompatibleImage(int w, int h, int t)
{
    Window win = vc.getFullScreenWindow();
    if(win != null)
    {
        GraphicsConfiguration gc = win.getGraphicsConfiguration();
        return gc.createCompatibleImage(w, h, t);
    }
    return null;
}


}

I would greatly appreciate any ideas you guys might have about solving this.

Android – Button changes backgroundimage for new activity

I want my Button to open a new activity using an intent.
This I already implemented and it works.

My problem is setting the backgroundimage for this new activity.

For example:

  • When button1 got pressed the new activity opens with image1 as
    background.
  • When button2 got pressed the new activity opens with image2 as
    background.

    Would be very nice if someone would know the javacode to implement this feature or where I could find it.

Thank you very much!
Taka

Why is the CDI bean not detected only if it is public?

This one is puzzling me. I created a minimal JAX-RS application based on JavaEE7 running on Wildfly 10.1.

@ApplicationPath("")
public class JAXRSConfiguration extends Application {

    @Override
    public Set<Class<?>> getClasses() {
        return new HashSet<Class<?>>(Arrays.asList(Resource.class));
    }
}

The resource injects a single dummy stateless bean:

@Path("")
public class Resource {

    @Inject
    Manager manager;

    @GET
    @Path("/go")
    public void go() {
        manager.call();
    }
}

This is the bean:

@Stateless
public class Manager {

    @PostConstruct
    private void init() {
        System.out.println("POST CONSTRUCT ");
    }

    void call() {
        System.out.println("called ");
    }
}

Using the browser to execute the GET causes the following error:

org.jboss.resteasy.spi.UnhandledException: org.jboss.weld.exceptions.WeldException: Class org.jboss.weld.util.reflection.Reflections can not access a member of class com.a.b.Manager with modifiers ""

Can post full stack trace but all the Caused By messages are the same.

I searched for this error and it happens when the injected bean is not public, but mine is. I decided to try to remove the public to see what it will complain about and… it works. The bean is injected, any injections it might have are injected, the post construct method is called and all the prints are printed.

This is in complete contrast to Does ejb stateless class has to be public?. What’s going on here?