Java, JPA, Glassfish, Invalid resource : jdbc/__default__pm

后端 未结 8 865
不知归路
不知归路 2020-12-02 17:32

I use Glassfish 3.1.2.2 (build 5), JPA, EclipseLink, MySQL

I created MySQL pool via Glassfish admin panel. Ping to MySQL from GF admin panel is ok.

I created

8条回答
  •  有刺的猬
    2020-12-02 17:39

    This could happen due to a NetBeans bug they say they had fixed but seemingly they had not. As a solution, I ended up removing glassfish-resources.xml altogether (as I couldn't make persistence.xml pick it up with any kind of the workarounds) and using @DataSourceDefinition annotation instead.

    My configuration uses a separate DataSourceBean.java file for @DataSourceDefinition:

    @Singleton
    @Startup
    @DataSourceDefinition(name="java:global/jdbc/myDataSource",
        className="com.microsoft.sqlserver.jdbc.SQLServerDataSource",
        url="jdbc:sqlserver://127.0.0.1:1433;databaseName=myDB",
        user="myuser",
        password="mypassword"
    )
    public class DataSourceBean {
    }
    

    persistence.xml looks like that:

    
    
        
            java:global/jdbc/myDataSource
            
                
            
        
    
    

提交回复
热议问题